Skip to content

Commit

Permalink
fix #30 add the help tooltip for the dates in the submissions table
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 26, 2022
1 parent d70a163 commit 3e3a9f7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
49 changes: 34 additions & 15 deletions app/helpers/submissions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "&lt;strong&gt;#{attr["namespace"]}:#{attr["attribute"]}&lt;/strong&gt;"
else
Expand All @@ -36,9 +28,26 @@ def generate_attribute_label(attr_label)
if (attr["helpText"] != nil)
help_text << "&lt;br&gt;&lt;br&gt;#{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.
Expand Down Expand Up @@ -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 = "<div class='d-flex align-items-center'><span class='mr-1'>#{label}</span><span>"
# Generate tooltip
help_text = attribute_help_text(attr)
label_html << help_tooltip(help_text, {:id => "tooltip#{attr["attribute"]}"} ).html_safe
label_html << '</span></div>'
label_html.html_safe
end
def ontologies_for_select

@ontologies_for_select ||= LinkedData::Client::Models::Ontology.all.collect do |onto|
Expand Down
27 changes: 22 additions & 5 deletions app/views/ontologies/_submissions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,36 @@
}
);

$(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

%div.click_versions_collapse
%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?
Expand Down

0 comments on commit 3e3a9f7

Please sign in to comment.