This repository has been archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Geographic Origin as a dropdown.
- Loading branch information
1 parent
d082463
commit 71c5157
Showing
6 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% authority = AuthorityFinder.for(property: key, model: f.object) %> | ||
<% if authority %> | ||
<% options = Hyrax::QaSelectService.new(authority.subauthority_name) %> | ||
<%= f.input key, | ||
collection: options.select_active_options, | ||
include_blank: true, | ||
input_html: { class: 'form-control', multiple: f.object.multiple?(key) } %> | ||
<% else %> | ||
<%= render "records/edit_fields/default", f: f, key: key%> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render "controlled_field", key: key, f: f %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
<% authority = AuthorityFinder.for(property: key, model: f.object) %> | ||
<% if authority %> | ||
<% languages = Hyrax::QaSelectService.new(authority.subauthority_name) %> | ||
<%= f.input :language, | ||
collection: languages.select_active_options, | ||
include_blank: true, | ||
input_html: { class: 'form-control', multiple: f.object.multiple?(key) } %> | ||
<% else %> | ||
<%= render "records/edit_fields/default", f: f, key: key%> | ||
<% end %> | ||
<%= render "controlled_field", key: key, f: f %> |
37 changes: 37 additions & 0 deletions
37
spec/views/records/edit_fields/_geographic_origin.html.erb_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'rails_helper' | ||
include SimpleForm::ActionViewExtensions::FormHelper | ||
|
||
RSpec.describe 'records/edit_fields/_geographic_origin.html.erb' do | ||
let(:vocabulary) { nil } | ||
let(:vocabulary_label) { "Geographic Origin" } | ||
before do | ||
Qa::Authorities::Local.registry.instance_variable_get(:@hash).delete(vocabulary_label) | ||
allow(view).to receive(:f).and_return(simple_form_for(form)) | ||
allow(view).to receive(:key).and_return(:geographic_origin) | ||
vocabulary | ||
render | ||
end | ||
after do | ||
Qa::Authorities::Local.registry.instance_variable_get(:@hash).delete(vocabulary_label) | ||
end | ||
|
||
context 'with an ephemera folder' do | ||
let(:form) { Hyrax::EphemeraFolderForm.new(EphemeraFolder.new, nil, nil) } | ||
context "when there is no language vocabulary" do | ||
it "doesn't create a select box" do | ||
expect(rendered).not_to have_selector "select" | ||
end | ||
end | ||
context "when there is a language vocabulary" do | ||
let(:vocabulary) do | ||
Vocabulary.create!(label: vocabulary_label).tap do |vocab| | ||
VocabularyTerm.create!(vocabulary: vocab, label: "Ireland") | ||
VocabularyTerm.create!(vocabulary: vocab, label: "Japan") | ||
end | ||
end | ||
it "creates a select box" do | ||
expect(rendered).to have_select("Geographic origin", options: ['', 'Ireland', 'Japan']) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters