From 70a131182706deec311edb04713cfc3ed3e8d685 Mon Sep 17 00:00:00 2001 From: Xiaoming Hu Date: Mon, 14 Aug 2023 15:24:06 +0200 Subject: [PATCH] enhance UI: Display collapsible linked custom metadata attributes --- .../stylesheets/linked_custom_metadata.css | 21 ++++++++++++++++++- app/helpers/samples_helper.rb | 12 +++++++++-- ..._custom_metadata_attribute_values.html.erb | 19 ++++++++++------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/linked_custom_metadata.css b/app/assets/stylesheets/linked_custom_metadata.css index 3ad04c4b8a..596f1cb2f4 100644 --- a/app/assets/stylesheets/linked_custom_metadata.css +++ b/app/assets/stylesheets/linked_custom_metadata.css @@ -35,4 +35,23 @@ padding: 10px 15px 10px 15px; border-radius: 5px; margin-bottom: 15px; -} \ No newline at end of file +} + +.linked_custom_metdata_display .panel-default .panel-heading { + font-weight: bold; + border: none; + background-color: #ffffff; + padding: 0px 0px; +} + + +.linked_custom_metdata_display .panel { + border: none; + box-shadow: none; + margin-bottom: 0px; +} + +.linked_custom_metdata_display .panel-body { + padding: 0px 0px; + border-radius: 5px; +} diff --git a/app/helpers/samples_helper.rb b/app/helpers/samples_helper.rb index 7334691d76..48b9ec010b 100644 --- a/app/helpers/samples_helper.rb +++ b/app/helpers/samples_helper.rb @@ -148,8 +148,16 @@ def linked_custom_metadata_attribute_display(value, attribute) attribute.linked_custom_metadata_type.custom_metadata_attributes.each do |attr| v = value ? value[attr.title.to_s] : nil html += '
  • ' - html += ''+' : ' - html += display_attribute_value(v, attr) + if attr.linked_custom_metadata? || attr.linked_custom_metadata_multi? + html += content_tag(:span, class: 'linked_custom_metdata_display') do + folding_panel(attr.label, true, id:attr.title) do + display_attribute_value(v, attr) + end + end + else + html += ''+' : ' + html += display_attribute_value(v, attr) + end html += '
  • ' end html += '' diff --git a/app/views/custom_metadata/_custom_metadata_attribute_values.html.erb b/app/views/custom_metadata/_custom_metadata_attribute_values.html.erb index 33093b4532..04f7cf0e9d 100644 --- a/app/views/custom_metadata/_custom_metadata_attribute_values.html.erb +++ b/app/views/custom_metadata/_custom_metadata_attribute_values.html.erb @@ -9,16 +9,21 @@ <% resource.custom_metadata.custom_metadata_attributes.each do |attribute| %> <% unless resource.custom_metadata.data[attribute.title].blank? %> -

    - - <%= display_attribute(resource.custom_metadata, attribute, link: true) %> -

    +
    + <% if attribute.linked_custom_metadata? || attribute.linked_custom_metadata_multi? %> + <%= content_tag(:span, class: 'linked_custom_metdata_display') do %> + <%= folding_panel(attribute.label, true, id:attribute.title) do %> + <%= display_attribute(resource.custom_metadata, attribute, link: true) %> + <% end %> + <% end %> + <% else %> + + <%= display_attribute(resource.custom_metadata, attribute, link: true) %> + <% end %> +
    <% end %> <% end %> - - <% else %> - <% end %> \ No newline at end of file