Skip to content

Commit

Permalink
Merge branch 'main' into full-test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Jan 19, 2024
2 parents 8fb0352 + 0ea9bd4 commit f99c3e9
Show file tree
Hide file tree
Showing 300 changed files with 7,902 additions and 1,797 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ gem 'remotipart', '~> 1.4.4' # Allows file upload in AJAX forms

gem 'rails-static-router'

gem 'caxlsx', '>= 3.0' # Write content to an xlsx file
gem 'caxlsx', '>= 4.0' # Write content to an xlsx file
gem 'caxlsx_rails', '~> 0.6.2'

gem 'net-ftp'
Expand All @@ -181,10 +181,10 @@ group :development do
gem "flamegraph", "~> 0.9.5"
gem "stackprof", "~> 0.2.25"
gem 'listen', '~> 3.3'
gem 'ruby-prof'
end

group :test do
gem 'ruby-prof'
gem 'test-prof'
gem 'rails-perftest'
gem 'minitest', '~> 5.14'
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ GIT
GEM
remote: https://rubygems.org/
specs:
RedCloth (4.3.2)
RedCloth (4.3.3)
actioncable (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
Expand Down Expand Up @@ -168,7 +168,7 @@ GEM
builder (3.2.4)
case_transform (0.2)
activesupport
caxlsx (3.3.0)
caxlsx (4.0.0)
htmlentities (~> 4.3, >= 4.3.4)
marcel (~> 1.0)
nokogiri (~> 1.10, >= 1.10.4)
Expand Down Expand Up @@ -491,7 +491,7 @@ GEM
net-smtp (0.3.3)
net-protocol
netrc (0.11.0)
nio4r (2.5.9)
nio4r (2.7.0)
nokogiri (1.14.5)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
Expand Down Expand Up @@ -563,7 +563,7 @@ GEM
psych (5.1.0)
stringio
public_suffix (5.0.0)
puma (5.6.7)
puma (5.6.8)
nio4r (~> 2.0)
pyu-ruby-sasl (0.0.3.3)
racc (1.7.1)
Expand Down Expand Up @@ -979,7 +979,7 @@ DEPENDENCIES
bootsnap (>= 1.4.4)
bootstrap-sass (>= 3.4.1)
bundler (>= 1.8.4)
caxlsx (>= 3.0)
caxlsx (>= 4.0)
caxlsx_rails (~> 0.6.2)
cff (~> 0.9.0)
citeproc-ruby (~> 2.0.0)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@
//= require jquery.splitter/jquery.splitter.min
//= require select2.full.min
//= require licenses
//= require svg-pan-zoom-3.6.1/svg-pan-zoom.min
18 changes: 18 additions & 0 deletions app/assets/javascripts/application_shared.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ function digValue(object, path) {
elements.removeClass(cssClass)
}, 1100);
};

// Fixes select2 in modals: https://github.com/select2/select2/issues/1436
$j.fn.modal.Constructor.prototype.enforceFocus = function () {};
}(jQuery));

