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 = "
#{label}" + # Generate tooltip + help_text = attribute_help_text(attr) + label_html << help_tooltip(help_text, {:id => "tooltip#{attr["attribute"]}"} ).html_safe + label_html << '
' + label_html.html_safe + end def ontologies_for_select @ontologies_for_select ||= LinkedData::Client::Models::Ontology.all.collect do |onto| diff --git a/app/views/ontologies/_submissions.html.haml b/app/views/ontologies/_submissions.html.haml index 3496428ce..f92213ce0 100644 --- a/app/views/ontologies/_submissions.html.haml +++ b/app/views/ontologies/_submissions.html.haml @@ -15,6 +15,20 @@ } ); + $(document).ready(function() { + + $('.tooltip_link[title][title!=""]').tooltipster({ + interactive: true, + position: "right", + contentAsHTML: true, + animation: 'fade', + delay: 200, + theme: 'tooltipster-shadow', + trigger: 'hover' + }); + }) + + - more_colspan = 4 - more_colspan = 3 if @ont_restricted @@ -22,12 +36,15 @@ %table#ontology_versions.table.table-sm.table-striped %thead %tr - %th Version - %th Released - %th Modified - %th Uploaded + %th.align-middle Version + %th + = generate_attribute_text("released", "Released") + %th + = generate_attribute_text("modificationDate", "Modified") + %th + = generate_attribute_text("creationDate", "Uploaded") - unless @ont_restricted - %th Downloads + %th.align-middle Downloads - begin - submission_ready = @ontology.explore.latest_submission({:include_status => 'ready'}) - submission_readyId = submission_ready.submissionId unless submission_ready.nil?