Skip to content

Commit

Permalink
Don't show title on batch upload metadata tab
Browse files Browse the repository at this point in the history
Fixes #1795
  • Loading branch information
jcoyne committed Apr 8, 2016
1 parent 2dbe1a5 commit 27d5878
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 20 deletions.
12 changes: 12 additions & 0 deletions app/forms/sufia/batch_upload_form.rb
Expand Up @@ -3,6 +3,18 @@ class BatchUploadForm < Sufia::Forms::WorkForm
self.model_class = ::GenericWork
include HydraEditor::Form::Permissions

self.terms -= [:title]

# On the batch upload, title is set per-file.
def primary_terms
super - [:title]
end

# # On the batch upload, title is set per-file.
# def secondary_terms
# super - [:title]
# end

# Override of ActiveModel::Model name that allows us to use our
# custom name class
def self.model_name
Expand Down
17 changes: 11 additions & 6 deletions app/forms/sufia/forms/work_form.rb
Expand Up @@ -12,13 +12,18 @@ def [](key)
super
end

def primary_terms
[:title, :creator, :tag, :rights]
end

# Fields that are in rendered terms are automatically drawn on the page.
def rendered_terms
terms - [:files, :visibility_during_embargo, :embargo_release_date,
:visibility_after_embargo, :visibility_during_lease,
:lease_expiration_date, :visibility_after_lease, :visibility,
:thumbnail_id, :representative_id, :ordered_member_ids,
:collection_ids]
def secondary_terms
terms - primary_terms -
[:files, :visibility_during_embargo, :embargo_release_date,
:visibility_after_embargo, :visibility_during_lease,
:lease_expiration_date, :visibility_after_lease, :visibility,
:thumbnail_id, :representative_id, :ordered_member_ids,
:collection_ids]
end

def self.multiple?(term)
Expand Down
4 changes: 2 additions & 2 deletions app/views/curation_concerns/base/_form_metadata.html.erb
Expand Up @@ -6,7 +6,7 @@
</div>
</div>
<div class="base-terms">
<% [:title, :creator, :tag, :rights].each do |term| %>
<% f.object.primary_terms.each do |term| %>
<%= render_edit_field_partial(term, f: f) %>
<% end %>
</div>
Expand All @@ -19,7 +19,7 @@
'aria-controls'=> "extended-terms" %>
<div id="extended-terms" class='collapse'>
<%= render 'form_media', f: f %>
<% (f.object.rendered_terms - [:title, :creator, :tag, :rights]).each do |term| %>
<% f.object.secondary_terms.each do |term| %>
<%= render_edit_field_partial(term, f: f) %>
<% end %>
</div>
Expand Down
4 changes: 3 additions & 1 deletion app/views/curation_concerns/base/_form_progress.html.erb
Expand Up @@ -34,7 +34,9 @@
Deposit Agreement
<% end %>
<br>
<%= link_to t(:'helpers.action.cancel'), :back, class: 'btn btn-default' %>
<%= link_to t(:'helpers.action.cancel'),
sufia.dashboard_index_path,
class: 'btn btn-default' %>
<%= f.submit 'Save', class: 'btn btn-primary', onclick: "confirmation_needed = false;", id: "with_files_submit", name: "save_with_files" %>
</div>
</div>
Expand Down
12 changes: 9 additions & 3 deletions spec/forms/curation_concerns/work_form_spec.rb
Expand Up @@ -3,9 +3,15 @@
describe CurationConcerns::GenericWorkForm do
let(:form) { described_class.new(GenericWork.new, nil) }

describe "#rendered_terms" do
subject { form.rendered_terms }
it { is_expected.not_to include(:visibilty, :visibility_during_embargo,
describe "#primary_terms" do
subject { form.primary_terms }
it { is_expected.to eq [:title, :creator, :tag, :rights] }
end

describe "#secondary_terms" do
subject { form.secondary_terms }
it { is_expected.not_to include(:title, :creator, :tag, :rights,
:visibilty, :visibility_during_embargo,
:embargo_release_date, :visibility_after_embargo,
:visibility_during_lease, :lease_expiration_date,
:visibility_after_lease, :collection_ids) }
Expand Down
15 changes: 13 additions & 2 deletions spec/forms/sufia/batch_upload_form_spec.rb
Expand Up @@ -6,6 +6,18 @@
let(:ability) { Ability.new(user) }
let(:user) { build(:user, display_name: 'Jill Z. User') }

describe "#primary_terms" do
subject { form.primary_terms }
it { is_expected.to eq [:creator, :tag, :rights] }
end

describe "#secondary_terms" do
subject { form.primary_terms }
it "doesn't have title" do
expect(subject).not_to include(:title)
end
end

describe ".model_name" do
subject { described_class.model_name }
it "has a route_key" do
Expand All @@ -28,8 +40,7 @@

describe "#terms" do
subject { form.terms }
it { is_expected.to eq [:title,
:creator,
it { is_expected.to eq [:creator,
:contributor,
:description,
:tag,
Expand Down
4 changes: 2 additions & 2 deletions spec/views/curation_concerns/base/_form.html.erb_spec.rb
Expand Up @@ -52,11 +52,11 @@
end

it "doesn't have switch to Batch Upload link" do
expect(page).not_to have_link('Batch upload')
expect(page).not_to have_link('Batch upload', href: '/batch_uploads')
end

it "renders the link for the Cancel button" do
expect(page).to have_link("Cancel", "/")
expect(page).to have_link("Cancel", href: "/dashboard")
end
end
end
8 changes: 4 additions & 4 deletions spec/views/sufia/batch_uploads/_form.html.erb_spec.rb
Expand Up @@ -12,7 +12,6 @@
allow(view).to receive(:curation_concern).and_return(work)
allow(controller).to receive(:current_user).and_return(stub_model(User))
assign(:form, form)
# stub_template 'sufia/batch_uploads/_form_files.html.erb' => 'files_form'
end

let(:page) do
Expand All @@ -22,9 +21,10 @@

it "draws the page" do
expect(page).to have_selector("form[action='/batch_uploads']")
expect(page).to have_selector("input#generic_work_title")
expect(page).to have_link("New Work", "/concern/generic_works/new")
expect(page).to have_link("Cancel", "/")
# No title, because it's captured per file (e.g. Display label)
expect(page).not_to have_selector("input#generic_work_title")
expect(page).to have_link("New Work", href: "/concern/generic_works/new")
expect(page).to have_link("Cancel", href: "/dashboard")
expect(rendered).to match(/Display label/)
end
end

0 comments on commit 27d5878

Please sign in to comment.