From 5725ebf096782ee3e1d441fe60742001a8177f49 Mon Sep 17 00:00:00 2001 From: SirineMhedhbi <31127782+SirineMhedhbi@users.noreply.github.com> Date: Sun, 6 Aug 2023 22:58:23 +0200 Subject: [PATCH] Fix: Bug missing roots display (#311) * remove dead code * return the first concept if there is no roots * return AlertMessageComponent if skos and empty roots * revert removing missing class error in get_class helper --------- Co-authored-by: Syphax Bouazzouni --- app/controllers/application_controller.rb | 25 +++++++++++-------- app/controllers/ontologies_controller.rb | 2 -- .../_concepts_tree.html.haml | 9 +++++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fcc9e9845..9559dc190 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -452,13 +452,15 @@ def get_class(params) if ignore_concept_param # get the top level nodes for the root # TODO_REV: Support views? Replace old view call: @ontology.top_level_classes(view) - roots = @ontology.explore.roots(concept_schemes: params[:concept_schemes]) - if roots.nil? || roots.empty? - LOG.add :debug, "Missing roots for #{@ontology.acronym}" - not_found("Missing roots for #{@ontology.acronym}") + @roots = @ontology.explore.roots(concept_schemes: params[:concept_schemes]) + if @roots.nil? || @roots.empty? + LOG.add :debug, "Missing @roots for #{@ontology.acronym}" + @concept = @ontology.explore.classes.collection.first.explore.self(full: true) + return end + @root = LinkedData::Client::Models::Class.new(read_only: true) - @root.children = roots.sort{|x,y| (x.prefLabel || "").downcase <=> (y.prefLabel || "").downcase} + @root.children = @roots.sort{|x,y| (x.prefLabel || "").downcase <=> (y.prefLabel || "").downcase} # get the initial concept to display root_child = @root.children.first @@ -480,13 +482,14 @@ def get_class(params) # Create the tree rootNode = @concept.explore.tree(include: "prefLabel,hasChildren,obsolete", concept_schemes: params[:concept_schemes]) if rootNode.nil? || rootNode.empty? - roots = @ontology.explore.roots(concept_schemes: params[:concept_schemes]) - if roots.nil? || roots.empty? - LOG.add :debug, "Missing roots for #{@ontology.acronym}" - not_found("Missing roots for #{@ontology.acronym}") + @roots = @ontology.explore.roots(concept_schemes: params[:concept_schemes]) + if @roots.nil? || @roots.empty? + LOG.add :debug, "Missing @roots for #{@ontology.acronym}" + @concept = @ontology.explore.classes.collection.first.explore.self(full: true) + return end - if roots.any? {|c| c.id == @concept.id} - rootNode = roots + if @roots.any? {|c| c.id == @concept.id} + rootNode = @roots else rootNode = [@concept] end diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 12035ac7f..07fdfe451 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -174,8 +174,6 @@ def classes @notes = @concept.explore.notes end - update_tab(@ontology, @concept.id) - if request.xhr? render 'ontologies/sections/visualize', layout: false else diff --git a/app/views/ontologies/concepts_browsers/_concepts_tree.html.haml b/app/views/ontologies/concepts_browsers/_concepts_tree.html.haml index 9e0460185..ba96119b0 100644 --- a/app/views/ontologies/concepts_browsers/_concepts_tree.html.haml +++ b/app/views/ontologies/concepts_browsers/_concepts_tree.html.haml @@ -16,6 +16,11 @@ 'chosen-enable-colors-value': 'true'}} -# Class tree %div#sd_content.card.p-1.py-3{style: 'overflow-y: scroll; height: 60vh;'} - = render TurboFrameComponent.new(id: 'concepts_tree_view', + - if skos? && @roots.empty? + %div.text-wrap + = render AlertMessageComponent.new do + Missing roots for #{@ontology.acronym} + - else + = render TurboFrameComponent.new(id: 'concepts_tree_view', src: "/ajax/classes/treeview?ontology=#{@ontology.acronym}&conceptid=#{escape(@concept.id)}&concept_schemes=#{params[:concept_schemes]}&auto_click=false", - data: {'turbo-frame-target': 'frame'}) \ No newline at end of file + data: {'turbo-frame-target': 'frame'}) \ No newline at end of file