Skip to content

Commit

Permalink
resolved #396 - badge view off for long values
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorf committed Mar 4, 2025
1 parent 932c589 commit 30c5cc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 14 additions & 3 deletions app/components/concept_details_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ def row_hash_properties(properties_set, ontology_acronym, &block)

values = data[:values]
url = data[:key]

is_list = values.is_a?(Array) && values.size > 1
style_as_badge = values.is_a?(Array) && values.size > 1 && short_values(values)

ajax_links = Array(values).map do |v|
if block_given?
capture(v, &block)
else
if v.is_a?(String)
get_link_for_cls_ajax(v, ontology_acronym, '_blank', is_list)
get_link_for_cls_ajax(v, ontology_acronym, '_blank', style_as_badge)
else
display_in_multiple_languages([v].to_h, style_as_badge: true)
end
Expand All @@ -63,6 +62,18 @@ def row_hash_properties(properties_set, ontology_acronym, &block)
out
end

def short_values(vals)
vals.each do |str|
word_count = str.split.count
character_count = str.length

unless word_count < 10 && character_count < 100
return false
end
end
true
end

def properties_set_by_keys(keys, concept_properties, exclude_keys = [])
concept_properties&.select do |k, v|
(keys.include?(k) || !keys.select { |key| v[:key].to_s.include?(key) }.empty?) && !exclude_keys.include?(k) &&
Expand Down
3 changes: 1 addition & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,11 @@ def get_link_for_cls_ajax(cls_id, ont_acronym, target = nil, style_as_badge = fa
if style_as_badge
render ChipButtonComponent.new(text: cls_id)
else
content_tag(:span, cls_id)
content_tag(:div, cls_id)
end
end
end


def get_link_for_ont_ajax(ont_acronym)
# Ajax call will replace the acronym with an ontology name (triggered by class='ont4ajax')
href_ont = " href='#{bp_ont_link(ont_acronym)}' "
Expand Down

0 comments on commit 30c5cc1

Please sign in to comment.