").attr("id", "proposal_buttons").append(requestTermButtons()));
- container.append(requestTermForm);
-
- requestTermForm.submit(function(e) {
- e.preventDefault(e);
- bindRequestTermSaveClick();
- return false;
- });
-
- return requestTermForm;
-}
-
-function obTriggerNewTermRequestFormSave() {
- var ont = jQuery(document).data().bp.ontology;
- var ob_onts = jQuery(document).data().bp.ontolobridge_ontologies;
-
- // Execute only if ontology is Ontolobridge-enabled
- if (Object.entries(ont).length > 0 && ob_onts && ob_onts.length > 0 && ob_onts.includes(ont["acronym"])) {
- var formName = 'request_term_form';
-
- jQuery("#" + formName + " input, #" + formName + " textarea").each(function() {
- var input = jQuery(this);
- var val = input.val().trim();
-
- if (input.attr('type') === "checkbox" && input.prop('checked') === true) {
- window.localStorage.setItem(formName + '_' + input.attr('name'), 'checkbox_checked');
- window.localStorage.setItem(formName + '_populated', true);
- } else if (input.attr('type') !== "hidden" && input.attr('type') !== "checkbox" && val) {
- window.localStorage.setItem(formName + '_' + input.attr('name'), val);
- window.localStorage.setItem(formName + '_populated', true);
- }
- });
- }
-}
-
-jQuery(document).ready(function() {
- clearStatusMessages();
- bindAddRequestTermClick();
- bindCancelRequestTermClick();
- preventNewTermInstructionsFormSubmit();
- bindNewTermInstructionsSubmit();
- bindNewTermInstructionsCancel();
- bindNewTermInstructionsClick();
-});
diff --git a/app/assets/stylesheets/application.css.scss.erb b/app/assets/stylesheets/application.css.scss.erb
index 59a73166f2..2b521539f4 100755
--- a/app/assets/stylesheets/application.css.scss.erb
+++ b/app/assets/stylesheets/application.css.scss.erb
@@ -32,7 +32,6 @@
@import "recommender";
@import "search";
@import "submissions";
-@import "ontolobridge";
@import "fair_assement";
@import "instances_table";
@import "register";
diff --git a/app/assets/stylesheets/browse.scss b/app/assets/stylesheets/browse.scss
index a55292bde0..57e857442c 100644
--- a/app/assets/stylesheets/browse.scss
+++ b/app/assets/stylesheets/browse.scss
@@ -266,6 +266,9 @@
z-index: 1;
}
+.browse-filter .switch-filter > p, .switch-filter > div{
+ max-width: 207px;
+}
.browse-search-bar input:focus {
box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
diff --git a/app/assets/stylesheets/home.scss b/app/assets/stylesheets/home.scss
index 9965d2bfd5..875138bdd7 100644
--- a/app/assets/stylesheets/home.scss
+++ b/app/assets/stylesheets/home.scss
@@ -222,7 +222,7 @@ i.fa.fa-caret-square-o-down {
.home-statistics-container > div {
display: flex;
align-items: start;
- justify-content: center;
+ justify-content: flex-start;
flex-wrap: wrap;
}
.home-agroportal-figures{
diff --git a/app/assets/stylesheets/mappings.scss b/app/assets/stylesheets/mappings.scss
index 89a7ebffbe..20ddbb6940 100644
--- a/app/assets/stylesheets/mappings.scss
+++ b/app/assets/stylesheets/mappings.scss
@@ -320,6 +320,28 @@ div#map_from_concept_details_table, div#map_to_concept_details_table {
#concept_mappings_table {
width: 100%;
+ word-break: break-word;
+ font-size: 13px;
+}
+.mappings-table-mapping-to{
+ width: 45%;
+}
+.mappings-table-mapping-to .chip-button-component-container{
+ text-wrap: wrap !important;
+}
+.mappings-table-mapping-to a{
+ background-color: unset;
+ line-height: unset;
+ padding: unset;
+ font-weight: unset;
+ font-size: unset;
+}
+.mappings-table-icon{
+ width: 18px;
+ height: 18px;
+}
+.mappings-table-icon path{
+ fill: var(--gray-color);
}
.summary-mappings-tab-table {
@@ -341,4 +363,7 @@ div#map_from_concept_details_table, div#map_to_concept_details_table {
padding: 10px;
outline: none;
margin-left: 0 !important;
+}
+.mappings-table-actions svg path{
+ fill: var(--primary-color);
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/ontolobridge.scss b/app/assets/stylesheets/ontolobridge.scss
deleted file mode 100644
index ebcc8e9426..0000000000
--- a/app/assets/stylesheets/ontolobridge.scss
+++ /dev/null
@@ -1,35 +0,0 @@
-/* message boxes */
-.message-box {
- color: #555;
- border-radius: 3px;
- font-family: Tahoma, Geneva, Arial, sans-serif;
- font-size: 11px;
- padding: 10px;
- margin: 10px 0 0 0;
-}
-
-.message-box span {
- font-weight: bold;
- text-transform: uppercase;
-}
-
-.error-msg {
- //background-color: #eee;
- border: 1px solid #f5aca6;
-}
-
-.success-msg {
- //background-color: #eee;
- border: 1px solid #a6ca8a;
-}
-
-input.req,
-textarea.req {
- border-color: darksalmon !important;
-}
-
-blockquote {
- padding: 0 1em;
- color: #6a737d;
- border-left: .25em solid #dfe2e5;
-}
diff --git a/app/assets/stylesheets/ontologies.scss b/app/assets/stylesheets/ontologies.scss
index ccaf70d314..3b71432d37 100644
--- a/app/assets/stylesheets/ontologies.scss
+++ b/app/assets/stylesheets/ontologies.scss
@@ -2,6 +2,7 @@ $ont-metadata-bg-color: #e2ebf0;
$widget-table-border-color: #EFEFEF;
+
.admin-background{
a.chip_button_container_clickable{
color: var(--admin-color) !important;
@@ -314,4 +315,4 @@ $widget-table-border-color: #EFEFEF;
color: white;
border-radius: 10px;
position: relative;
-}
\ No newline at end of file
+}
diff --git a/app/assets/stylesheets/taxonomy.scss b/app/assets/stylesheets/taxonomy.scss
index 6043973aa8..bf5c679ff5 100644
--- a/app/assets/stylesheets/taxonomy.scss
+++ b/app/assets/stylesheets/taxonomy.scss
@@ -63,7 +63,18 @@
}
.taxonomy-card .description{
color: #666666;
- padding-bottom: 5px;
+}
+
+.taxonomy-card .descriptionlink svg{
+ margin: 0px 2px;
+ height: 19px;
+}
+
+.taxonomy-card .descriptionlink svg path{
+ fill: #666666;
+}
+.category-link{
+ color: #666666 !important;
}
.taxonomy-slice-svg{
width: 35px;
diff --git a/app/components/chip_button_component/chip_button_component.html.haml b/app/components/chip_button_component/chip_button_component.html.haml
index 26172a5487..f2dd0d3dd0 100644
--- a/app/components/chip_button_component/chip_button_component.html.haml
+++ b/app/components/chip_button_component/chip_button_component.html.haml
@@ -4,7 +4,7 @@
= @text || content
- elsif !content
%a.chip_button_container_clickable{@html_options}
- = @text
+ = @text.html_safe
- else
%span.chip_button_container_clickable{@html_options}
= content
diff --git a/app/components/display/taxonomy_card_component.rb b/app/components/display/taxonomy_card_component.rb
index df896191b6..89b05bcb69 100644
--- a/app/components/display/taxonomy_card_component.rb
+++ b/app/components/display/taxonomy_card_component.rb
@@ -1,4 +1,5 @@
class Display::TaxonomyCardComponent < ViewComponent::Base
+ include UrlsHelper
def initialize(taxonomy: , ontologies_names: )
@taxonomy = taxonomy
@ontologies_names = ontologies_names
diff --git a/app/components/display/taxonomy_card_component/taxonomy_card_component.html.haml b/app/components/display/taxonomy_card_component/taxonomy_card_component.html.haml
index ab55aa41de..218eaca749 100644
--- a/app/components/display/taxonomy_card_component/taxonomy_card_component.html.haml
+++ b/app/components/display/taxonomy_card_component/taxonomy_card_component.html.haml
@@ -4,12 +4,22 @@
= "#{@taxonomy.name} (#{@taxonomy.acronym})"
%a{href: "https://#{@taxonomy.acronym}.#{$UI_URL.sub("https://", "")}"}
= inline_svg_tag('icons/slices.svg', class: "taxonomy-slice-svg #{@taxonomy.is_slice ? '' : 'd-none'}")
+
+ - if link?(@taxonomy.description)
+ .descriptionlink
+ %a.category-link{href: @taxonomy.description, target: '_blank'}
+ = @taxonomy.description
+ = inline_svg_tag 'icons/external-link.svg'
+
%a.ontologies{href: "/ontologies?#{@taxonomy.id.split('/')[-2]}=#{@taxonomy.acronym}"}
= inline_svg_tag('icons/ontology.svg')
.number-of-ontologies
= "#{@taxonomy.ontologies.length} ontologies"
- .description
- = render TextAreaFieldComponent.new(value: @taxonomy.description)
+
+ - unless link?(@taxonomy.description)
+ .description.mb-1
+ = render TextAreaFieldComponent.new(value: @taxonomy.description)
+
.ontologies-cards
- @taxonomy.ontologies.each_with_index do |ontology, index|
- if index>10
diff --git a/app/components/label_fetcher_component.rb b/app/components/label_fetcher_component.rb
new file mode 100644
index 0000000000..f89f39d16e
--- /dev/null
+++ b/app/components/label_fetcher_component.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+class LabelFetcherComponent < ViewComponent::Base
+ include UrlsHelper, Turbo::FramesHelper, ModalHelper
+
+ def initialize(id:, label: nil, link: nil, ajax_src: nil, open_in_modal: false, target: nil, external: false)
+ super
+ @id = id
+ @link = link
+ @ajax_src = ajax_src
+ @open_in_modal = open_in_modal
+ @target = target
+ @external = external
+ @label = label
+
+ if external_link?
+ @link = id
+ @target ||= '_blank'
+ else
+ @target ||= '_top'
+ end
+
+ end
+
+ def external_link?
+ (@label.nil? || @label.eql?(@id)) && @external
+ end
+
+ def label_fetcher_container(&block)
+ id = "#{escape(@id)}_label"
+ if @ajax_src
+ render(TurboFrameComponent.new(id: id, src: "#{@ajax_src}&target=#{@target}", loading: 'lazy')) do |t|
+ t.loader do
+ render ChipButtonComponent.new(url: @id, text: "#{@id} #{render(LoaderComponent.new(small: true))}", type: 'clickable', target: '_blank')
+ end
+
+ t.error do
+ capture(&block)
+ end
+ end
+ else
+ turbo_frame_tag(id) do
+ capture(&block)
+ end
+ end
+
+ end
+
+ def link_with_icon
+ if external_link?
+ ExternalLinkTextComponent.new(text: @label).call
+ else
+ InternalLinkTextComponent.new(text: @label).call
+ end
+ end
+end
diff --git a/app/components/label_fetcher_component/label_fetcher_component.html.haml b/app/components/label_fetcher_component/label_fetcher_component.html.haml
new file mode 100644
index 0000000000..80587133d1
--- /dev/null
+++ b/app/components/label_fetcher_component/label_fetcher_component.html.haml
@@ -0,0 +1,10 @@
+= label_fetcher_container do
+ - if @open_in_modal
+ = render ChipButtonComponent.new(type: 'clickable') do
+ = link_to_modal(@label, @link)
+ - else
+ %span
+ = render ChipButtonComponent.new(url: @link,
+ type: 'clickable',
+ text: link_with_icon,
+ target: @target)
diff --git a/app/components/label_link_component.rb b/app/components/label_link_component.rb
deleted file mode 100644
index 3d8ecee988..0000000000
--- a/app/components/label_link_component.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-class LabelLinkComponent < ViewComponent::Base
-
- def initialize(id:, text:, icon: 'popup-link')
- @id = id
- @text = text
- @icon = icon
- end
-
- def call
- if @id.eql?(@text)
- ExternalLinkTextComponent.new(text: @text).call
- else
- InternalLinkTextComponent.new(text: @text).call
- end
- end
-
- def self.inline(id, text)
- { plain: LabelLinkComponent.new(id: id, text: text).call }
- end
-end
diff --git a/app/components/link_text_component.rb b/app/components/link_text_component.rb
index 47ea0f6dfc..36dc79ba33 100644
--- a/app/components/link_text_component.rb
+++ b/app/components/link_text_component.rb
@@ -10,7 +10,7 @@ def initialize(text:, icon: nil, target: nil)
end
def call
- svg_icon = !@icon&.empty? ? inline_svg(@icon) : ''
+ svg_icon = !@icon&.empty? ? inline_svg(@icon, width: '14px', height: '14px') : ''
extra_span = @text == t('mappings.upload_mappings') ? '' : "
#{svg_icon}"
"#{@text}#{extra_span}".html_safe
end
diff --git a/app/components/tree_link_component.rb b/app/components/tree_link_component.rb
index 73da902f20..fd23706d96 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/components/turbo_frame_component.rb b/app/components/turbo_frame_component.rb
index d25322e154..1e54e24ce8 100644
--- a/app/components/turbo_frame_component.rb
+++ b/app/components/turbo_frame_component.rb
@@ -4,6 +4,7 @@ class TurboFrameComponent < ViewComponent::Base
include Turbo::FramesHelper
renders_one :loader
+ renders_one :error
def initialize(id:, src: '', **html_options)
@id = id
diff --git a/app/components/turbo_frame_component/turbo_frame_component.html.haml b/app/components/turbo_frame_component/turbo_frame_component.html.haml
index 1c5d0d9f59..a288d8eaca 100644
--- a/app/components/turbo_frame_component/turbo_frame_component.html.haml
+++ b/app/components/turbo_frame_component/turbo_frame_component.html.haml
@@ -8,5 +8,9 @@
- else
%div.p-3
= render LoaderComponent.new(type: 'pulsing')
- %div{'data-turbo-frame-error-target': 'errorMessage', style:'display: none; width: 100%'}
- = render Display::AlertComponent.new(type:'danger')
\ No newline at end of file
+ %span{'data-turbo-frame-error-target': 'errorMessage', style:'display: none; width: 100%'}
+ - if error?
+ = error
+ - else
+ %div
+ = render Display::AlertComponent.new(type:'danger')
diff --git a/app/controllers/agents_controller.rb b/app/controllers/agents_controller.rb
index c058eb130f..5c06c79a39 100644
--- a/app/controllers/agents_controller.rb
+++ b/app/controllers/agents_controller.rb
@@ -18,7 +18,7 @@ def show
end
def ajax_agents
- filters = { query: params[:query], qf: "identifiers_texts^20 acronym_text^15 name_text^10 email_text^10"}
+ filters = { query: "#{params[:query]}*", qf: "identifiers_texts^20 acronym_text^15 name_text^10 email_text^10"}
@agents = LinkedData::Client::HTTP.get('/search/agents', filters)
agents_json = @agents.collection.map do |x|
{
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 7af57ee341..1a8a3c8278 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -13,7 +13,7 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
- include InternationalisationHelper
+ include InternationalisationHelper, MultiLanguagesHelper
before_action :set_locale
@@ -26,6 +26,9 @@ def set_locale
I18n.locale = cookies[:locale] || detect_locale
cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil?
logger.debug "* Locale set to '#{I18n.locale}'"
+
+ I18n.locale = portal_lang if portal_language_enabled?(I18n.locale)
+
session[:locale] = I18n.locale
end
diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb
index c01c0cf879..699eda2698 100644
--- a/app/controllers/collections_controller.rb
+++ b/app/controllers/collections_controller.rb
@@ -1,7 +1,6 @@
class CollectionsController < ApplicationController
include CollectionsHelper,SearchContent
-
def index
acronym = params[:ontology]
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(acronym).first
@@ -47,21 +46,30 @@ def show
def show_label
collection_label = ''
- collection = get_request_collection
- collection_label = collection['prefLabel'] if collection
- collection_label = params[:id] if collection_label.nil? || collection_label.empty?
+ collection = get_request_collection
+ collection_label = collection['prefLabel'] if collection
+ collection_label = params[:id] if collection_label.nil? || collection_label.empty?
- render LabelLinkComponent.inline(params[:id], helpers.main_language_label(collection_label))
+ label = helpers.main_language_label(collection_label)
+ link = collection_path(collection_id: params[:id], ontology_id: params[:ontology_id], language: request_lang)
+ render(inline: helpers.ajax_link_chip(params[:id], label, link, external: collection.blank?), layout: false)
end
def show_members
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id] || params[:ontology]).first
- @submission = @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')
- @collection = get_request_collection
+ @submission = @ontology.explore.latest_submission(include: 'uriRegexPattern,preferredNamespaceUri')
page = params[:page] || '1'
@auto_click = page.to_s.eql?('1')
- @page = @collection.explore.members({page: page, language: request_lang})
- @concepts = @page.collection
+ @collection = get_request_collection(@ontology)
+
+ if @collection
+ @page = @collection.explore.members({ page: page, language: request_lang })
+ @concepts = @page.collection
+ else
+ @page = OpenStruct.new({ nextPage: 1, page: 1 })
+ @concepts = []
+ end
+
if @ontology.nil?
ontology_not_found params[:ontology]
else
@@ -71,14 +79,12 @@ def show_members
private
- def get_request_collection
+ def get_request_collection(ontology = nil)
params[:id] = request_collection_id
- if params[:id].nil? || params[:id].empty?
- render plain: t('collections.error_valid_collection')
- return
- end
- @ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id] || params[:ontology]).first
+ return nil if params[:id].nil? || params[:id].empty?
+
+ @ontology = ontology || LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id] || params[:ontology]).first
ontology_not_found(params[:ontology_id]) if @ontology.nil?
get_collection(@ontology, params[:id])
end
diff --git a/app/controllers/concepts_controller.rb b/app/controllers/concepts_controller.rb
index 196a61f97d..3d4923296f 100644
--- a/app/controllers/concepts_controller.rb
+++ b/app/controllers/concepts_controller.rb
@@ -23,7 +23,6 @@ def show
redirect_to(ontology_path(id: params[:ontology], p: 'classes', conceptid: params[:id], lang: request_lang)) and return unless turbo_frame_request?
@submission = get_ontology_submission_ready(@ontology)
- @ob_instructions = helpers.ontolobridge_instructions_template(@ontology)
@concept = @ontology.explore.single_class({full: true, language: request_lang}, params[:id])
@instances_concept_id = @concept.id
@@ -43,16 +42,16 @@ def index
# Note that find_by_acronym includes views by default
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology]).first
- @ob_instructions = helpers.ontolobridge_instructions_template(@ontology)
- @submission = @ontology.explore.latest_submission(include: 'all')
+ @submission = @ontology.explore.latest_submission(include:'uriRegexPattern,preferredNamespaceUri')
+
+ @concept = @ontology.explore.single_class({dispay: 'prefLabel'}, params[:id])
- @concept = @ontology.explore.single_class({full: true}, params[:id])
concept_not_found(params[:id]) if @concept.nil?
@schemes = params[:concept_schemes].split(',')
@concept.children = @concept.explore.children(pagesize: 750, concept_schemes: Array(@schemes).join(','), language: request_lang, display: 'prefLabel,obsolete,hasChildren').collection || []
- @concept.children.sort! { |x, y| (x.prefLabel || "").downcase <=> (y.prefLabel || "").downcase } unless @concept.children.empty?
+
render turbo_stream: [
replace(helpers.child_id(@concept) + '_open_link') { TreeLinkComponent.tree_close_icon },
replace(helpers.child_id(@concept) + '_childs') do
@@ -62,10 +61,18 @@ def index
end
def show_label
- cls_id = params[:concept] || params[:id] # cls_id should be a full URI
- ont_id = params[:ontology] # ont_id could be a full URI or an acronym
-
- render LabelLinkComponent.inline(cls_id, helpers.main_language_label(concept_label(ont_id, cls_id)))
+ cls_id = params[:concept] || params[:id]
+ ont_id = params[:ontology]
+ pref_label = begin
+ concept_label(ont_id, cls_id)
+ rescue
+ cls_id
+ end
+ cls = @ontology.explore&.single_class({ language: request_lang, include: 'prefLabel' }, cls_id)
+ label = helpers.main_language_label(pref_label)
+ link = concept_path(cls_id, ont_id, request_lang)
+
+ render(inline: helpers.ajax_link_chip(cls_id, label, link, external: cls.nil? || cls.errors), layout: nil)
end
def show_definition
@@ -86,8 +93,8 @@ def show_tree
not_found(t('concepts.missing_roots')) if @root.nil?
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.acronym, Array(params[:concept_schemes]&.split(',')), request_lang,
+ id: 'concepts_tree_view', auto_click: params[:auto_click] || true)
end
end
diff --git a/app/controllers/concerns/search_aggregator.rb b/app/controllers/concerns/search_aggregator.rb
index 078c89c5c9..f1f074272f 100644
--- a/app/controllers/concerns/search_aggregator.rb
+++ b/app/controllers/concerns/search_aggregator.rb
@@ -251,17 +251,15 @@ def blacklist_cls_id_components(cls_id, blacklist_words)
def merge_federated_results(search_results)
search_results.each do |element|
element[:root][:other_portals] = []
+
element[:reuses].reject! do |reuse|
- if (element[:root][:ontology_acronym] == reuse[:root][:ontology_acronym]) && (element[:root][:uri] == reuse[:root][:uri])
- portal_name = reuse[:root][:portal_name]
- link = reuse[:root][:link]
- element[:root][:other_portals] << {
- name: portal_name,
- color: federated_portal_color(portal_name),
- light_color: federated_portal_light_color(portal_name),
- link: link,
- ontology_id: reuse[:root][:ontology_id]
- }
+ element_ontology_id = element[:root][:ontology_id].split('/').last
+ element_uri = element[:root][:uri]
+ reuse_ontology_id = reuse[:root][:ontology_id].split('/').last
+ reuse_uri = reuse[:root][:uri]
+
+ if element_ontology_id == reuse_ontology_id && element_uri == reuse_uri
+ element[:root][:other_portals] << build_other_portal_entry(reuse)
true
else
false
@@ -270,6 +268,16 @@ def merge_federated_results(search_results)
end
end
+ def build_other_portal_entry(reuse)
+ {
+ name: reuse[:root][:portal_name],
+ color: federated_portal_color(reuse[:root][:portal_name]),
+ light_color: federated_portal_light_color(reuse[:root][:portal_name]),
+ link: reuse[:root][:link],
+ ontology_id: reuse[:root][:ontology_id]
+ }
+ end
+
def swap_canonical_portal_results_first(search_results)
all_submissions = LinkedData::Client::Models::OntologySubmission.all(include: 'pullLocation', include_views: true, display_links: false, display_context: false)
diff --git a/app/controllers/concerns/submission_filter.rb b/app/controllers/concerns/submission_filter.rb
index c039147280..5bb9937e1a 100644
--- a/app/controllers/concerns/submission_filter.rb
+++ b/app/controllers/concerns/submission_filter.rb
@@ -72,6 +72,7 @@ def merge_by_acronym(submissions)
submissions.group_by { |x| x[:ontology]&.acronym }.each do |acronym, ontologies|
ontology = canonical_ontology(ontologies)
ontology[:sources] = ontologies.map { |x| x[:id] }
+ ontology[:sources].reject! { |id| id.include?(portal_name.downcase) } if ontology[:sources].size.eql?(1)
merged_submissions << ontology
end
merged_submissions
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 2d20328b74..068d217b85 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -23,11 +23,20 @@ def index
@anal_ont_names = []
@anal_ont_numbers = []
- @analytics.sort_by{|ont, count| -count}[0..4].each do |ont, count|
- @anal_ont_names << ont
- @anal_ont_numbers << count
+ if @analytics.empty?
+ all_metrics = LinkedData::Client::Models::Metrics.all
+ all_metrics.sort_by{|x| -(x.classes + x.individuals)}[0..4].each do |x|
+ @anal_ont_names << x.id.split('/')[-4]
+ @anal_ont_numbers << (x.classes + x.individuals) || 0
+ end
+ else
+ @analytics.sort_by{|ont, count| -count}[0..4].each do |ont, count|
+ @anal_ont_names << ont
+ @anal_ont_numbers << count
+ end
end
+
end
def set_cookies
diff --git a/app/controllers/label_xl_controller.rb b/app/controllers/label_xl_controller.rb
index 521d35fb7a..e62a749084 100644
--- a/app/controllers/label_xl_controller.rb
+++ b/app/controllers/label_xl_controller.rb
@@ -1,5 +1,5 @@
class LabelXlController < ApplicationController
- include LabelXlHelper
+ include LabelXlHelper, UrlsHelper
def show
@label_xl = get_request_label_xl
@@ -9,8 +9,9 @@ def show_label
label_xl = get_request_label_xl
label_xl_label = label_xl ? label_xl['literalForm'] : nil
label_xl_label = params[:id] if label_xl_label.nil? || label_xl_label.empty?
-
- render LabelLinkComponent.inline(params[:id], helpers.main_language_label(label_xl_label))
+ label = helpers.main_language_label(label_xl_label)
+ link = "/ajax/label_xl/?id=#{escape(params[:id])}&ontology=#{params[:ontology_id]}&cls_id=#{escape(params[:cls_id])}"
+ render(inline: helpers.ajax_link_chip(params[:id], label, link, open_in_modal: true, external: label_xl.blank?), layout: false)
end
private
diff --git a/app/controllers/language_controller.rb b/app/controllers/language_controller.rb
index 0ccf6b59c5..56c647489a 100644
--- a/app/controllers/language_controller.rb
+++ b/app/controllers/language_controller.rb
@@ -1,11 +1,12 @@
class LanguageController < ApplicationController
+ include MultiLanguagesHelper
# set locale to the language selected by the user
def set_locale_language
language = params[:language].strip.downcase.to_sym
supported_languages = I18n.available_locales
-
- if language
+
+ if language && portal_language_enabled?(language)
if supported_languages.include?(language)
cookies.permanent[:locale] = language
else
diff --git a/app/controllers/mappings_controller.rb b/app/controllers/mappings_controller.rb
index b1bcfc8c32..0ca5fd8b77 100644
--- a/app/controllers/mappings_controller.rb
+++ b/app/controllers/mappings_controller.rb
@@ -118,7 +118,7 @@ def show_mappings
ontology_acronym = @ontology.acronym
@ontology_name = ontology_acronym
end
- if @target_ontology.nil?
+ if @target_ontology.nil? || @target_ontology.errors
if params[:target] == EXTERNAL_MAPPINGS_GRAPH
target_acronym = EXTERNAL_URL_PARAM_STR
@target_ontology_name = t('mappings.external_mappings')
@@ -132,7 +132,6 @@ def show_mappings
end
ontologies = [ontology_acronym, target_acronym]
-
@mapping_pages = LinkedData::Client::HTTP.get("#{MAPPINGS_URL}", { page: page, ontologies: ontologies.join(',') })
not_found(@mapping_pages.errors) if @mapping_pages.respond_to?(:errors)
@mappings = @mapping_pages.collection
@@ -342,4 +341,56 @@ def valid_values?(values)
end
errors
end
-end
\ No newline at end of file
+
+ def set_mapping_target(concept_to_id:, ontology_to:, mapping_type: )
+ case mapping_type
+ when 'interportal'
+ @map_to_interportal, @map_to_interportal_ontology = ontology_to.match(%r{(.*)/ontologies/(.*)}).to_a[1..]
+ @map_to_interportal_class = concept_to_id
+ when 'external'
+ @map_to_external_ontology = ontology_to
+ @map_to_external_class = concept_to_id
+ else
+ @map_to_bioportal_ontology_id = ontology_to
+ @map_to_bioportal_full_id = concept_to_id
+ end
+ end
+
+ def get_mappings_target_params
+ mapping_type = Array(params[:mapping_type]).first
+ external = true
+ case mapping_type
+ when 'interportal'
+ ontology_to = "#{params[:map_to_interportal]}/ontologies/#{params[:map_to_interportal_ontology]}"
+ concept_to_id = params[:map_to_interportal_class]
+ when 'external'
+ ontology_to = params[:map_to_external_ontology]
+ concept_to_id = params[:map_to_external_class]
+ else
+ ontology_to = params[:map_to_bioportal_ontology_id]
+ concept_to_id = params[:map_to_bioportal_full_id]
+ external = false
+ end
+ [ontology_to, concept_to_id, external]
+ end
+
+ def get_mappings_target
+ ontology_to, concept_to_id, external_mapping = get_mappings_target_params
+ target = ''
+ if external_mapping
+ target_ontology = ontology_to
+ target = concept_to_id
+ else
+ if helpers.link?(ontology_to)
+ target_ontology = LinkedData::Client::Models::Ontology.find(ontology_to)
+ else
+ target_ontology = LinkedData::Client::Models::Ontology.find_by_acronym(ontology_to).first
+ end
+ if target_ontology
+ target = target_ontology.explore.single_class(concept_to_id).id
+ target_ontology = target_ontology.id
+ end
+ end
+ [target_ontology, target, external_mapping]
+ end
+end
diff --git a/app/controllers/ontolobridge_controller.rb b/app/controllers/ontolobridge_controller.rb
deleted file mode 100644
index 89d3d62b6d..0000000000
--- a/app/controllers/ontolobridge_controller.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'rest-client'
-require 'multi_json'
-
-class OntolobridgeController < ApplicationController
-
- # POST /ontolobridge
- # POST /ontolobridge.xml
- def create
- request_term
- end
-
- def request_term
- response = {}
- endpoint = "/RequestTerm"
- h_params = {}
- response_raw = nil
- code = 200
-
- begin
- params.delete("controller")
- params.delete("action")
- params.each { |k, v|
- if v === "on"
- h_params[k] = true
- else
- h_params[k] = v
- end
- }
-
- headers = {'Authorization' => $ONTOLOBRIDGE_AUTHENTICATION_TOKEN}
- response_raw = RestClient.post("#{$ONTOLOBRIDGE_BASE_URL}#{endpoint}", h_params, headers)
- code = response_raw.code
- response.merge!(MultiJson.load(response_raw))
- rescue RestClient::BadRequest => e
- code = 400
- response["error"] = e.message
- rescue Exception => e
- code = 500
- response["error"] = t('ontolobridge.problem_of_creating_new_term', endpoint: endpoint, class: e.class, message: e.message)
- end
-
- render json: [response, code], status: code
- end
-
- def save_new_term_instructions
- code = 200
- response = {error: '', success: ''}
- response[:success] = t('ontolobridge.new_term_instructions_saved', acronym: params['acronym'])
- ont_data = Ontology.find_by(acronym: params['acronym'])
- ont_data ||= Ontology.new
- ont_data.acronym = params['acronym']
- ont_data.new_term_instructions = params['new_term_instructions']
-
- begin
- ont_data.save
- rescue Exception => e
- code = 500
- response[:error] = t('ontolobridge.error_saving_new_term_instructions', acronym: params['acronym'])
- end
- sleep(1)
- render json: [response, code], status: code
- end
-
-end
diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb
index 7e67bb7cb7..793a0f7a14 100644
--- a/app/controllers/ontologies_controller.rb
+++ b/app/controllers/ontologies_controller.rb
@@ -276,7 +276,6 @@ def show
params[:p] = "summary"
end
- #@ob_instructions = helpers.ontolobridge_instructions_template(@ontology)
# Get the latest submission (not necessarily the latest 'ready' submission)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 490072b4bd..5816730466 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -26,13 +26,13 @@ def show
redirect_to projects_path
return
end
-
+
@project = projects.first
@ontologies_used = []
onts_used = @project.ontologyUsed
onts_used.each do |ont_used|
ont = LinkedData::Client::Models::Ontology.find(ont_used)
- unless ont.nil?
+ unless ont.nil? || ont.errors
@ontologies_used << Hash["name", ont.name, "acronym", ont.acronym]
end
end
@@ -62,7 +62,7 @@ def edit
@project = projects.first
@user_select_list = LinkedData::Client::Models::User.all.map {|u| [u.username, u.id]}
@user_select_list.sort! {|a,b| a[1].downcase <=> b[1].downcase}
- @usedOntologies = @project.ontologyUsed || []
+ @usedOntologies = @project.ontologyUsed&.map{|o| o.split('/').last}
@ontologies = LinkedData::Client::Models::Ontology.all
end
@@ -76,7 +76,7 @@ def create
@project = LinkedData::Client::Models::Project.new(values: project_params)
@project_saved = @project.save
-
+
# Project successfully created.
if response_success?(@project_saved)
flash[:notice] = t('projects.project_successfully_created')
@@ -160,10 +160,10 @@ def destroy
def project_params
p = params.require(:project).permit(:name, :acronym, :institution, :contacts, { creator:[] }, :homePage,
:description, { ontologyUsed:[] })
-
+
p[:creator]&.reject!(&:blank?)
- p[:ontologyUsed]&.reject!(&:blank?)
- p.to_h
+ p[:ontologyUsed] ||= []
+ p = p.to_h
end
def flash_error(msg)
diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb
index 8c5c97f1f0..1116e6a740 100644
--- a/app/controllers/schemes_controller.rb
+++ b/app/controllers/schemes_controller.rb
@@ -23,9 +23,9 @@ def index
render inline: helpers.render_search_paginated_list(container_id: 'schemes_sorted_list',
- next_page_url: "/ontologies/#{@ontology.acronym}/schemes",
- child_url: "/ontologies/#{@ontology.acronym}/schemes/show", child_turbo_frame: 'scheme',
- child_param: :schemeid,
+ next_page_url: "/ontologies/#{@ontology.acronym}/schemes",
+ child_url: "/ontologies/#{@ontology.acronym}/schemes/show", child_turbo_frame: 'scheme',
+ child_param: :schemeid,
results: results, next_page: next_page, total_count: total_count)
end
@@ -35,7 +35,7 @@ def show
redirect_to(ontology_path(id: params[:ontology], p: 'schemes', schemeid: params[:id],lang: request_lang)) and return unless turbo_frame_request?
@scheme = get_request_scheme
-
+
render partial: "schemes/show"
end
@@ -43,8 +43,9 @@ def show_label
scheme = get_request_scheme
scheme_label = scheme ? scheme['prefLabel'] : params[:id]
scheme_label = scheme_label.nil? || scheme_label.empty? ? params[:id] : scheme_label
-
- render LabelLinkComponent.inline(params[:id], helpers.main_language_label(scheme_label))
+ label = helpers.main_language_label(scheme_label)
+ link = scheme_path(scheme_id: params[:id], ontology_id: params[:ontology_id])
+ render(inline: helpers.ajax_link_chip(params[:id], label, link, external: scheme.blank?), layout: false)
end
private
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b46440f674..f11d494a32 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -9,7 +9,7 @@ module ApplicationHelper
REST_URI = $REST_URL
API_KEY = $API_KEY
- include ModalHelper, MultiLanguagesHelper, UrlsHelper
+ include ModalHelper, MultiLanguagesHelper, UrlsHelper, ComponentsHelper
RESOLVE_NAMESPACE = {:omv => "http://omv.ontoware.org/2005/05/ontology#", :skos => "http://www.w3.org/2004/02/skos/core#", :owl => "http://www.w3.org/2002/07/owl#",
@@ -19,7 +19,7 @@ module ApplicationHelper
:umls => "http://bioportal.bioontology.org/ontologies/umls/", :door => "http://kannel.open.ac.uk/ontology#", :dct => "http://purl.org/dc/terms/",
:void => "http://rdfs.org/ns/void#", :foaf => "http://xmlns.com/foaf/0.1/", :vann => "http://purl.org/vocab/vann/", :adms => "http://www.w3.org/ns/adms#",
:voaf => "http://purl.org/vocommons/voaf#", :dcat => "http://www.w3.org/ns/dcat#", :mod => "http://www.isibang.ac.in/ns/mod#", :prov => "http://www.w3.org/ns/prov#",
- :cc => "http://creativecommons.org/ns#", :schema => "http://schema.org/", :doap => "http://usefulinc.com/ns/doap#", :bibo => "http://purl.org/ontology/bibo/",
+ :cc => "http://creativecommons.org/ns#", :schema => "http://schema.org/", :doap => "http://usefulinc.com/ns/doap#", :bibo => "http://purl.org/ontology/bibo/",
:wdrs => "http://www.w3.org/2007/05/powder-s#", :cito => "http://purl.org/spar/cito/", :pav => "http://purl.org/pav/", :nkos => "http://w3id.org/nkos/nkostype#",
:oboInOwl => "http://www.geneontology.org/formats/oboInOwl#", :idot => "http://identifiers.org/idot/", :sd => "http://www.w3.org/ns/sparql-service-description#",
:cclicense => "http://creativecommons.org/licenses/",
@@ -55,7 +55,6 @@ def get_apikey
end
end
-
def omniauth_providers_info
$OMNIAUTH_PROVIDERS || []
end
@@ -76,7 +75,6 @@ def current_user_admin?
session[:user] && session[:user].admin?
end
-
def child_id(child)
child.id.to_s.split('/').last
end
@@ -107,20 +105,23 @@ def error_message_alert
end
def onts_for_select(include_views: false)
- ontologies ||= LinkedData::Client::Models::Ontology.all({include: "acronym,name", include_views: include_views})
+ ontologies ||= LinkedData::Client::Models::Ontology.all({include: "acronym,name,viewOf", include_views: include_views})
onts_for_select = [['', '']]
ontologies.each do |ont|
next if ( ont.acronym.nil? or ont.acronym.empty? )
acronym = ont.acronym
name = ont.name
abbreviation = acronym.empty? ? "" : "(#{acronym})"
- ont_label = "#{name.strip} #{abbreviation}"
+ ont_label = "#{name.strip} #{abbreviation}#{ont.viewOf ? ' [view]' : ''}"
onts_for_select << [ont_label, acronym]
end
onts_for_select.sort! { |a,b| a[0].downcase <=> b[0].downcase }
onts_for_select
end
+ def slices_enabled?
+ $ENABLE_SLICES.eql?(true)
+ end
def at_slice?
!@subdomain_filter.nil? && !@subdomain_filter[:active].nil? && @subdomain_filter[:active] == true
@@ -128,7 +129,7 @@ def at_slice?
def add_comment_button(parent_id, parent_type)
if session[:user].nil?
- link_to t('application.add_comment'), login_index_path(redirect: request.url), class: "secondary-button regular-button slim"
+ link_to t('application.add_comment'), login_index_path(redirect: request.url), class: "secondary-button regular-button slim", data: {'turbo-frame': '_top'}
else
link_to_modal t('application.add_comment'), notes_new_comment_path(parent_id: parent_id, parent_type: parent_type, ontology_id: @ontology.acronym),
class: "secondary-button regular-button slim", data: { show_modal_title_value: t('application.add_new_comment')}
@@ -145,14 +146,13 @@ def add_reply_button(parent_id)
def add_proposal_button(parent_id, parent_type)
if session[:user].nil?
- link_to t('application.add_proposal'), login_index_path(redirect: request.url), class: "secondary-button regular-button slim"
+ link_to t('application.add_proposal'), login_index_path(redirect: request.url), class: "secondary-button regular-button slim", data: {'turbo-frame': '_top'}
else
link_to_modal t('application.add_proposal'), notes_new_proposal_path(parent_id: parent_id, parent_type: parent_type, ontology_id: @ontology.acronym),
class: "secondary-button regular-button slim", data: { show_modal_title_value: t('application.add_new_proposal')}
end
end
-
def subscribe_button(ontology_id)
return if ontology_id.nil?
render TurboFrameComponent.new(id: 'subscribe_button', src: ontology_subscriptions_path(ontology_id: ontology_id.split('/').last), class: 'ml-1') do |t|
@@ -175,21 +175,15 @@ def admin_block(ontology: @ontology, user: session[:user], class_css: "admin-bor
end
def subscribed_to_ontology?(ontology_acronym, user)
- user = LinkedData::Client::Models::User.find(user.username, {include: 'subscription'}) if user.subscription.nil?
+ user = LinkedData::Client::Models::User.find(user.username, {include: 'all'}) if user.subscription.nil?
return false if user.subscription.nil? or user.subscription.empty?
user.subscription.each do |sub|
- #sub = {ontology: ontology_acronym, notification_type: "NOTES"}
sub_ont_acronym = sub[:ontology] ? sub[:ontology].split('/').last : nil # make sure we get the acronym, even if it's a full URI
return true if sub_ont_acronym == ontology_acronym
end
return false
end
- def ontolobridge_instructions_template(ontology)
- ont_data = Ontology.find_by(acronym: ontology.acronym)
- ont_data.nil? || ont_data.new_term_instructions.empty? ? t('concepts.request_term.new_term_instructions') : ont_data.new_term_instructions
- end
-
# http://stackoverflow.com/questions/1293573/rails-smart-text-truncation
def smart_truncate(s, opts = {})
opts = {:words => 20}.merge(opts)
@@ -223,95 +217,40 @@ def notification_type(flash_key)
bootstrap_alert_class[flash_key]
end
- def bp_ont_link(ont_acronym)
- return "/ontologies/#{ont_acronym}"
- end
-
- def bp_class_link(cls_id, ont_acronym)
- return "#{bp_ont_link(ont_acronym)}?p=classes&conceptid=#{escape(cls_id)}&language=#{request_lang}"
- end
-
- def bp_scheme_link(scheme_id, ont_acronym)
- return "#{bp_ont_link(ont_acronym)}?p=schemes&schemeid=#{escape(scheme_id)}"
- end
-
- def bp_label_xl_link(label_xl_id, ont_acronym)
- return "#{bp_ont_link(ont_acronym)}/?label_xl_id=#{escape(label_xl_id)}"
- end
-
- def bp_collection_link(collection_id, ont_acronym)
- "#{bp_ont_link(ont_acronym)}?p=collection&collectionid=#{escape(collection_id)}"
- end
-
- def label_ajax_data_h(cls_id, ont_acronym, ajax_uri, cls_url)
- { data:
- {
- 'label-ajax-cls-id-value': cls_id,
- 'label-ajax-ontology-acronym-value': ont_acronym,
- 'label-ajax-ajax-url-value': ajax_uri,
- 'label-ajax-cls-id-url-value': cls_url
- }
- }
- end
-
- def label_ajax_data(cls_id, ont_acronym, ajax_uri, cls_url)
- label_ajax_data_h(cls_id, ont_acronym, ajax_uri, cls_url)
- end
+ def label_ajax_link(id, ont_acronym, ajax_uri, target)
+ ajax_uri = if ajax_uri.include?('?')
+ "#{ajax_uri}&ontology=#{ont_acronym}&id=#{escape(id)}"
+ else
+ "#{ajax_uri}?ontology=#{ont_acronym}&id=#{escape(id)}"
+ end
- def label_ajax_link(link, cls_id, ont_acronym, ajax_uri, cls_url, target = nil)
- data = label_ajax_data(cls_id, ont_acronym, ajax_uri, cls_url)
- options = { 'data-controller': 'label-ajax' }.merge(data)
- options = options.merge({ target: target }) if target
- content_tag(:span, class: 'mx-1') do
- render ChipButtonComponent.new(url: link, text: cls_id, type: 'clickable', **options)
+ content_tag(:span, class: 'concepts-mapping-count') do
+ ajax_link_chip(id, ajax_src: ajax_uri, target: target)
end
end
def get_link_for_cls_ajax(cls_id, ont_acronym, target = nil)
if cls_id.start_with?('http://') || cls_id.start_with?('https://')
- link = bp_class_link(cls_id, ont_acronym)
ajax_url = '/ajax/classes/label'
- cls_url = "/ontologies/#{ont_acronym}?p=classes&conceptid=#{CGI.escape(cls_id)}"
- label_ajax_link(link, cls_id, ont_acronym, ajax_url , cls_url ,target)
+ label_ajax_link(cls_id, ont_acronym, ajax_url, target)
else
content_tag(:div, cls_id)
end
end
- def get_link_for_ont_ajax(ont_acronym)
- # ajax call will replace the acronym with an ontology name (triggered by class='ont4ajax')
- href_ont = " href='#{bp_ont_link(ont_acronym)}' "
- data_ont = " data-ont='#{ont_acronym}' "
- return "
#{ont_acronym}"
- end
-
def get_link_for_scheme_ajax(scheme, ont_acronym, target = '_blank')
- link = bp_scheme_link(scheme, ont_acronym)
ajax_url = "/ajax/schemes/label?language=#{request_lang}"
- scheme_url = "?p=schemes&schemeid=#{CGI.escape(scheme)}"
- label_ajax_link(link, scheme, ont_acronym, ajax_url, scheme_url, target)
+ label_ajax_link(scheme, ont_acronym, ajax_url, target)
end
def get_link_for_collection_ajax(collection, ont_acronym, target = '_blank')
- link = bp_collection_link(collection, ont_acronym)
ajax_url = "/ajax/collections/label?language=#{request_lang}"
- collection_url = "?p=collections&collectionid=#{CGI.escape(collection)}"
- label_ajax_link(link, collection, ont_acronym, ajax_url, collection_url, target)
- end
-
- def get_link_for_label_xl_ajax(label_xl, ont_acronym, cls_id, modal: true)
- link = label_xl
- ajax_uri = "/ajax/label_xl/label?cls_id=#{CGI.escape(cls_id)}"
- label_xl_url = "/ajax/label_xl/?id=#{CGI.escape(label_xl)}&ontology=#{ont_acronym}&cls_id=#{CGI.escape(cls_id)}"
- data = label_ajax_data_h(label_xl, ont_acronym, ajax_uri, label_xl_url)
- data[:data][:controller] = 'label-ajax'
- if modal
- link_to_modal(cls_id, link, {data: data[:data] , class: 'btn btn-sm btn-light m-1'})
- else
- link_to(link,'', {data: data[:data], class: 'btn btn-sm btn-light m-1', target: '_blank'})
- end
-
+ label_ajax_link(collection, ont_acronym, ajax_url, target)
+ end
+ def get_link_for_label_xl_ajax(label_xl, ont_acronym, cls_id, target = nil)
+ ajax_url = "/ajax/label_xl/label?cls_id=#{CGI.escape(cls_id)}"
+ label_ajax_link(label_xl, ont_acronym, ajax_url, target)
end
def ontology_viewer_page_name(ontology_name, concept_label, page)
@@ -449,14 +388,14 @@ def prefixed_url(url)
def show_advanced_options_button(text: nil, init: nil)
content_tag(:div, class: "#{init ? 'd-none' : ''} advanced-options-button", 'data-action': 'click->reveal-component#show', 'data-reveal-component-target': 'showButton') do
inline_svg_tag('icons/settings.svg') +
- content_tag(:div, text, class: 'text')
+ content_tag(:div, text, class: 'text')
end
end
def hide_advanced_options_button(text: nil, init: nil)
content_tag(:div, class: "#{init ? '' : 'd-none'} advanced-options-button", 'data-action': 'click->reveal-component#hide', 'data-reveal-component-target': 'hideButton') do
inline_svg_tag('icons/hide.svg') +
- content_tag(:div, text, class: 'text')
+ content_tag(:div, text, class: 'text')
end
end
diff --git a/app/helpers/collections_helper.rb b/app/helpers/collections_helper.rb
index b366a1401c..f8593cba2e 100644
--- a/app/helpers/collections_helper.rb
+++ b/app/helpers/collections_helper.rb
@@ -1,4 +1,5 @@
module CollectionsHelper
+ include MultiLanguagesHelper, UrlsHelper
def get_collections(ontology, add_colors: false)
@@ -48,8 +49,8 @@ def no_collections_alert
end
end
- def collection_path(collection_id = '', language = '')
- "/ontologies/#{@ontology.acronym}/collections/show?id=#{escape(collection_id)}&language=#{language}"
+ def collection_path(collection_id: '', ontology_id: @ontology.acronym, language: request_lang)
+ "/ontologies/#{ontology_id}/collections/show?id=#{escape(collection_id)}&language=#{language}"
end
def request_collection_id
@@ -64,8 +65,8 @@ def link_to_collection(collection, selected_collection_id)
pref_label_lang, pref_label_html = get_collection_label(collection)
tooltip = pref_label_lang.to_s.eql?('@none') ? '' : "data-controller='tooltip' data-tooltip-position-value='right' title='#{pref_label_lang.upcase}'"
<<-EOS
-
#{pref_label_html}
diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb
index d0f1879a2a..97fded4d03 100644
--- a/app/helpers/components_helper.rb
+++ b/app/helpers/components_helper.rb
@@ -107,7 +107,7 @@ def paginated_list_component(id:, results:, next_page_url:, child_url:, child_tu
end
def resolvability_check_tag(url)
- content_tag(:span, check_resolvability_container(url), style: 'display: inline-block;', onClick: "window.open('#{check_resolvability_url(url: url)}', '_blank');")
+ content_tag(:span, check_resolvability_container(url), class: 'resolvability-check',style: 'display: inline-block;', onClick: "window.open('#{check_resolvability_url(url: url)}', '_blank');")
end
def rounded_button_component(link)
@@ -172,6 +172,10 @@ def tree_component(root, selected, target_frame:, sub_tree: false, id: nil, auto
end
end
+ def ajax_link_chip(id, label = nil, link = nil, external: false, open_in_modal: false, ajax_src: nil, target: '_blank')
+ render LabelFetcherComponent.new(id: id, label: label, link: link, open_in_modal: open_in_modal, ajax_src: ajax_src, target: target, external: external)
+ end
+
def chart_component(title: '', type:, labels:, datasets:, index_axis: 'x', show_legend: false)
data = {
controller: 'load-chart',
@@ -270,8 +274,8 @@ def regular_button(id, value, variant: "secondary", state: "regular", size: "sli
end
end
- def form_save_button
- render Buttons::RegularButtonComponent.new(id: 'save-button', value: t('components.save_button'), variant: "primary", size: "slim", type: "submit") do |btn|
+ def form_save_button(enable_loading: true)
+ render Buttons::RegularButtonComponent.new(id: 'save-button', value: t('components.save_button'), variant: "primary", size: "slim", type: "submit", state: enable_loading ? 'animate' : '') do |btn|
btn.icon_left do
inline_svg_tag "check.svg"
end
diff --git a/app/helpers/concepts_helper.rb b/app/helpers/concepts_helper.rb
index 3cec8ade6b..1b62c06d76 100644
--- a/app/helpers/concepts_helper.rb
+++ b/app/helpers/concepts_helper.rb
@@ -1,6 +1,11 @@
# frozen_string_literal: true
module ConceptsHelper
- include TermsReuses
+ include TermsReuses, UrlsHelper
+
+ def concept_path(id, ontology_id, language)
+ "/ontologies/#{ontology_id}?p=classes&conceptid=#{escape(id)}&language=#{language}"
+ end
+
def concept_link(acronym, child, language)
child.id.eql?('bp_fake_root') ? '#' : "/ontologies/#{acronym}/concepts/show?id=#{CGI.escape(child.id)}&language=#{language}"
end
@@ -76,14 +81,9 @@ def default_sub_menu_class
def concept_label(ont_id, cls_id)
@ontology = LinkedData::Client::Models::Ontology.find(ont_id)
@ontology ||= LinkedData::Client::Models::Ontology.find_by_acronym(ont_id).first
- ontology_not_found(ont_id) unless @ontology
- # Retrieve a class prefLabel or return the class ID (URI)
- # - mappings may contain class URIs that are not in bioportal (e.g. obo-xrefs)
+ ontology_not_found(ont_id) if @ontology.nil? || @ontology.errors
cls = @ontology.explore.single_class({language: request_lang, include: 'prefLabel'}, cls_id)
- # TODO: log any cls.errors
- # TODO: NCBO-402 might be implemented here, but it throws off a lot of ajax result rendering.
- #cls_label = cls.prefLabel({:use_html => true}) || cls_id
- cls.prefLabel || cls_id
+ cls&.prefLabel || cls_id
end
def concept_id_param_exist?(params)
diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb
index 2ddcdc5275..d521b517e1 100644
--- a/app/helpers/home_helper.rb
+++ b/app/helpers/home_helper.rb
@@ -13,6 +13,8 @@ def render_footer_link(options = {})
def format_number_abbreviated(number)
+ number = 0 if number.nil?
+
if number >= 1_000_000
(number / 1_000_000).to_s + 'M'
elsif number >= 1_000
diff --git a/app/helpers/mappings_helper.rb b/app/helpers/mappings_helper.rb
index bfe583a41b..129b1e4bf8 100644
--- a/app/helpers/mappings_helper.rb
+++ b/app/helpers/mappings_helper.rb
@@ -2,57 +2,79 @@ module MappingsHelper
# Used to replace the full URI by the prefixed URI
RELATIONSHIP_PREFIX = {
- "http://www.w3.org/2004/02/skos/core#" => "skos:",
- "http://www.w3.org/2000/01/rdf-schema#" => "rdfs:",
- "http://www.w3.org/2002/07/owl#" => "owl:",
- "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf:",
- "http://purl.org/linguistics/gold/" => "gold:",
- "http://lemon-model.net/lemon#" => "lemon:"
+ 'http://www.w3.org/2004/02/skos/core#' => 'skos:',
+ 'http://www.w3.org/2000/01/rdf-schema#' => 'rdfs:',
+ 'http://www.w3.org/2002/07/owl#' => 'owl:',
+ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' => 'rdf:',
+ 'http://purl.org/linguistics/gold/' => 'gold:',
+ 'http://lemon-model.net/lemon#' => 'lemon:'
}
INTERPORTAL_HASH = $INTERPORTAL_HASH
-
- # a little method that returns true if the URIs array contain a gold:translation or gold:freeTranslation
- def translation?(relation_array)
- if relation_array.kind_of?(Array)
- relation_array.map!(&:downcase)
- if relation_array.include? "http://purl.org/linguistics/gold/translation"
- true
- elsif relation_array.include? "http://purl.org/linguistics/gold/freetranslation"
- true
- else
- false
- end
+ def mapping_links(mapping, concept)
+ target_concept = mapping.classes.select do |c|
+ c.id != concept.id && c.links['ontology'] != concept.links['ontology']
+ end.first
+ target_concept ||= mapping.classes.last
+ process = mapping.process || {}
+
+ if inter_portal_mapping?(target_concept)
+ cls_link = target_concept.id
+ ont_name = target_concept.links['ontology']
+ ont_link = link_to ont_name, get_inter_portal_ui_link(ont_name, process['name']), target: '_blank'
+ source_tooltip = 'Internal-portal'
+ elsif internal_mapping?(target_concept)
+ ont_name = target_concept.links['ontology'].split('/').last
+ ont_link = link_to ont_name, ontology_path(ont_name), 'data-turbo-frame': '_top'
+ cls_link = raw(get_link_for_cls_ajax(target_concept.id, ont_name, '_top'))
+ source_tooltip = 'Internal'
else
- false
+ cls_label = ExternalLinkTextComponent.new(text: target_concept.links['self']).call
+ cls_link = raw("#{cls_label}")
+ ont_name = target_concept.links['ontology']
+ ont_link = link_to ExternalLinkTextComponent.new(text: ont_name).call, target_concept.links['ontology'],
+ target: '_blank'
+ source_tooltip = 'External'
end
+
+ [cls_link, ont_link, source_tooltip]
+ end
+
+ def mapping_prefixed_relations(mapping)
+ process = mapping.process || {}
+ Array(process[:relation]).each { |relation| get_prefixed_uri(relation) }
+ end
+
+ def mapping_type_tooltip(map)
+ relations = mapping_prefixed_relations(map)
+ process = map.process || {}
+ type = if map.source.to_s.include? 'SKOS'
+ 'SKOS'
+ else
+ map.source
+ end
+ types_description = {
+ 'CUI' => t('mappings.types_description.cui'),
+ 'LOOM' => t('mappings.types_description.loom'),
+ 'REST' => t('mappings.types_description.rest'),
+ 'SAME_URI' => t('mappings.types_description.same_uri'),
+ 'SKOS' => t('mappings.types_description.skos')
+ }
+ type_tooltip = content_tag(:div, "#{map.source} #{relations.join(', ')} : #{types_description[type]} #{process[:source_name]}".strip, style: 'width: 300px')
+ [type, type_tooltip]
end
# a little method that returns the uri with a prefix : http://purl.org/linguistics/gold/translation become gold:translation
def get_prefixed_uri(uri)
RELATIONSHIP_PREFIX.each { |k, v| uri.sub!(k, v) }
- return uri
- end
-
- # method to get (using http) prefLabel for interportal classes
- # Using bp_ajax_controller.ajax_process_interportal_cls will try to resolve class labels.
- def ajax_to_inter_portal_cls(cls)
- inter_portal_acronym = get_inter_portal_acronym(cls.links["ui"])
- href_cls = " href='#{cls.links["ui"]}' "
- if inter_portal_acronym
- data_cls = " data-cls='#{cls.links["self"]}?apikey=' "
- portal_cls = " portal-cls='#{inter_portal_acronym}' "
- raw("
#{cls.id}")
- else
- raw("
#{cls.id}")
- end
-
+ uri
end
def ajax_to_internal_cls(cls)
- link_to("#{cls.id}
".html_safe,
- ontology_path(cls.explore.ontology.acronym, p: 'classes', conceptid: cls.id), target: "_blank")
+ cls_id = cls.id
+ ont_acronym = cls.links['ontology'].split('/').last
+ get_link_for_cls_ajax(cls_id, ont_acronym, '_blank')
end
# to get the apikey from the interportal instance of the interportal class.
@@ -60,7 +82,7 @@ def ajax_to_internal_cls(cls)
def get_inter_portal_acronym(class_ui_url)
if !INTERPORTAL_HASH.nil?
INTERPORTAL_HASH.each do |key, value|
- if class_ui_url.start_with?(value["ui"])
+ if class_ui_url.start_with?(value['ui'])
return key
else
return nil
@@ -69,28 +91,25 @@ def get_inter_portal_acronym(class_ui_url)
end
end
- # method to extract the prefLabel from the external class URI
- def get_label_for_external_cls(class_uri)
- if class_uri.include? "#"
- prefLabel = class_uri.split("#")[-1]
- else
- prefLabel = class_uri.split("/")[-1]
- end
- return prefLabel
- end
-
def ajax_to_external_cls(cls)
- raw("
#{get_label_for_external_cls(cls.id)}")
+ class_uri = cls.id
+ text = if class_uri.include? '#'
+ class_uri.split('#')[-1]
+ else
+ class_uri.split('/')[-1]
+ end
+ text = render(ExternalLinkTextComponent.new(text: text))
+ link_to text, cls.links['self'], target: '_blank'
end
# Replace the inter_portal mapping ontology URI (that link to the API) by the link to the ontology in the UI
def get_inter_portal_ui_link(uri, process_name)
process_name = '' if process_name.nil?
- interportal_acronym = process_name.split(" ")[2]
- if interportal_acronym.nil? || interportal_acronym.empty?
+ interportal_acronym = process_name.split(' ')[2]
+ if interportal_acronym.nil? || interportal_acronym.empty? || INTERPORTAL_HASH[interportal_acronym].nil?
uri
else
- uri.sub!(INTERPORTAL_HASH[interportal_acronym]["api"], INTERPORTAL_HASH[interportal_acronym]["ui"])
+ uri.sub!(INTERPORTAL_HASH[interportal_acronym]['api'], INTERPORTAL_HASH[interportal_acronym]['ui'])
end
end
@@ -99,66 +118,14 @@ def internal_mapping?(cls)
end
def inter_portal_mapping?(cls)
- !internal_mapping?(cls) && cls.links.has_key?("ui")
- end
-
- def get_mappings_target_params
- mapping_type = Array(params[:mapping_type]).first
- external = true
- case mapping_type
- when 'interportal'
- ontology_to = "#{params[:map_to_interportal]}/ontologies/#{params[:map_to_interportal_ontology]}"
- concept_to_id = params[:map_to_interportal_class]
- when 'external'
- ontology_to = params[:map_to_external_ontology]
- concept_to_id = params[:map_to_external_class]
- else
- ontology_to = params[:map_to_bioportal_ontology_id]
- concept_to_id = params[:map_to_bioportal_full_id]
- external = false
- end
- [ontology_to, concept_to_id, external]
- end
-
- def set_mapping_target(concept_to_id:, ontology_to:, mapping_type: )
- case mapping_type
- when 'interportal'
- @map_to_interportal, @map_to_interportal_ontology = ontology_to.match(%r{(.*)/ontologies/(.*)}).to_a[1..]
- @map_to_interportal_class = concept_to_id
- when 'external'
- @map_to_external_ontology = ontology_to
- @map_to_external_class = concept_to_id
- else
- @map_to_bioportal_ontology_id = ontology_to
- @map_to_bioportal_full_id = concept_to_id
- end
- end
-
- def get_mappings_target
- ontology_to, concept_to_id, external_mapping = get_mappings_target_params
- target = ''
- if external_mapping
- target_ontology = ontology_to
- target = concept_to_id
- else
- if helpers.link?(ontology_to)
- target_ontology = LinkedData::Client::Models::Ontology.find(ontology_to)
- else
- target_ontology = LinkedData::Client::Models::Ontology.find_by_acronym(ontology_to).first
- end
- if target_ontology
- target = target_ontology.explore.single_class(concept_to_id).id
- target_ontology = target_ontology.id
- end
- end
- [target_ontology, target, external_mapping]
+ !internal_mapping?(cls) && cls.links.has_key?('ui')
end
def type?(type)
@mapping_type.nil? && type.eql?('internal') || @mapping_type.eql?(type)
end
- def concept_mappings_loader(ontology_acronym: ,concept_id: )
+ def concept_mappings_loader(ontology_acronym:, concept_id:)
content_tag(:span, id: 'mapping_count') do
concat(content_tag(:div, class: 'concepts-mapping-count ml-1 mr-1') do
render(TurboFrameComponent.new(
@@ -173,21 +140,23 @@ def concept_mappings_loader(ontology_acronym: ,concept_id: )
end
def client_filled_modal
- link_to_modal "", ""
+ link_to_modal '', ''
end
def mappings_bubble_view_legend
content_tag(:div, class: 'mappings-bubble-view-legend') do
- mappings_legend_section(t('mappings.bubble_view_legend.bubble_size'), t('mappings.bubble_view_legend.bubble_size_desc'), 'mappings-bubble-size-legend') +
+ mappings_legend_section(t('mappings.bubble_view_legend.bubble_size'),
+ t('mappings.bubble_view_legend.bubble_size_desc'), 'mappings-bubble-size-legend') +
mappings_legend_section(
- t('mappings.bubble_view_legend.color_degree'),t('mappings.bubble_view_legend.color_degree_desc'),'mappings-bubble-color-legend') +
+ t('mappings.bubble_view_legend.color_degree'), t('mappings.bubble_view_legend.color_degree_desc'), 'mappings-bubble-color-legend') +
content_tag(:div, class: 'content-container') do
content_tag(:div, class: 'bubble-view-legend-item') do
content_tag(:div, class: 'title') do
- content_tag(:div, t('mappings.bubble_view_legend.yellow_bubble'), class: 'd-inline') + content_tag(:span, t('mappings.bubble_view_legend.selected_bubble'))
+ content_tag(:div, t('mappings.bubble_view_legend.yellow_bubble'),
+ class: 'd-inline') + content_tag(:span, t('mappings.bubble_view_legend.selected_bubble'))
end +
- content_tag(:div, class: "mappings-bubble-size-legend d-flex justify-content-center") do
- content_tag(:div, '', class: "bubble yellow")
+ content_tag(:div, class: 'mappings-bubble-size-legend d-flex justify-content-center') do
+ content_tag(:div, '', class: 'bubble yellow')
end
end
end
@@ -209,7 +178,7 @@ def mappings_legend_section(title_text, description_text, css_class)
def mappings_legend(css_class)
content_tag(:div, class: css_class) do
content_tag(:div, t('mappings.bubble_view_legend.less_mappings'), class: 'mappings-legend-text') +
- (1..6).map { |i| content_tag(:div, "", class: "bubble bubble#{i}") }.join.html_safe +
+ (1..6).map { |i| content_tag(:div, '', class: "bubble bubble#{i}") }.join.html_safe +
content_tag(:div, t('mappings.bubble_view_legend.more_mappings'), class: 'mappings-legend-text')
end
end
diff --git a/app/helpers/multi_languages_helper.rb b/app/helpers/multi_languages_helper.rb
index 9e21f2e0ed..ada13053b1 100644
--- a/app/helpers/multi_languages_helper.rb
+++ b/app/helpers/multi_languages_helper.rb
@@ -22,6 +22,10 @@ def portal_languages
}
end
+ def portal_language_enabled?(lang)
+ portal_languages.reject { |_k, x| x[:disabled] }.keys.include?(lang)
+ end
+
def portal_language_selector
languages = portal_languages
selected_language = portal_lang
@@ -153,7 +157,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)
diff --git a/app/helpers/ontologies_helper.rb b/app/helpers/ontologies_helper.rb
index 1cfe84c87f..1c6180b6f1 100644
--- a/app/helpers/ontologies_helper.rb
+++ b/app/helpers/ontologies_helper.rb
@@ -544,12 +544,15 @@ def render_concepts_json_button(link)
def ontology_object_details_component(frame_id: , ontology_id:, objects_title:, object:, &block)
render TurboFrameComponent.new(id: frame_id, data: {"turbo-frame-target": "frame"}) do
- return if !object.present?
- return alert_component(object.errors.join) if object.errors
+ return unless object.present?
- ontology_object_tabs_component(ontology_id: ontology_id, objects_title: objects_title, object_id: object["@id"]) do |tabs|
- tab_item_component(container_tabs: tabs, title: t('concepts.details'), path: '#details', selected: true) do
- capture(&block)
+ if object.errors
+ alert_component(object.errors.join)
+ else
+ ontology_object_tabs_component(ontology_id: ontology_id, objects_title: objects_title, object_id: object["@id"]) do |tabs|
+ tab_item_component(container_tabs: tabs, title: t('concepts.details'), path: '#details', selected: true) do
+ capture(&block)
+ end
end
end
end
@@ -642,7 +645,7 @@ def ontology_depiction_card
def count_subscriptions(ontology_id)
ontology_id = ontology_id.split('/').last
- users = LinkedData::Client::Models::User.all(include: 'subscription', display_context: false, display_links: false)
+ users = LinkedData::Client::Models::User.all(include: 'all', display_context: false, display_links: false)
users.select { |u| u.subscription.find { |s| s.ontology && s.ontology.split('/').last.eql?(ontology_id) } }.count
end
diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb
index 9d3019cd36..7eec737c73 100644
--- a/app/helpers/schemes_helper.rb
+++ b/app/helpers/schemes_helper.rb
@@ -1,4 +1,5 @@
module SchemesHelper
+ include UrlsHelper
def get_schemes(ontology)
ontology.explore.schemes(language: request_lang)
@@ -47,8 +48,8 @@ def section_name(section)
t("ontology_details.sections.#{section}")
end
- def scheme_path(scheme_id = '', language = '')
- "/ontologies/#{@ontology.acronym}/schemes/show?id=#{escape(scheme_id)}&lang=#{language}"
+ def scheme_path(ontology_id: @ontology.acronym, scheme_id: '', language: request_lang)
+ "/ontologies/#{ontology_id}/schemes/show?id=#{escape(scheme_id)}&lang=#{language}"
end
def no_main_scheme?
@@ -64,6 +65,7 @@ def no_main_scheme_alert
t('schemes.no_main_scheme_alert')
end
end
+
def no_schemes_alert
render Display::AlertComponent.new do
t('schemes.no_schemes_alert', acronym: @ontology.acronym)
@@ -88,7 +90,6 @@ def schemes_tree(schemes_labels, main_scheme_label, selected_scheme_id, submissi
scheme
end.compact
-
main_scheme = nil
if main_scheme_label.nil?
children = schemes
@@ -105,8 +106,8 @@ def schemes_tree(schemes_labels, main_scheme_label, selected_scheme_id, submissi
root.children = children
selected_scheme = selected_scheme || main_scheme || root.children.first
tree_component(root, selected_scheme, target_frame: 'scheme', auto_click: false, submission: submission) do |child|
- href = scheme_path(child['@id'], request_lang) rescue ''
- data = { schemeid: (child['@id'] rescue '')}
+ href = scheme_path(scheme_id: child['@id'], ontology_id: @ontology.acronym, language: request_lang)
+ data = { schemeid: child['@id']}
["#", data, href]
end
end
diff --git a/app/helpers/submission_inputs_helper.rb b/app/helpers/submission_inputs_helper.rb
index 06ecee5b39..2636fdc68e 100644
--- a/app/helpers/submission_inputs_helper.rb
+++ b/app/helpers/submission_inputs_helper.rb
@@ -108,12 +108,12 @@ def attribute_input(attr_key, long_text: false, label: nil, show_tooltip: true,
end
- def ontology_name_input(ontology = @ontology)
- text_input(name: 'ontology[name]', value: ontology.name)
+ def ontology_name_input(ontology = @ontology, label: 'Name')
+ text_input(name: 'ontology[name]', value: ontology.name, label: label_required(label))
end
- def ontology_acronym_input(ontology = @ontology, update: @is_update_ontology)
- out = text_input(name: 'ontology[acronym]', value: ontology.acronym, disabled: update)
+ def ontology_acronym_input(ontology = @ontology, update: @is_update_ontology, label: 'Acronym')
+ out = text_input(name: 'ontology[acronym]', value: ontology.acronym, disabled: update, label: label_required(label))
out += hidden_field_tag('ontology[acronym]', ontology.acronym) if update
out
end
@@ -123,7 +123,7 @@ def ontology_administered_by_input(ontology = @ontology, users_list = @user_sele
users_list = LinkedData::Client::Models::User.all(include: "username").map { |u| [u.username, u.id] }
users_list.sort! { |a, b| a[1].downcase <=> b[1].downcase }
end
- select_input(label: t('submission_inputs.administrators'), name: "ontology[administeredBy]", values: users_list, selected: ontology.administeredBy || session[:user].id, multiple: true)
+ select_input(label: label_required(t('submission_inputs.administrators')), name: "ontology[administeredBy]", values: users_list, selected: ontology.administeredBy || session[:user].id, multiple: true)
end
def ontology_categories_input(ontology = @ontology, categories = @categories)
@@ -213,7 +213,7 @@ def ontology_visibility_input(ontology = @ontology)
render(Layout::RevealComponent.new(possible_values: %w[private public], selected: ontology.viewingRestriction)) do |c|
c.button do
- select_input(label: t('submission_inputs.visibility'), name: "ontology[viewingRestriction]", required: true,
+ select_input(label: label_required(t('submission_inputs.visibility')), name: "ontology[viewingRestriction]", required: true,
values: %w[public private],
selected: ontology.viewingRestriction)
end
@@ -248,7 +248,7 @@ def contact_input(label: '', name: t('submission_inputs.contact'), show_help: tr
render NestedFormInputsComponent.new(object_name: 'contact', default_empty_row: true) do |c|
c.header do
- content_tag(:div, name.blank? ? '' : t('submission_inputs.contact_name', name: name), class: 'w-50') + content_tag(:div, name.blank? ? '' : t('submission_inputs.contact_email', name: name), class: 'w-50')
+ content_tag(:div, name.blank? ? '' : label_required(t('submission_inputs.contact_name', name: name)), class: 'w-50') + content_tag(:div, name.blank? ? '' : label_required(t('submission_inputs.contact_email', name: name)), class: 'w-50')
end
c.template do
@@ -531,4 +531,11 @@ def attribute_help_text(attr)
help_text
end
end
+
+ def label_required(label)
+ content_tag(:div) do
+ label.html_safe +
+ content_tag(:span, '*', style: 'color: var(--error-color);')
+ end
+ end
end
diff --git a/app/javascript/controllers/class_search_auto_complete_controller.js b/app/javascript/controllers/class_search_auto_complete_controller.js
index 831cfee410..0a42a8d343 100644
--- a/app/javascript/controllers/class_search_auto_complete_controller.js
+++ b/app/javascript/controllers/class_search_auto_complete_controller.js
@@ -11,14 +11,9 @@ export default class extends OntoportalAutocompleteController {
onFindValue(li) {
if (li == null) {
- // User performs a search
- let search = confirm("Class could not be found.\n\nPress OK to go to the Search page or Cancel to continue browsing");
-
- if (search) {
- jQuery("#search_keyword").val(jQuery("#search_box").val());
- jQuery("#search_form").submit();
- return
- }
+ // No result found
+ // TODO in this case show a message to redirect to the global search page
+ return
}
// Appropriate value selected
diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js
index fa09b85416..7b99fc21d4 100644
--- a/app/javascript/controllers/index.js
+++ b/app/javascript/controllers/index.js
@@ -34,12 +34,6 @@ application.register("form-options-display", FormDisplayController)
import HistoryController from "./history_controller"
application.register("history", HistoryController)
-import LabelAjaxController from "./label_ajax_controller"
-application.register("label-ajax", LabelAjaxController)
-
-import LabelsAjaxContainerController from "./labels_ajax_container_controller"
-application.register("labels-ajax-container", LabelsAjaxContainerController)
-
import LanguageChangeController from "./language_change_controller"
application.register("language-change", LanguageChangeController)
diff --git a/app/javascript/controllers/label_ajax_controller.js b/app/javascript/controllers/label_ajax_controller.js
deleted file mode 100644
index d3cbcfff46..0000000000
--- a/app/javascript/controllers/label_ajax_controller.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import {Controller} from "@hotwired/stimulus"
-import useAjax from "../mixins/useAjax";
-
-// Connects to data-controller="label-ajax"
-export default class extends Controller {
- static values = {
- clsId: String,
- ontologyAcronym: String,
- ajaxUrl: String,
- clsIdUrl: String,
- }
-
- connect() {
- setTimeout(() => {
- this.linkA = jQuery(this.element);
-
- if (this.linkA.hasClass('ajax-modified-cls')) {
- return true
- }
-
- this.cls_id = this.clsIdValue;
- this.ont_acronym = this.ontologyAcronymValue;
-
- let ajax_uri = new URL(this.ajaxUrlValue, document.location.origin)
-
- ajax_uri.searchParams.set('ontology', this.ont_acronym)
- ajax_uri.searchParams.set('id', this.cls_id)
-
-
- this.request = useAjax({
- url: ajax_uri.pathname + ajax_uri.search,
- timeout: ajax_process_timeout * 1000,
- success: this.#ajaxSuccess.bind(this),
- error: this.#ajaxError.bind(this)
- });
- },1)
- }
-
- abort() {
- if (this.request) {
- this.request.abort()
- this.request = null
- }
- }
-
- disconnect() {
- this.abort()
- }
-
- #ajaxSuccess(data) {
- data = data.trim();
- if (typeof data !== "undefined" && data.length > 0 && data.indexOf("http") !== 0) {
- let cls_name = data
- let cls_uri = this.clsIdUrlValue
- this.linkA.html(cls_name);
- this.linkA.attr('href', cls_uri);
- this.linkA.addClass('ajax-modified-cls');
- //find and process any identical classes (low probability)
- this.#fillIdenticalIds(cls_name, cls_uri)
- } else {
- // remove the unique_id separator and the ontology acronym from the href
- this.linkA.attr('href', this.cls_id); // it may not be an ontology class, don't use the cls_uri
- this.linkA.addClass('ajax-modified-cls');
- }
- }
-
- #ajaxError() {
- this.linkA.addClass('ajax-error')
- }
-
- #fillIdenticalIds(cls_name, cls_uri) {
-
- let unique_id = this.linkA.attr('href');
- jQuery('a[href="' + unique_id + '"]').each(function () {
- let link = jQuery(this);
- if (!link.hasClass('ajax-modified-cls')) {
- link.html(cls_name);
- link.attr('href', cls_uri);
- link.addClass('ajax-modified-cls')
- }
- });
- }
-}
diff --git a/app/javascript/controllers/labels_ajax_container_controller.js b/app/javascript/controllers/labels_ajax_container_controller.js
deleted file mode 100644
index a8f606114c..0000000000
--- a/app/javascript/controllers/labels_ajax_container_controller.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import {Controller} from "@hotwired/stimulus"
-
-// Connects to data-controller="labels-ajax-container"
-export default class extends Controller {
- static outlets = ['label-ajax']
-
- abortAll() {
- this.labelAjaxOutlets.forEach((link) => {link.abort()})
- }
-}
diff --git a/app/javascript/controllers/turbo_frame_error_controller.js b/app/javascript/controllers/turbo_frame_error_controller.js
index 782166bc54..16d2cbbd28 100644
--- a/app/javascript/controllers/turbo_frame_error_controller.js
+++ b/app/javascript/controllers/turbo_frame_error_controller.js
@@ -34,7 +34,10 @@ export default class extends Turbo_frame_controller {
Array.from(styles).forEach(e => el.removeChild(e))
let body = el.querySelector('h1')
- this.errorMessageTarget.firstElementChild.querySelector('.alert-message').innerHTML = (body ? body.innerText : el.innerHTML)
+ let alertContainer = this.errorMessageTarget.firstElementChild?.querySelector('.alert-message')
+ if(alertContainer){
+ alertContainer.innerHTML = (body ? body.innerText : el.innerHTML)
+ }
$(this.errorMessageTarget).show()
}
diff --git a/app/views/collections/_list_view.html.haml b/app/views/collections/_list_view.html.haml
index a50abe0ce2..d0594f157f 100644
--- a/app/views/collections/_list_view.html.haml
+++ b/app/views/collections/_list_view.html.haml
@@ -11,6 +11,6 @@
- scheme = OpenStruct.new(collection)
- scheme.prefLabel = Array(get_collection_label(collection)).last
- scheme.id = scheme['@id']
- - tree_child.child(child: scheme, href: collection_path(collection['@id'], request_lang),
+ - tree_child.child(child: scheme, href: collection_path(collection_id: collection['@id'], ontology_id: @ontology.acronym, language: request_lang),
children_href: '#', selected: scheme.id.eql?(selected_collection_id),
target_frame: 'collection', data: {collectionid: collection['@id']}, is_reused: concept_reused?(submission: @submission, concept_id: scheme.id))
diff --git a/app/views/concepts/_list.html.haml b/app/views/concepts/_list.html.haml
index 9c9a28a848..45d56b6f41 100644
--- a/app/views/concepts/_list.html.haml
+++ b/app/views/concepts/_list.html.haml
@@ -10,6 +10,9 @@
= render TreeLinkComponent.new(child: concept, href: href,
children_href: '#', selected: concept.id.eql?(concepts.first.id) && c.auto_click?,
target_frame: 'concept_show', data: data, is_reused: concept_reused?(submission: @submission, concept_id: concept.id))
- - c.error do
- = t('concepts.list_error')
+ - c.error do
+ - if @collection.nil?
+ = t("ontologies.concepts_browsers.select_collection")
+ - else
+ = t('concepts.list_error')
diff --git a/app/views/concepts/_request_term.html.haml b/app/views/concepts/_request_term.html.haml
deleted file mode 100644
index 85c364f60e..0000000000
--- a/app/views/concepts/_request_term.html.haml
+++ /dev/null
@@ -1,47 +0,0 @@
-:plain
-
-.notes_list_container
- .add_request_term{style: "float: left; margin-right: 1em;"}
- %div#ob_success_message{class: "message-box success-msg", style: "display: none; margin: 10px 0;"}
- %div#ob_error_message{class: "message-box error-msg", style: "display: none; margin: 10px 0;"}
- - if !session[:user].nil? && @ontology.admin?(session[:user])
- %p
- %em
- = t('concepts.request_terms_instructions', acronym: @ontology.acronym)
- %div#new_term_instructions_container{style: 'clear: both;'}
- %form#new_term_instructions_form
- = hidden_field nil, :acronym, value: @ontology.acronym
- = hidden_field nil, :new_term_instructions_old, value: @ob_instructions.html_safe
- %div#new_term_instructions
- = @ob_instructions.html_safe
- %button#new_term_instructions_submit{class: "btn", type: "button", title: t('concepts.submit_changes'), alt: "Submit Changes", style: 'display: none;'}
- = t('concepts.submit_changes')
- %button#new_term_instructions_cancel{class: "btn", type: "button", title: t('concepts.cancel'), alt: "Cancel", style: 'display: none;'}
- = t('concepts.cancel')
- %span#progress_message{style: 'display: none; margin-left: 20px;'}
- - else
- %div
- = @ob_instructions.html_safe
- - if session[:user].nil?
- = link_to t('concepts.request_new_term'), login_index_path, style: "font-size: .9em;"
- - else
- = link_to t('concepts.request_new_term'), "javascript:void(0);", class: "add_request_term", style: "font-size: .9em;", data: { parent_id: "#{@concept.id}" }
- %div.request_term_form_div{style: "display: none; clear: both; padding-top: 1em;"}
-
-:javascript
- var g_prefLabel;
-
- jQuery(document).ready(function() {
- g_prefLabel = '#{@concept.prefLabel({:use_html => false}).html_safe}';
-
- if (!g_prefLabel) {
- g_prefLabel = '#{@concept.id}';
- }
- var isPopulated = window.localStorage.getItem('request_term_form_populated');
-
- if (isPopulated) {
- addRequestTermBox("#{@concept.id}");
- }
- });
diff --git a/app/views/concepts/_show.html.haml b/app/views/concepts/_show.html.haml
index 8d690b65fd..bbbb95614b 100644
--- a/app/views/concepts/_show.html.haml
+++ b/app/views/concepts/_show.html.haml
@@ -1,4 +1,4 @@
-= render TurboFrameComponent.new(id: 'concept_show', data: {controller:'labels-ajax-container', 'action': 'turbo:before-fetch-request->labels-ajax-container#abortAll', 'labels-ajax-container-label-ajax-outlet': '#concept_show a[data-controller="label-ajax"]'}) do
+= render TurboFrameComponent.new(id: 'concept_show') do
- if @concept.id.eql?("bp_fake_root")
= render Display::AlertComponent.new do
= t('concepts.use_jump_to')
diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml
index f330566b7b..6cc474bbc6 100644
--- a/app/views/home/index.html.haml
+++ b/app/views/home/index.html.haml
@@ -22,18 +22,18 @@
.home-bubble.home-bubble-one
%a.h5{href:"/ontologies/#{@anal_ont_names[0]}", style: "color: white !important"}
= @anal_ont_names[0]
- %p
- = @anal_ont_numbers[0].to_s + " " + t('visits.visits')
+ %p
+ = format_number_abbreviated(@anal_ont_numbers[0]) + " " + (@analytics.empty? ? t('visits.count') : t('visits.visits'))
.home-bubble.home-bubble-two
%a.h5{href:"/ontologies/#{@anal_ont_names[1]}", style: "color: white !important"}
= @anal_ont_names[1]
- %p
- = @anal_ont_numbers[1].to_s + " " + t('visits.visits')
+ %p
+ = format_number_abbreviated(@anal_ont_numbers[1]) + " " + (@analytics.empty? ? t('visits.count') : t('visits.visits'))
.home-bubble.home-bubble-three
%a.h5{href:"/ontologies/#{@anal_ont_names[2]}", style: "color: white !important"}
= @anal_ont_names[2]
- %p
- = @anal_ont_numbers[2].to_s + " " + t('visits.visits')
+ %p
+ = format_number_abbreviated(@anal_ont_numbers[2]) + " " + (@analytics.empty? ? t('visits.count') : t('visits.visits'))
%a.home-bubble.home-bubble-four{:href => "/visits"}
.h5 ...
@@ -47,7 +47,7 @@
.home-body-container
.home-section
- %h4= t('home.ontology_upload')
+ %h4= t('home.ontology_upload', site: portal_name)
%hr.home-section-line/
%p= t('home.ontology_upload_desc')
%p= t('home.ontology_upload_benefits', site: $SITE)
@@ -62,6 +62,56 @@
= upload_ontology_button
.discover-ontologies
= discover_ontologies_button
+ .home-section
+ %h4
+ = t('home.agroportal_figures', site: current_slice_name || portal_name)
+ %hr.home-section-line/
+ .home-statistics-container
+ .home-statistics
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:ontologies_count])
+ %p= t("home.ontologies")
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:class_count])
+ %p= t("home.classes")
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:individuals_count])
+ %p= t("home.individuals")
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:properties_count])
+ %p= t("home.properties")
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:projects_count])
+ %p= t("home.projects")
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:mappings_count])
+ %p= t("home.mappings")
+ .home-statistics-item
+ %hr/
+ %div
+ %h4
+ = format_number_abbreviated(@metrics[:users_count])
+ %p= t("home.users")
+ .home-statistics-link.justify-content-end{style: @analytics.empty? && "visibility: hidden"}
+ = link_to t("home.see_details"),'/statistics', target: "_blank"
.home-section
%h4
@@ -125,58 +175,7 @@
= render LoaderComponent.new(type: 'pulsing')
%script{:async => "", :charset => "utf-8", :src => "https://platform.twitter.com/widgets.js"}
- .home-section
- %h4
- = t('home.agroportal_figures', site: current_slice_name || portal_name)
- %hr.home-section-line/
- .home-statistics-container
- .home-statistics
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:ontologies_count])
- %p= t("home.ontologies")
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:class_count])
- %p= t("home.classes")
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:individuals_count])
- %p= t("home.individuals")
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:properties_count])
- %p= t("home.properties")
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:projects_count])
- %p= t("home.projects")
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:mappings_count])
- %p= t("home.mappings")
- .home-statistics-item
- %hr/
- %div
- %h4
- = format_number_abbreviated(@metrics[:users_count])
- %p= t("home.users")
- .home-statistics-link.justify-content-end{style: @analytics.empty? && "visibility: hidden"}
- = link_to t("home.see_details"),'/statistics', target: "_blank"
-
- - if @slices
+ - if slices_enabled?
.home-section
.home-section-title
.text
@@ -238,4 +237,4 @@
}
function submitRecommender(){
document.getElementById("recommender_submit").click()
- }
+ }
\ No newline at end of file
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index fcc5859ccc..54d83afe8f 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -46,10 +46,6 @@
{
}
;
- jQuery(document).data().bp.ontolobridge_ontologies =
- <%=$NEW_TERM_REQUEST_ONTOLOGIES.to_json.html_safe%> ||
- [];
- jQuery(document).data().bp.ont_viewer = {};
jQuery(document).data().bp.ont_chart = {};
@@ -60,4 +56,4 @@
<%= turbo_frame_tag :cookies_modal, src: cookies_path if cookies[:cookies_accepted].nil? && !(Rails.env.development? || Rails.env.test?) %>
-<%= render partial: 'layouts/notices' %>
\ No newline at end of file
+<%= render partial: 'layouts/notices' %>
diff --git a/app/views/layouts/_ontology_viewer.html.haml b/app/views/layouts/_ontology_viewer.html.haml
index e7f3010e16..95fe55300d 100644
--- a/app/views/layouts/_ontology_viewer.html.haml
+++ b/app/views/layouts/_ontology_viewer.html.haml
@@ -4,26 +4,6 @@
= render :partial =>'layouts/header'
%div#bd.bg-white.ontology-viewer
- :javascript
- // Ontology viewer vars
- jQuery(document).data().bp.ont_viewer = {};
- jQuery(document).data().bp.ont_viewer.ontology_id = jQuery(document).data().bp.ontology.acronym;
- jQuery(document).data().bp.ont_viewer.ontology_version_id = jQuery(document).data().bp.submission_latest.submissionId;
- jQuery(document).data().bp.ont_viewer.ontology_name = "#{@ontology.name}";
- jQuery(document).data().bp.ont_viewer.org_site = "#{$ORG_SITE}";
- jQuery(document).data().bp.ont_viewer.concept_id = "#{params[:conceptid] || (@concept ? @concept.id : 'root')}";
- jQuery(document).data().bp.ont_viewer.content_section = "#{sanitize(h(content_section))}";
- jQuery(document).data().bp.ont_viewer.concept_param = "#{"conceptid=\#{params[:conceptid]}" unless params[:conceptid].nil? || params[:conceptid].empty?}";
- jQuery(document).data().bp.ont_viewer.concept_name = "#{@concept.prefLabel unless @concept.nil?}";
- jQuery(document).data().bp.ont_viewer.metadata_only = "#{@ontology.summaryOnly}";
- jQuery(document).data().bp.ont_viewer.current_purl = "#{@current_purl}";
- jQuery(document).data().bp.ont_viewer.purl_prefix = "#{($PURL_ENABLED ? $PURL_PREFIX+"/"+@ontology.acronym : '')}";
- jQuery(document).data().bp.ont_viewer.concept_name_title = (jQuery(document).data().bp.ont_viewer.concept_name == "") ?
- "" : " - " + jQuery(document).data().bp.ont_viewer.concept_name;
-
-
-
-
= modal_frame_container
= render partial: 'concepts/perma_link_modal'
diff --git a/app/views/layouts/appliance.html.haml b/app/views/layouts/appliance.html.haml
index 778b0fe1c9..02cddcf9b7 100644
--- a/app/views/layouts/appliance.html.haml
+++ b/app/views/layouts/appliance.html.haml
@@ -21,7 +21,6 @@
jQuery(document).data({bp: {config: #{bp_config_json.html_safe}, user: #{(session[:user] || {}).to_hash.to_json.html_safe}}});
jQuery(document).data().bp.ontology = #{@ontology.to_json.html_safe} || {};
jQuery(document).data().bp.submission_latest = #{@submission_latest.to_json.html_safe} || {};
- jQuery(document).data().bp.ont_viewer = {};
jQuery(document).data().bp.ont_chart = {};
%body{:class => "#{controller_name} #{action_name}"}
@@ -35,4 +34,3 @@
= yield
= render partial: "layouts/footer"
-
diff --git a/app/views/layouts/component_preview.html.erb b/app/views/layouts/component_preview.html.erb
index 429f630109..04686f6ce4 100644
--- a/app/views/layouts/component_preview.html.erb
+++ b/app/views/layouts/component_preview.html.erb
@@ -41,10 +41,6 @@
{
}
;
- jQuery(document).data().bp.ontolobridge_ontologies =
- <%=$NEW_TERM_REQUEST_ONTOLOGIES.to_json.html_safe%> ||
- [];
- jQuery(document).data().bp.ont_viewer = {};
jQuery(document).data().bp.ont_chart = {};
@@ -57,4 +53,4 @@