Skip to content

Commit

Permalink
Merge pull request #3699 from mlibrary/HELIO-4731/edit_keywords_on_mo…
Browse files Browse the repository at this point in the history
…nographs

HELIO-4731 - enable keyword field storage on Monographs
  • Loading branch information
sethaj authored Oct 8, 2024
2 parents ccb9787 + 3ce2529 commit 190aabb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/forms/hyrax/monograph_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Hyrax
class MonographForm < Hyrax::Forms::WorkForm
self.model_class = ::Monograph
# Hyrax::BasicMetadata fields are already included
self.terms -= %i[keyword related_url source based_near rights_statement alternative_title abstract access_right
self.terms -= %i[related_url source based_near rights_statement alternative_title abstract access_right
rights_notes bibliographic_citation]
# these will hold their order, bearing in mind that required_fields are automatically removed first
self.terms += %i[press date_published creator_display series buy_url isbn doi hdl rightsholder open_access
Expand All @@ -30,6 +30,8 @@ class MonographForm < Hyrax::Forms::WorkForm
self.terms = self.terms.insert(self.terms.index(:hdl) + 1, :identifier)
self.terms.delete_at(self.terms.index(:license))
self.terms = self.terms.insert(self.terms.index(:rightsholder), :license)
self.terms.delete_at(self.terms.index(:keyword))
self.terms = self.terms.insert(self.terms.index(:subject) + 1, :keyword)

delegate :current_user, to: :current_ability

Expand Down
3 changes: 2 additions & 1 deletion app/views/hyrax/monographs/_attribute_rows.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= presenter.attribute_to_html(:press, label: t('publisher')) %>
<%= presenter.attribute_to_html(:description, render_as: :markdown) %>
<%= presenter.attribute_to_html(:subject, catalog_search_link: true) %>
<%= presenter.attribute_to_html(:subject) %>
<%= presenter.attribute_to_html(:keyword) %>
<%= presenter.attribute_to_html(:language) %>
<%= presenter.attribute_to_html(:section_titles) %>
<%= presenter.attribute_to_html(:buy_url, render_as: :markdown) %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ en:
press: "The monograph's publisher/press on Fulcrum."
previous_edition: "Full DOI (or other) URL pointing to the previous edition of the Monograph"
section_titles: "Used like a table of contents to indicate the order of attached FileSets' \"related sections\"."
subject: "Keywords which describe what this monograph is about."
subject: "Academic discipline(s) which relate to this monograph.<br/>Fulcrum does not enforce a controlled vocabulary but we recommend that each press maintain its own."
volume: "Monograph volume number if member of a multi-volume set - integer - greater than 0."
oclc_owi: "OCLC Work Identifier - NOT the OCLC Number - At least that is my interpretation."
copyright_year: "Copyright Year - YYYY - four digit year - greater than 1709."
Expand Down
2 changes: 1 addition & 1 deletion lib/metadata_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{ object: :monograph, field_name: 'Edition Name', metadata_name: 'edition_name', multivalued: :no, description: I18n.t('csv.descriptions.edition_name') },
{ object: :monograph, field_name: 'Previous Edition', metadata_name: 'previous_edition', multivalued: :no, description: I18n.t('csv.descriptions.previous_edition') },
{ object: :monograph, field_name: 'Next Edition', metadata_name: 'next_edition', multivalued: :no, description: I18n.t('csv.descriptions.next_edition') },
{ object: :file_set, field_name: 'Keywords', metadata_name: 'keyword', required: false, multivalued: :yes_split, description: I18n.t('csv.descriptions.keyword') },
{ object: :universal, field_name: 'Keywords', metadata_name: 'keyword', required: false, multivalued: :yes_split, description: I18n.t('csv.descriptions.keyword') },
{ object: :monograph, field_name: 'Section Titles', metadata_name: 'section_titles', required: false, multivalued: :no, description: I18n.t('csv.descriptions.section_titles') },
{ object: :file_set, field_name: 'Section', metadata_name: 'section_title', required: false, multivalued: :yes_split, description: I18n.t('csv.descriptions.section_title') },
{ object: :universal, field_name: 'Language', metadata_name: 'language', required: false, multivalued: :yes_split, description: I18n.t('csv.descriptions.language') },
Expand Down
9 changes: 9 additions & 0 deletions spec/features/create_monograph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
fill_in 'Description', with: 'Blahdy blah description works'
expect(page).to have_css('input.monograph_subject', count: 1)
fill_in 'Subject', with: 'red stuff'
expect(page).to have_css('input.monograph_keyword', count: 1)
fill_in 'Keywords', with: 'not a subject!'
expect(page).to have_css('input.monograph_language', count: 1)
fill_in 'Language', with: 'English'
fill_in 'Series', with: 'The Cereal Series'
Expand Down Expand Up @@ -133,6 +135,8 @@
fill_in 'Authorship Display (free-form text)', with: 'Fancy Authorship Name Stuff That Takes Precedence'
expect(page).to have_css('input.monograph_subject', count: 2)
page.all(:fillable_field, 'monograph[subject][]').last.set('green stuff')
expect(page).to have_css('input.monograph_keyword', count: 2)
page.all(:fillable_field, 'monograph[keyword][]').last.set('not a second subject!')
expect(page).to have_css('input.monograph_language', count: 2)
page.all(:fillable_field, 'monograph[language][]').last.set('German')
expect(page).to have_css('input.monograph_series', count: 2)
Expand All @@ -156,6 +160,8 @@
expect(page).to have_content 'The Second Series'
# Subject
expect(page).to have_content 'red stuff'
# Keywords - for now we're not actually going to show Monograph keywords on the catalog page
expect(page).not_to have_content 'not a subject!'
# ISBN
expect(page).to have_content '123-456-7890'
expect(page).to have_content '123-456-7891'
Expand Down Expand Up @@ -199,6 +205,9 @@
# subject
expect(page).to have_content 'red stuff'
expect(page).to have_content 'green stuff'
# keyword
expect(page).to have_content 'not a subject!'
expect(page).to have_content 'not a second subject!'
# language
expect(page).to have_content 'English'
expect(page).to have_content 'German'
Expand Down
2 changes: 2 additions & 0 deletions spec/forms/hyrax/monograph_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
publisher
date_created
subject
keyword
language
representative_id
thumbnail_id
Expand Down Expand Up @@ -90,6 +91,7 @@
contributor
creator_display
subject
keyword
language
series
buy_url
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/export/exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
let(:rows) { :monograph }
let(:expected) do
<<~eos
#{monograph.id},"=HYPERLINK(""#{Rails.application.routes.url_helpers.hyrax_monograph_url(monograph)}"")",#{monograph.date_uploaded},#{monograph.date_modified},#{monograph.title.first},,,,,,,,"First, Ms Joan (editor); Second, Mr Tom (editor); Third Author, Lady","Doe, Jane (illustrator); Joe, G.I.",,,,,,,,,,,,,,,,,https://doi.org/mpub.111111111.blah,,,,,,,,#{monograph.press},false,
#{monograph.id},"=HYPERLINK(""#{Rails.application.routes.url_helpers.hyrax_monograph_url(monograph)}"")",#{monograph.date_uploaded},#{monograph.date_modified},#{monograph.title.first},,,,,,,,"First, Ms Joan (editor); Second, Mr Tom (editor); Third Author, Lady","Doe, Jane (illustrator); Joe, G.I.",,,,,,,,,,,,,,,,,,https://doi.org/mpub.111111111.blah,,,,,,,,#{monograph.press},false,
eos
end

Expand Down

0 comments on commit 190aabb

Please sign in to comment.