$j(document).ready(function () {
Expand Down Expand Up @@ -401,6 +404,21 @@ $j(document).ready(function () {
$j(document).on('click', '.sidebar-backdrop', Sidebar.toggle);

Licenses.init();

$j('.svg-pan-zoom').each(function () {
// Does not seem to work using jQuery load event, so doing it vanilla way
this.addEventListener('load', function () {
svgPanZoom(this, {
zoomEnabled: true,
dblClickZoomEnabled: true,
mouseWheelZoomEnabled: false,
controlIconsEnabled: true,
contain: false,
fit: true
});
});
});
});


var URL_ROOT = '<%= Rails.application.config.relative_url_root %>';
64 changes: 14 additions & 50 deletions app/assets/javascripts/controlled_vocabs.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,26 @@ CVTerms = {
$j(':input:not(.destroy-attribute)', row).prop('disabled', false);
}
},
// processes the JSON response when fetching terms, and populates the term list
handleOntologyTermsJSONResponse: function (json) {
$j.each(json, function (key, term) {
//make a new term
CVTerms.addNewTermRow();

//get the last row and its inputs
var row = $j('table#new-terms tr.sample-cv-term').last();
var inputs = $j(row).find('td input');

$j(inputs).prop('readonly',true);

//inputs 0,1,2 are label, iri, and parent_iri
$j(inputs[0]).val(term.label);
$j(inputs[1]).val(term.iri);
$j(inputs[2]).val(term.parent_iri);
});
handleOntologyTermsHTMLResponse: function (html) {
$j('#add-term-button-row').before(html);
},
// adds a new blank row to the terms list
addNewTermRow: function () {
var newTerm = $j('#new-term-row tbody').clone().html();
let newTerm = $j('#new-term-row tbody').clone().html();

var index = 0;
$j('#new-terms tr.sample-cv-term').each(function () {
var newIndex = parseInt($j(this).data('index'));
if (newIndex > index) {
index = newIndex;
}
});
let index = 0;

//can't be reordered, so the last should always be the highest index
if ($j('#new-terms tr.sample-cv-term').length) {
index = parseInt($j('#new-terms tr.sample-cv-term').last().data('index'));
}
index++;

newTerm = newTerm.replace(/--index--/g, index);
$j('#add-term-button-row').before($j(newTerm));
},
// reports the error when the ajax method to fetch the terms is unsuccessful
reportFetchError: function (json) {
var error_message = json.errors[0].details;
reportFetchError: function (error_message) {
$j('div#fetch-error-message').text("An error occurred fetching the terms: " + error_message);
$j('div#fetch-error-message').show();
},
Expand All @@ -135,23 +118,6 @@ CVTerms = {
}
});
},
disableAddTermButton: function(reason) {
$j('a#add-term').attr('disabled', true);
if (!$j('a#add-term').parent().is('span')) {
let span = $j('a#add-term').wrap('<span />').parent();
$j(span).attr('data-tooltip', reason);
bindTooltips('div#controlled-vocab-terms');
$j(span).click(function () {
alert(reason);
});
}
},
enableAddTermButton: function() {
let button = $j('a#add-term');
button.attr('disabled',false);
button.removeClass('disabled');
button.unwrap('span');
},
// sets up and trigger the ajax call to fetch the terms list
fetchTermsAJAX: function () {
$j('div#controlled-vocab-terms').hide();
Expand All @@ -161,19 +127,19 @@ CVTerms = {
$j('input#fetch-ontology-terms-submit').prop('disabled', true);

$j.ajax({
url: '<%= fetch_ols_terms_sample_controlled_vocabs_path %>',
dataType: "json",
url: '<%= fetch_ols_terms_html_sample_controlled_vocabs_path %>',
dataType: "html",
data: {
source_ontology_id: $j('select#sample_controlled_vocab_source_ontology').val(),
root_uri: $j('#sample_controlled_vocab_ols_root_term_uri').val(),
include_root_term: $j('#include_root_term:checked').val()
},
success: function (resp) {
CVTerms.clearAllTerms();
CVTerms.handleOntologyTermsJSONResponse((resp));
CVTerms.handleOntologyTermsHTMLResponse(resp);
},
error: function (resp) {
CVTerms.reportFetchError(resp.responseJSON);
CVTerms.reportFetchError(resp.responseText);
},
complete: function () {
$j('#fetch-terms-spinner').spinner('remove');
Expand Down Expand Up @@ -209,10 +175,8 @@ CVTerms = {
if (selected.value == "") {
$j('#sample_controlled_vocab_ols_root_term_uri').val('');
$j('#ontology-root-uri').hide();
CVTerms.enableAddTermButton();
} else {
$j('#ontology-root-uri').show();
CVTerms.disableAddTermButton('<%= I18n.t('controlled_vocabs.add_new_term_disabled_reason') %>');
var link = $j('a#selected-ols-link');
link.text(selected.text);
link.attr('href', '<%= Ebi::OlsClient::ROOT_URL %>/ontologies/' + selected.value);
Expand Down
Loading

0 comments on commit f99c3e9

Please sign in to comment.