From 377c62e35f42c7587aefd04df65470d3bb948248 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Mon, 1 Jul 2024 19:19:14 -0400 Subject: [PATCH] Display based_near_label for based_near term --- .../config/metadata_profiles/m3_profile.yaml | 1 + .../config/metadata_profiles/m3_profile.yaml | 6 +----- app/helpers/hyrax/attributes_helper.rb | 20 ++++++------------- app/views/hyrax/base/_attribute_rows.html.erb | 2 +- config/metadata/basic_metadata.yaml | 1 + config/metadata_profiles/m3_profile.yaml | 1 + 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.dassie/config/metadata_profiles/m3_profile.yaml b/.dassie/config/metadata_profiles/m3_profile.yaml index fcbe80c7fd..f8771baf05 100644 --- a/.dassie/config/metadata_profiles/m3_profile.yaml +++ b/.dassie/config/metadata_profiles/m3_profile.yaml @@ -375,6 +375,7 @@ properties: - San Diego, California, United States view: label: Based Near + render_term: 'based_near_label_tesim' html_dl: true bibliographic_citation: available_on: diff --git a/.koppie/config/metadata_profiles/m3_profile.yaml b/.koppie/config/metadata_profiles/m3_profile.yaml index 833b0e6082..bb005e59ef 100644 --- a/.koppie/config/metadata_profiles/m3_profile.yaml +++ b/.koppie/config/metadata_profiles/m3_profile.yaml @@ -72,11 +72,6 @@ properties: requirement: required sample_values: - Pencil drawn portrait study of woman - view: - label: - en: 'Title' - es: 'Título' - html_dl: true date_modified: available_on: class: @@ -344,6 +339,7 @@ properties: - San Diego, California, United States view: label: Based Near + render_term: 'based_near_label_tesim' html_dl: true bibliographic_citation: available_on: diff --git a/app/helpers/hyrax/attributes_helper.rb b/app/helpers/hyrax/attributes_helper.rb index 618c765822..a60b856bab 100644 --- a/app/helpers/hyrax/attributes_helper.rb +++ b/app/helpers/hyrax/attributes_helper.rb @@ -16,6 +16,11 @@ def view_options_for(presenter) end end + def conform_field(field_name, options_hash) + options = HashWithIndifferentAccess.new(options_hash) + HashWithIndifferentAccess.new(options)['render_term'] || field_name + end + # @param [String] field name # @param [Hash] a nested hash of view options... {:label=>{"en"=>"Title", "es"=>"Título"}, :html_dl=>true} def conform_options(field_name, options_hash) @@ -24,7 +29,7 @@ def conform_options(field_name, options_hash) current_locale = params['locale'] || I18n.locale.to_s unless hash_of_locales.present? - options[:label] = field_to_label(field_name.to_s) + options[:label] = field_name.to_s.humanize return options end @@ -43,18 +48,5 @@ def conform_options(field_name, options_hash) options end - - private - - def field_to_label(input_string) - # Split the input string by underscores - words = input_string.downcase.split('_') - # Capitalize the first word - if words.any? - words[0] = words[0].capitalize - end - # Join the words into a single string - words.join(' ') - end end end diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index ea146c7782..ba28733857 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -1,3 +1,3 @@ <% view_options_for(presenter).each do |field, options| %> - <%= presenter.attribute_to_html(field.to_sym, conform_options(field, options)) %> + <%= presenter.attribute_to_html(conform_field(field, options), conform_options(field, options)) %> <% end %> diff --git a/config/metadata/basic_metadata.yaml b/config/metadata/basic_metadata.yaml index 35f65b9562..0c15953f3a 100644 --- a/config/metadata/basic_metadata.yaml +++ b/config/metadata/basic_metadata.yaml @@ -49,6 +49,7 @@ attributes: - "based_near_tesim" predicate: http://xmlns.com/foaf/0.1/based_near view: + render_term: 'based_near_label' html_dl: true bibliographic_citation: type: string diff --git a/config/metadata_profiles/m3_profile.yaml b/config/metadata_profiles/m3_profile.yaml index 206207d61c..a0f7682a09 100644 --- a/config/metadata_profiles/m3_profile.yaml +++ b/config/metadata_profiles/m3_profile.yaml @@ -330,6 +330,7 @@ properties: - San Diego, California, United States view: label: Based Near + render_term: 'based_near_label_tesim' html_dl: true bibliographic_citation: available_on: