Skip to content

Commit

Permalink
Merge pull request #56 from nfdi4health/merge-seek-1.15.1intoLDH
Browse files Browse the repository at this point in the history
Merge seek 1.15.1 into LDH main
  • Loading branch information
ReneHaensel authored Jul 9, 2024
2 parents 8003816 + 7208cc5 commit f3bcd95
Show file tree
Hide file tree
Showing 279 changed files with 4,168 additions and 2,329 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ gem 'will_paginate', '~> 3.1'
gem 'yaml_db'
gem 'rails_autolink'
gem 'rfc-822'
gem 'nokogiri', '~> 1.16.2'
gem 'nokogiri', '~> 1.16'
#necessary for newer hashie dependency, original api_smith is no longer active
gem 'api_smith', git: 'https://github.com/youroute/api_smith.git', ref: '1fb428cebc17b9afab25ac9f809bde87b0ec315b'
gem 'rdf-virtuoso', '>= 0.2.0'
Expand Down
126 changes: 64 additions & 62 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,40 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (4.3.3)
actioncable (6.1.7.7)
actionpack (= 6.1.7.7)
activesupport (= 6.1.7.7)
actioncable (6.1.7.8)
actionpack (= 6.1.7.8)
activesupport (= 6.1.7.8)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.7)
actionpack (= 6.1.7.7)
activejob (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
actionmailbox (6.1.7.8)
actionpack (= 6.1.7.8)
activejob (= 6.1.7.8)
activerecord (= 6.1.7.8)
activestorage (= 6.1.7.8)
activesupport (= 6.1.7.8)
mail (>= 2.7.1)
actionmailer (6.1.7.7)
actionpack (= 6.1.7.7)
actionview (= 6.1.7.7)
activejob (= 6.1.7.7)
activesupport (= 6.1.7.7)
actionmailer (6.1.7.8)
actionpack (= 6.1.7.8)
actionview (= 6.1.7.8)
activejob (= 6.1.7.8)
activesupport (= 6.1.7.8)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.7.7)
actionview (= 6.1.7.7)
activesupport (= 6.1.7.7)
actionpack (6.1.7.8)
actionview (= 6.1.7.8)
activesupport (= 6.1.7.8)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.7.7)
actionpack (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
actiontext (6.1.7.8)
actionpack (= 6.1.7.8)
activerecord (= 6.1.7.8)
activestorage (= 6.1.7.8)
activesupport (= 6.1.7.8)
nokogiri (>= 1.8.5)
actionview (6.1.7.7)
activesupport (= 6.1.7.7)
actionview (6.1.7.8)
activesupport (= 6.1.7.8)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -94,14 +94,14 @@ GEM
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.1.7.7)
activesupport (= 6.1.7.7)
activejob (6.1.7.8)
activesupport (= 6.1.7.8)
globalid (>= 0.3.6)
activemodel (6.1.7.7)
activesupport (= 6.1.7.7)
activerecord (6.1.7.7)
activemodel (= 6.1.7.7)
activesupport (= 6.1.7.7)
activemodel (6.1.7.8)
activesupport (= 6.1.7.8)
activerecord (6.1.7.8)
activemodel (= 6.1.7.8)
activesupport (= 6.1.7.8)
activerecord-import (1.3.0)
activerecord (>= 4.2)
activerecord-session_store (2.0.0)
Expand All @@ -110,14 +110,14 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 3)
railties (>= 5.2.4.1)
activestorage (6.1.7.7)
actionpack (= 6.1.7.7)
activejob (= 6.1.7.7)
activerecord (= 6.1.7.7)
activesupport (= 6.1.7.7)
activestorage (6.1.7.8)
actionpack (= 6.1.7.8)
activejob (= 6.1.7.8)
activerecord (= 6.1.7.8)
activesupport (= 6.1.7.8)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.7)
activesupport (6.1.7.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -198,7 +198,7 @@ GEM
execjs
coffee-script-source (1.12.2)
commonmarker (0.23.10)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.1)
connection_pool (2.3.0)
countries (5.2.0)
unaccent (~> 0.3)
Expand Down Expand Up @@ -322,7 +322,7 @@ GEM
httpclient (2.8.3)
httpi (1.1.1)
rack
i18n (1.14.4)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
i18n-js (3.9.0)
i18n (>= 0.6.6)
Expand Down Expand Up @@ -460,7 +460,7 @@ GEM
nokogiri (~> 1)
rake
mini_mime (1.1.5)
mini_portile2 (2.8.5)
mini_portile2 (2.8.7)
minitest (5.20.0)
minitest-reporters (1.5.0)
ansi
Expand Down Expand Up @@ -492,7 +492,7 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.7.0)
nokogiri (1.16.2)
nokogiri (1.16.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nori (1.1.5)
Expand Down Expand Up @@ -566,8 +566,8 @@ GEM
puma (5.6.8)
nio4r (~> 2.0)
pyu-ruby-sasl (0.0.3.3)
racc (1.7.3)
rack (2.2.8.1)
racc (1.8.0)
rack (2.2.9)
rack-attack (6.6.0)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
Expand All @@ -584,20 +584,20 @@ GEM
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.7.7)
actioncable (= 6.1.7.7)
actionmailbox (= 6.1.7.7)
actionmailer (= 6.1.7.7)
actionpack (= 6.1.7.7)
actiontext (= 6.1.7.7)
actionview (= 6.1.7.7)
activejob (= 6.1.7.7)
activemodel (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
rails (6.1.7.8)
actioncable (= 6.1.7.8)
actionmailbox (= 6.1.7.8)
actionmailer (= 6.1.7.8)
actionpack (= 6.1.7.8)
actiontext (= 6.1.7.8)
actionview (= 6.1.7.8)
activejob (= 6.1.7.8)
activemodel (= 6.1.7.8)
activerecord (= 6.1.7.8)
activestorage (= 6.1.7.8)
activesupport (= 6.1.7.8)
bundler (>= 1.15.0)
railties (= 6.1.7.7)
railties (= 6.1.7.8)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand Down Expand Up @@ -625,9 +625,9 @@ GEM
json
require_all (~> 3.0)
ruby-progressbar
railties (6.1.7.7)
actionpack (= 6.1.7.7)
activesupport (= 6.1.7.7)
railties (6.1.7.8)
actionpack (= 6.1.7.8)
activesupport (= 6.1.7.8)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down Expand Up @@ -728,7 +728,8 @@ GEM
netrc (~> 0.8)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
rexml (3.2.8)
strscan (>= 3.0.9)
rfc-822 (0.4.1)
rmagick (5.3.0)
pkg-config (~> 1.4)
Expand Down Expand Up @@ -861,6 +862,7 @@ GEM
sqlite3 (1.4.2)
stackprof (0.2.25)
stringio (3.0.1.1)
strscan (3.1.0)
sunspot (2.6.0)
pr_geohash (~> 1.0)
rsolr (>= 1.1.1, < 3)
Expand Down Expand Up @@ -950,7 +952,7 @@ GEM
rails (>= 3.0)
rake (>= 0.8.7)
yard (0.9.36)
zeitwerk (2.6.13)
zeitwerk (2.6.15)
zip-container (4.0.2)
rubyzip (~> 2.0.0)

Expand Down Expand Up @@ -1028,7 +1030,7 @@ DEPENDENCIES
my_responds_to_parent!
mysql2
net-ftp
nokogiri (~> 1.16.2)
nokogiri (~> 1.16)
omniauth (~> 2.1.0)
omniauth-github
omniauth-rails_csrf_protection
Expand Down
16 changes: 8 additions & 8 deletions app/assets/javascripts/single_page/dynamic_table.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function sanitizeData(data) {

const objectInputTemp = '<input type="hidden" name="_NAME_[]" id="inpt-_NAME_" value="" autocomplete="off" />' +
'<select name="_NAME_[]" id="select-_NAME_" class="form-control _EXTRACLASS_" title="_TITLE_" data-role="seek-objectsinput" ' +
'data-tags-limit="100" _MULTIPLE?_ style="background-color: coral;" data-typeahead-template="_TYPEHEAD_"' +
'data-tags-limit="_LIMIT?_" multiple style="background-color: coral;" data-typeahead-template="_TYPEHEAD_"' +
'data-typeahead-query-url="_URL_" data-allow-new-items=_ALLOW_FREE_TEXT_>_OPTIONS_</select>';

const typeaheadSamplesUrl = "<%= typeahead_samples_path(linked_sample_type_id: '_LINKED_') %>";
Expand Down Expand Up @@ -86,11 +86,12 @@ const handleSelect = (e) => {
}

c["render"] = function(data_, type, full, meta) {
sanitizedData = sanitizeData(data_);
let sanitizedData = sanitizeData(data_);
let data;
if(c.linked_sample_type){
data = sanitizedData && Array.isArray(sanitizedData) ? sanitizedData : [sanitizedData];
data = data[0]?.id ? data : [];
return inputObjectsInput(c, data, options, linkedSamplesUrl);
return registeredSamplesObjectsInput(c, data, options, linkedSamplesUrl);
} else if(c.is_cv_list && sanitizedData !== "#HIDDEN"){
data = sanitizedData && Array.isArray(sanitizedData) ? sanitizedData : [sanitizedData];
data = data.map((e) => {
Expand Down Expand Up @@ -569,7 +570,7 @@ function retrieveLinkedSamples(url){
return linkedSamples;
}

function inputObjectsInput(column, data, options, url){
function registeredSamplesObjectsInput(column, data, options, url){
const existingOptions = data.map((e) => {
isHiddenInput = (e.title == '#HIDDEN');
if (isHiddenInput) {
Expand All @@ -584,7 +585,6 @@ function inputObjectsInput(column, data, options, url){
const typeaheadTemplate = 'typeahead/single_pages_samples'
const objectInputName = data.map((e) => e.id).join('-') + '-' + crypto.randomUUID();


const unLinkedSamples = data.reduce(function(filtered, sample) {
if(!column.linkedSampleIds.includes(parseInt(sample.id)) && sample.title != '#HIDDEN'){
filtered.push(sample);
Expand All @@ -593,7 +593,7 @@ function inputObjectsInput(column, data, options, url){
}, []);
const hasUnlinkedSamples = unLinkedSamples.length > 0 ? true : false;

const hasMultipleInputs = column.multi_link ? 'multiple="multiple"' : ''
const hasMultipleInputs = column.multi_link ? '100' : '1'
const extraClass = hasUnlinkedSamples ? 'select2__error' : '';
const titleText = hasUnlinkedSamples ? `Sample(s) '${unLinkedSamples.map(uls => uls.title).join(', ')}' not recognised as input. Please correct this issue!` : '';
setTimeout(ObjectsInput.init);
Expand All @@ -605,7 +605,7 @@ function inputObjectsInput(column, data, options, url){
.replace('_OPTIONS_', existingOptions)
.replace('_EXTRACLASS_', extraClass)
.replace('_TITLE_', titleText)
.replace('_MULTIPLE?_', hasMultipleInputs)
.replace('_LIMIT?_', hasMultipleInputs)
.replace('_ALLOW_FREE_TEXT_', false);
}
}
Expand All @@ -629,7 +629,7 @@ function cvListObjectsInput(column, data, options, url){
.replace('_OPTIONS_', existingOptions)
.replace('_EXTRACLASS_', extraClass)
.replace('_TITLE_', titleText)
.replace('_MULTIPLE?_', 'multiple="multiple"')
.replace('_LIMIT?_', '')
.replace('_ALLOW_FREE_TEXT_', allowNewItems);
}
}
Expand Down
30 changes: 19 additions & 11 deletions app/assets/javascripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const applyTemplate = () => {
$j('#template_level').val(data.level);
$j('#template_parent_id').val(data.template_id);

const appliedToSampleType = $j('#template_level')[0] === undefined || $j('#template_level')[0] === null;
// Make sure default sorted attributes are added to the table
Templates.table.order([9, "asc"]).draw();
$j.each(Templates.table.rows().data(), (i, row) => {
Expand All @@ -239,24 +240,25 @@ const applyTemplate = () => {
row[7] === "Registered Sample List" &&
row[1].includes("Input") &&
row[11] === null;
const isInherited = row[14] !== "undefined" || row[14] !== null;
const isRequired = row[0] ? "checked" : "";
newRow = $j(newRow.replace(/replace-me/g, index));
$j(newRow).find('[data-attr="required"]').prop("checked", row[0]);
if (appliedToSampleType) $j(newRow).find('[data-attr="required"]').addClass("disabled");
$j(newRow).find(".sample-type-is-title").prop("checked", row[8]);
if (appliedToSampleType) $j(newRow).find('.sample-type-is-title').addClass("disabled");
$j(newRow).find('[data-attr="title"]').val(row[1]);
$j(newRow).find('[data-attr="title"]').addClass("disabled");
if (appliedToSampleType) $j(newRow).find('[data-attr="title"]').addClass("disabled");
$j(newRow).find('[data-attr="description"]').val(row[2]);
$j(newRow).find('[data-attr="type"]').val(row[3]);
$j(newRow).find('[data-attr="type"]').addClass("disabled");
if (appliedToSampleType) $j(newRow).find('[data-attr="type"]').addClass("disabled");
$j(newRow).find('[data-attr="cv_id"]').val(row[4]);
$j(newRow).find('[data-attr="cv_id"]').parent().addClass("disabled");
if (appliedToSampleType) $j(newRow).find('[data-attr="cv_id"]').parent().addClass("disabled");
$j(newRow).find('[data-attr="allow_cv_free_text"]').prop("checked", row[5]);
$j(newRow)
.find('[data-attr="allow_cv_free_text"]')
.addClass("disabled");
if (appliedToSampleType) $j(newRow)
.find('[data-attr="allow_cv_free_text"]')
.addClass("disabled");
$j(newRow).find('[data-attr="unit"]').val(row[6]);
$j(newRow).find('[data-attr="unit"]').addClass("disabled");
$j(newRow).find(".sample-type-is-title").prop("checked", row[8]);
if (appliedToSampleType) $j(newRow).find('[data-attr="unit"]').addClass("disabled");
$j(newRow).find('[data-attr="pid"]').val(row[9]);
$j(newRow).find('[data-attr="isa_tag_id"]').val(row[11]);
$j(newRow).find('[data-attr="isa_tag_title"]').val(row[11]);
Expand All @@ -265,7 +267,10 @@ const applyTemplate = () => {
.addClass("disabled");
$j(newRow).find('[data-attr="template_attribute_id"]').val(row[14]); // In case of a sample type
$j(newRow).find('[data-attr="parent_attribute_id"]').val(row[14]); // In case of a template
if (isRequired) {

// Hide the remove button if the attribute is required and it is applied to a sample type.
// Template attributes should always be removeable
if (isRequired && appliedToSampleType) {
$j(newRow).find('label.btn.btn-danger').addClass("hidden");
}

Expand Down Expand Up @@ -293,9 +298,12 @@ const applyTemplate = () => {
const template_id_tag = $j(`#isa_study${suffix}template_parent_id`);
if (template_id_tag) $j(template_id_tag).val(id);

// Removes the hidden from the new attribute button
$j(`${attribute_table} ${addAttributeRow}`).find('#add-attribute').removeClass("hidden");

SampleTypes.recalculatePositions();
SampleTypes.bindSortable();
$j(".sample-type-attribute-type").trigger("change", [false]);
$j(".sample-type-attribute-type").trigger("change", [false]);
};

// Shows the modal form
Expand Down
Loading

0 comments on commit f3bcd95

Please sign in to comment.