Skip to content

Commit

Permalink
allow new terms to be added after populating a CV from OLS #1653
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Nov 10, 2023
1 parent f6bdffd commit 769acca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
19 changes: 0 additions & 19 deletions app/assets/javascripts/controlled_vocabs.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,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 Down Expand Up @@ -209,10 +192,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
6 changes: 1 addition & 5 deletions app/views/sample_controlled_vocabs/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@
</table>
</div>
<div>
<%
options = {id: 'add-term'}
options.merge!({disabled:true, disabled_reason:t('controlled_vocabs.add_new_term_disabled_reason')}) if @sample_controlled_vocab.ontology_based?
%>
<%= button_link_to('Add new term', 'add', '#', options) %>
<%= button_link_to('Add new term', 'add', '#', id: 'add-term') %>
<%= button_link_to('Remove all terms', 'destroy', '#', :id => 'clear-terms', class:'btn btn-danger') %>
</div>
</div>
Expand Down

0 comments on commit 769acca

Please sign in to comment.