Skip to content

Commit

Permalink
Display based_near_label for based_near term
Browse files Browse the repository at this point in the history
  • Loading branch information
laritakr committed Jul 1, 2024
1 parent 9e65f4a commit 377c62e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions .dassie/config/metadata_profiles/m3_profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions .koppie/config/metadata_profiles/m3_profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 6 additions & 14 deletions app/helpers/hyrax/attributes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<Hash>] a nested hash of view options... {:label=>{"en"=>"Title", "es"=>"Título"}, :html_dl=>true}
def conform_options(field_name, options_hash)
Expand All @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_attribute_rows.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
1 change: 1 addition & 0 deletions config/metadata/basic_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/metadata_profiles/m3_profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 377c62e

Please sign in to comment.