diff --git a/app/controllers/concepts_controller.rb b/app/controllers/concepts_controller.rb index f0405b926..ba0192508 100644 --- a/app/controllers/concepts_controller.rb +++ b/app/controllers/concepts_controller.rb @@ -58,7 +58,7 @@ def index render turbo_stream: [ replace(helpers.child_id(@concept) + '_open_link') { TreeLinkComponent.tree_close_icon }, replace(helpers.child_id(@concept) + '_childs') do - helpers.concepts_tree_component(@concept, @concept, @ontology.acronym, Array(@schemes), request_lang, sub_tree: true, ontology_uri_pattern: @submission) + helpers.concepts_tree_component(@concept, @concept, @ontology.acronym, Array(@schemes), request_lang, sub_tree: true, submission: @submission) end ] end @@ -88,7 +88,7 @@ def show_tree render inline: helpers.concepts_tree_component(@root, @concept, @ontology.acronym, Array(params[:concept_schemes]&.split(',')), request_lang, - id: 'concepts_tree_view', auto_click: params[:auto_click] || true, ontology_uri_pattern: @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')) + id: 'concepts_tree_view', auto_click: params[:auto_click] || true, submission: @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')) end end diff --git a/app/controllers/concerns/terms_reuses.rb b/app/controllers/concerns/terms_reuses.rb index 7366c6dec..98e7b6ea1 100644 --- a/app/controllers/concerns/terms_reuses.rb +++ b/app/controllers/concerns/terms_reuses.rb @@ -5,11 +5,11 @@ def get_submission_uri_pattern_by_id(acronym: nil) LinkedData::Client::HTTP.get("ontologies/#{acronym}/latest_submission", {display: 'uriRegexPattern,preferredNamespaceUri'}) end - def concept_reused?(ontology_uri_pattern: nil, concept_id: nil) - if ontology_uri_pattern&.uriRegexPattern - is_reused = !(concept_id =~ Regexp.new(ontology_uri_pattern.uriRegexPattern)) - elsif ontology_uri_pattern&.preferredNamespaceUri - is_reused = !(concept_id.include?(ontology_uri_pattern.preferredNamespaceUri)) + def concept_reused?(submission: nil, concept_id: nil) + if submission&.uriRegexPattern + is_reused = !(concept_id =~ Regexp.new(submission.uriRegexPattern)) + elsif submission&.preferredNamespaceUri + is_reused = !(concept_id.include?(submission.preferredNamespaceUri)) end return is_reused end diff --git a/app/controllers/instances_controller.rb b/app/controllers/instances_controller.rb index 98ff3efc6..63750f1dd 100644 --- a/app/controllers/instances_controller.rb +++ b/app/controllers/instances_controller.rb @@ -26,7 +26,7 @@ def index child_param: :instanceid, show_count: is_concept_instance, auto_click: params[:instanceid].blank? && page.eql?(1), - results: results, next_page: next_page, total_count: total_count, ontology_uri_pattern: @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')) + results: results, next_page: next_page, total_count: total_count, submission: @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')) if is_concept_instance && page.eql?(1) render turbo_stream: view diff --git a/app/controllers/properties_controller.rb b/app/controllers/properties_controller.rb index 32c25166e..f9626a15d 100644 --- a/app/controllers/properties_controller.rb +++ b/app/controllers/properties_controller.rb @@ -46,7 +46,7 @@ def show_children render turbo_stream: [ replace(helpers.child_id(@property) + '_open_link') { TreeLinkComponent.tree_close_icon }, replace(helpers.child_id(@property) + '_childs') do - helpers.property_tree_component(@property, @property, acronym, request_lang, sub_tree: true, ontology_uri_pattern: get_submission_uri_pattern_by_id(acronym: acronym)) + helpers.property_tree_component(@property, @property, acronym, request_lang, sub_tree: true, submission: get_submission_uri_pattern_by_id(acronym: acronym)) end ] end @@ -86,7 +86,7 @@ def index_tree(container_id) end render inline: helpers.property_tree_component(@root, @property, @ontology.acronym, request_lang, - id: container_id, auto_click: true, ontology_uri_pattern: @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')) + id: container_id, auto_click: true, submission: @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')) end end diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb index dcde976f8..210e4ab57 100644 --- a/app/helpers/components_helper.rb +++ b/app/helpers/components_helper.rb @@ -47,7 +47,7 @@ def search_page_input_component(name:, value: nil, placeholder: , button_icon: ' end end - def paginated_list_component(id:, results:, next_page_url:, child_url:, child_turbo_frame:, child_param:, open_in_modal: false , selected: nil, auto_click: false, ontology_uri_pattern: nil) + def paginated_list_component(id:, results:, next_page_url:, child_url:, child_turbo_frame:, child_param:, open_in_modal: false , selected: nil, auto_click: false, submission: nil) render(TreeInfiniteScrollComponent.new( id: id, collection: results.collection, @@ -78,7 +78,7 @@ def paginated_list_component(id:, results:, next_page_url:, child_url:, child_tu target_frame: child_turbo_frame, data: data, open_in_modal: open_in_modal, - is_reused: concept_reused?(ontology_uri_pattern: ontology_uri_pattern, concept_id: concept.id) + is_reused: concept_reused?(submission: submission, concept_id: concept.id) ))) end end @@ -134,7 +134,7 @@ def link_to_with_actions(link_to_tag, acronym: nil, url: nil, copy: true, check_ tag.html_safe end - def tree_component(root, selected, target_frame:, sub_tree: false, id: nil, auto_click: false, ontology_uri_pattern: nil, &child_data_generator) + def tree_component(root, selected, target_frame:, sub_tree: false, id: nil, auto_click: false, submission: nil, &child_data_generator) root.children.sort! { |a, b| (a.prefLabel || a.id).downcase <=> (b.prefLabel || b.id).downcase } render TreeViewComponent.new(id: id, sub_tree: sub_tree, auto_click: auto_click) do |tree_child| @@ -149,9 +149,9 @@ def tree_component(root, selected, target_frame:, sub_tree: false, id: nil, auto children_href: children_link, selected: child.id.eql?(selected&.id), muted: child.isInActiveScheme&.empty?, target_frame: target_frame, - data: data, is_reused: concept_reused?(ontology_uri_pattern: ontology_uri_pattern, concept_id: child.id)) do + data: data, is_reused: concept_reused?(submission: submission, concept_id: child.id)) do tree_component(child, selected, target_frame: target_frame, sub_tree: true, - id: id, auto_click: auto_click, ontology_uri_pattern: ontology_uri_pattern, &child_data_generator) + id: id, auto_click: auto_click, submission: submission, &child_data_generator) end end end diff --git a/app/helpers/concepts_helper.rb b/app/helpers/concepts_helper.rb index 7f9b9566e..5851088f6 100644 --- a/app/helpers/concepts_helper.rb +++ b/app/helpers/concepts_helper.rb @@ -20,8 +20,8 @@ def concept_tree_data(acronym, child, language, concept_schemes) } [children_link, data, href] end - def concepts_tree_component(root, selected_concept, acronym, concept_schemes, language, sub_tree: false, id: nil, auto_click: false, ontology_uri_pattern: nil) - tree_component(root, selected_concept, target_frame: 'concept_show', sub_tree: sub_tree, id: id, auto_click: auto_click, ontology_uri_pattern: ontology_uri_pattern) do |child| + def concepts_tree_component(root, selected_concept, acronym, concept_schemes, language, sub_tree: false, id: nil, auto_click: false, submission: nil) + tree_component(root, selected_concept, target_frame: 'concept_show', sub_tree: sub_tree, id: id, auto_click: auto_click, submission: submission) do |child| concept_tree_data(acronym, child, language, concept_schemes) end end @@ -105,14 +105,14 @@ def same_period?(year, month, date) year.eql?(date.year) && month.eql?(date.strftime('%B')) end - def concepts_li_list(concepts, auto_click: false, selected_id: nil, ontology_uri_pattern: nil) + def concepts_li_list(concepts, auto_click: false, selected_id: nil, submission: nil) out = '' concepts.each do |concept| children_link, data, href = concept_tree_data(@ontology.acronym, concept, request_lang, []) out += render TreeLinkComponent.new(child: concept, href: href, children_href: '#', selected: concept.id.eql?(selected_id) && auto_click, - target_frame: 'concept_show', data: data, is_reused: concept_reused?(ontology_uri_pattern: ontology_uri_pattern, concept_id: concept.id)) + target_frame: 'concept_show', data: data, is_reused: concept_reused?(submission: submission, concept_id: concept.id)) end out end @@ -124,7 +124,7 @@ def render_concepts_by_dates(auto_click: false) first_month, first_concepts = first_month_concepts.shift out = '' if same_period?(first_year, first_month, @last_date) - out += "" + out += "" else tmp = {} tmp[first_month] = first_concepts @@ -137,7 +137,7 @@ def render_concepts_by_dates(auto_click: false) @concepts_year_month.each do |year, month_concepts| month_concepts.each do |month, concepts| out += "" end end diff --git a/app/helpers/properties_helper.rb b/app/helpers/properties_helper.rb index 0304ce706..8f77493a8 100644 --- a/app/helpers/properties_helper.rb +++ b/app/helpers/properties_helper.rb @@ -17,8 +17,8 @@ def property_tree_data(acronym, child, language) } [children_link, data, href] end - def property_tree_component(root, selected_concept, acronym, language, sub_tree: false, id: nil, auto_click: false, ontology_uri_pattern: nil) - tree_component(root, selected_concept, target_frame: 'property_show', sub_tree: sub_tree, id: id, auto_click: auto_click, ontology_uri_pattern: ontology_uri_pattern) do |child| + def property_tree_component(root, selected_concept, acronym, language, sub_tree: false, id: nil, auto_click: false, submission: nil) + tree_component(root, selected_concept, target_frame: 'property_show', sub_tree: sub_tree, id: id, auto_click: auto_click, submission: submission) do |child| property_tree_data(acronym, child, language) end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 1dd1ffbed..b5b673ef9 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -8,7 +8,7 @@ def search_content_params def render_search_paginated_list(container_id:, next_page_url:, child_url:, child_turbo_frame:, child_param:, show_count: nil, lang: request_lang, - auto_click: false, results: , next_page: ,total_count:, ontology_uri_pattern: nil ) + auto_click: false, results: , next_page: ,total_count:, submission: nil ) query, page, _ = search_content_params @results = OpenStruct.new @@ -45,7 +45,7 @@ def render_search_paginated_list(container_id:, next_page_url:, child_url:, chil child_turbo_frame: child_turbo_frame, open_in_modal: show_count, selected: selected, - auto_click: auto_click, ontology_uri_pattern: ontology_uri_pattern) + auto_click: auto_click, submission: submission) end end end \ No newline at end of file