diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 4f8c69db3..57c833ae2 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -8,7 +8,7 @@ class OntologiesController < ApplicationController layout :determine_layout before_action :authorize_and_redirect, :only=>[:edit,:update,:create,:new] - + before_action :submission_metadata, only: [:show] KNOWN_PAGES = Set.new(["terms", "classes", "mappings", "notes", "widgets", "summary", "properties"]) EXTERNAL_MAPPINGS_GRAPH = "http://data.bioontology.org/metadata/ExternalMappings" INTERPORTAL_MAPPINGS_GRAPH = "http://data.bioontology.org/metadata/InterportalMappings" diff --git a/app/helpers/submissions_helper.rb b/app/helpers/submissions_helper.rb index 2b1dad380..1ec67d9a2 100644 --- a/app/helpers/submissions_helper.rb +++ b/app/helpers/submissions_helper.rb @@ -4,21 +4,13 @@ def extractable_metadatum_tooltip(options = {}) help_tooltip(options[:content], {}, 'fas fa-file-export', 'extractable-metadatum', options[:text]).html_safe end - # Generate the HTML label for every attributes - def generate_attribute_label(attr_label) - # Get the attribute hash corresponding to the given attribute - attr = @metadata.select{ |attr_hash| attr_hash["attribute"].to_s.eql?(attr_label) }.first - label_html = if !attr["extracted"].nil? && attr["extracted"] == true - extractable_metadatum_tooltip({ content: 'Extractable metadatum' }) - end.to_s.html_safe - if !attr["label"].nil? - label_html << label_tag("submission_#{attr_label}", attr["label"], { class: 'form-label' }) - else - label_html << label_tag("submission_#{attr_label}", attr_label.underscore.humanize, { class: 'form-label' }) - end + def attribute_infos(attr_label) + @metadata.select{ |attr_hash| attr_hash["attribute"].to_s.eql?(attr_label) }.first + end + + def attribute_help_text(attr) - # Generate tooltip if !attr["namespace"].nil? help_text = "<strong>#{attr["namespace"]}:#{attr["attribute"]}</strong>" else @@ -36,9 +28,26 @@ def generate_attribute_label(attr_label) if (attr["helpText"] != nil) help_text << "<br><br>#{attr["helpText"]}" end + help_text + end + # Generate the HTML label for every attributes + def generate_attribute_label(attr_label) + # Get the attribute hash corresponding to the given attribute + attr = attribute_infos(attr_label) + label_html = if !attr["extracted"].nil? && attr["extracted"] == true + extractable_metadatum_tooltip({ content: 'Extractable metadatum' }) + end.to_s.html_safe + + if !attr["label"].nil? + label_html << label_tag("submission_#{attr_label}", attr["label"], { class: 'form-label' }) + else + label_html << label_tag("submission_#{attr_label}", attr_label.underscore.humanize, { class: 'form-label' }) + end + # Generate tooltip + help_text = attribute_help_text(attr) label_html << help_tooltip(help_text, {:id => "tooltip#{attr["attribute"]}"}).html_safe - return label_html + label_html end # Generate the HTML input for every attributes. @@ -232,7 +241,17 @@ def generate_attribute_input(attr_label, options = {}) return input_html end end - + + + def generate_attribute_text(attr_label , label) + attr = attribute_infos(attr_label) + label_html = "