diff --git a/app/assets/stylesheets/taxonomy.scss b/app/assets/stylesheets/taxonomy.scss index 6043973aa..bf5c679ff 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/display/taxonomy_card_component.rb b/app/components/display/taxonomy_card_component.rb index df896191b..154ed5eff 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 + require 'uri' def initialize(taxonomy: , ontologies_names: ) @taxonomy = taxonomy @ontologies_names = ontologies_names @@ -7,4 +8,9 @@ def initialize(taxonomy: , ontologies_names: ) def reveal_id @taxonomy.id end + + def description_is_url? + uri_regex = URI::DEFAULT_PARSER.make_regexp + @taxonomy.description.match?(/\A#{uri_regex}\z/) + end end 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 ab55aa41d..a6bcff113 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 description_is_url? + .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 description_is_url? + .description.mb-1 + = render TextAreaFieldComponent.new(value: @taxonomy.description) + .ontologies-cards - @taxonomy.ontologies.each_with_index do |ontology, index| - if index>10