Skip to content

Commit

Permalink
add ontology license badge in the ontology viewer header
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 28, 2023
1 parent 235faee commit d9739f5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
4 changes: 4 additions & 0 deletions app/assets/images/icons/law.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/assets/stylesheets/bioportal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ body{

}

.disabled-link{
color: #888888 !important;
span{
opacity: 0.6;
}
a {
color: #888888 !important;
}
svg path{
fill: #888888 !important;
}
}
.text-truncate-scroll{
overflow: scroll;
white-space: nowrap;
Expand Down
14 changes: 14 additions & 0 deletions app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ module OntologiesHelper
def ontology_retired?(submission)
submission[:status].to_s.eql?('retired') || submission[:deprecated].to_s.eql?('true')
end
def ontology_license_badge(acronym, submission = @submission_latest)
no_license = submission.hasLicense.blank?
render ChipButtonComponent.new(class: "chip_button_small #{no_license && 'disabled-link'}", type: 'static') do
if no_license
content_tag(:span) do
content_tag(:span, "No license", class: "mx-1") + inline_svg_tag('icons/law.svg', width: "15px")
end
else
link_to_modal(nil, "/ajax/submission/show_licenses/#{acronym}",data: { show_modal_title_value: "Additional license a access rights information"}) do
content_tag(:span, "View license", class: "mx-1") + inline_svg_tag('icons/law.svg')
end
end

end
end
def ontology_retired_badge(submission, small: false, clickable: true)
return if submission.nil? || !ontology_retired?(submission)
text_color = submission[:status].to_s.eql?('retired') ? 'text-danger bg-danger-light' : 'text-warning bg-warning-light'
Expand Down
5 changes: 3 additions & 2 deletions app/views/layouts/ontology_viewer/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
.ontology-details-header-sub-container
.ontology-details-header-left-container{style:'width: 70%'}
.ontology-details-name-bar
%div{style:'max-width: 60%', data: { controller: 'tooltip'}, title: ontology_alternative_names }
%div
= @ontology.name
%span
%span{data: { controller: 'tooltip'}, title: ontology_alternative_names}
= "("+ @ontology.acronym+")"
- if @ontology.private?
= render ChipButtonComponent.new(class: 'chip_button_small mr-1') do
= private_ontology_icon(@ontology.private?)
- if @submission_latest&.hasOntologyLanguage
= render ChipButtonComponent.new(class: 'chip_button_small mr-1', text: @submission_latest.hasOntologyLanguage)
= ontology_retired_badge(@submission_latest, small: true, clickable: false)
= ontology_license_badge(@ontology.acronym, @submission_latest)
- unless sub.nil? || sub.creationDate.nil?
.ontology-details-last-update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,7 @@
For additional information, reach out
%span.date_creation_text
#{display_contact(@submission_latest.contact)}.

- unless @submission_latest.nil? || @submission_latest.hasLicense.nil?
%div.creation_text
%span
- code = ontology_import_code
#{code && "Import #{code} in your resource to start using it.".html_safe } This resource is under
%span.date_creation_text
#{attribute_enforced_values('hasLicense')[@submission_latest.hasLicense] || @submission_latest.hasLicense}
%span
license,
= link_to_modal("see access details", "/ajax/submission/show_licenses/#{@ontology.acronym}",data: { show_modal_title_value: "Additionnal license a access rights information", show_modal_size_value: 'modal-xl' })
%span
for more information.



- unless Array(@submission_latest&.naturalLanguage).empty?
- l.row do
= render FieldContainerComponent.new(label: 'Languages') do
Expand Down

0 comments on commit d9739f5

Please sign in to comment.