Skip to content

Commit

Permalink
Fix bug of select list view of ontology (#289)
Browse files Browse the repository at this point in the history
* Add Chosen.js functionality to fix bug of select views of ontolgy

* Add Chosen.js functionality for list views ontologies

* fix bug of update ontology where there is no view

* Refactor code

* Delete ponse = @ontology.update
  • Loading branch information
SirineMhedhbi authored and Bilelkihal committed Aug 1, 2023
1 parent 904b1c7 commit 6f4f874
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ def update
# Note: find_by_acronym includes ontology views
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology][:acronym] || params[:id]).first
@ontology.update_from_params(ontology_params)
@ontology.viewOf = nil if @ontology.isView.eql? "0"
error_response = @ontology.update
if response_error?(error_response)
@categories = LinkedData::Client::Models::Category.all
Expand Down
13 changes: 11 additions & 2 deletions app/views/shared/_ontology_picker_single.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@
<%disabled ||= nil%>

<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#<%=picker_id%>").chosen({search_contains: true});
jQuery(document).ready(function() {
jQuery("#<%= picker_id %>").chosen({ search_contains: true });

jQuery("#ontology_isView").change(function() {
if (this.checked) {
jQuery("#ontology_viewOf").prop("disabled", false).trigger("chosen:updated");
} else {
jQuery("#ontology_viewOf").val('').trigger("chosen:updated");
jQuery("#ontology_viewOf").prop("disabled", true).trigger("chosen:updated");
}
});
});
</script>

Expand Down

0 comments on commit 6f4f874

Please sign in to comment.