diff --git a/app/components/tree_link_component.rb b/app/components/tree_link_component.rb
index 73da902f2..fd23706d9 100644
--- a/app/components/tree_link_component.rb
+++ b/app/components/tree_link_component.rb
@@ -2,26 +2,19 @@
class TreeLinkComponent < ViewComponent::Base
include MultiLanguagesHelper, ModalHelper, ApplicationHelper
- def initialize(child:, href:, children_href: , selected: false , data: {}, muted: false, target_frame: nil, open_in_modal: false, is_reused: nil)
+
+ def initialize(child:, href:, children_href:, selected: false, data: {}, muted: false, target_frame: nil, open_in_modal: false, is_reused: nil)
+ super
+
@child = child
@active_style = selected ? 'active' : ''
- #@icons = child.relation_icon(node)
@muted_style = muted ? 'text-muted' : ''
@href = href
@children_link = children_href
- label = (@child.prefLabel || @child.label) rescue @child.id
- if label.nil?
- @pref_label_html = link_last_part(child.id)
- else
- pref_label_lang, @pref_label_html = select_language_label(label)
- pref_label_lang = pref_label_lang.to_s.upcase
- @tooltip = pref_label_lang.eql?("@NONE") ? "" : pref_label_lang
- if child.obsolete?
- @pref_label_html = "#{@pref_label_html}".html_safe
- end
- end
- @data ||= { controller: 'tooltip', 'tooltip-position-value': 'right', turbo: true, 'turbo-frame': target_frame, action: 'click->simple-tree#select'}
+ @pref_label_html, @tooltip = node_label(child)
+
+ @data ||= { controller: 'tooltip', 'tooltip-position-value': 'right', turbo: true, 'turbo-frame': target_frame, action: 'click->simple-tree#select' }
@data.merge!(data) do |_, old, new|
"#{old} #{new}"
@@ -32,7 +25,6 @@ def initialize(child:, href:, children_href: , selected: false , data: {}, muted
@is_reused = is_reused
end
-
# This gives a very hacky short code to use to uniquely represent a class
# based on its parent in a tree. Used for unique ids in HTML for the tree view
def short_uuid
@@ -49,7 +41,7 @@ def open?
end
def border_left
- !@child.hasChildren ? 'pl-3 tree-border-left' : ''
+ !@child.hasChildren ? 'pl-3 tree-border-left' : ''
end
def li_id
@@ -75,4 +67,26 @@ def open_children_link
end
+ private
+
+ def node_label(child)
+ label = begin
+ child.prefLabel || child.label
+ rescue
+ child.id
+ end
+
+ if label.nil?
+ pref_label_html = link_last_part(child.id)
+ else
+ pref_label_lang, pref_label_html = select_language_label(label)
+ pref_label_lang = pref_label_lang.to_s.upcase
+ tooltip = pref_label_lang.eql?("@NONE") ? "" : pref_label_lang
+
+ pref_label_html = "#{pref_label_html}".html_safe if child.obsolete?
+ end
+
+ [pref_label_html, tooltip]
+ end
+
end
diff --git a/app/helpers/multi_languages_helper.rb b/app/helpers/multi_languages_helper.rb
index 9e21f2e0e..6e127b94e 100644
--- a/app/helpers/multi_languages_helper.rb
+++ b/app/helpers/multi_languages_helper.rb
@@ -153,7 +153,7 @@ def select_language_label(concept_label, platform_languages = %i[en fr])
end
end
- concept_value || concept.to_a.first
+ concept_value || concept.reject { |k| k.to_s.eql?('@none') }.first || concept.first
end
def main_language_label(label)