Skip to content

Commit

Permalink
for admin_set don't allow title to be editable.
Browse files Browse the repository at this point in the history
  • Loading branch information
blancoj authored and elrayle committed Oct 11, 2017
1 parent d8efb0c commit 3f815e9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 7 deletions.
20 changes: 15 additions & 5 deletions app/views/hyrax/admin/collection_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@
<% form_url = @form.id.nil? ? hyrax.admin_collection_types_path : hyrax.admin_collection_type_path(@form.id) %>
<%= simple_form_for @form, url: form_url, as: :collection_type do |f| %>
<div class="tab-content">
<div id="metadata" class="tab-pane active">
<div class="panel panel-default labels">
<div class="panel-body">
<%= render 'form_metadata', f: f %>
<% if @collection_type.admin_set? %>
<div id="metadata" class="tab-pane active">
<div class="panel panel-default labels">
<div class="panel-body">
<%= render 'form_metadata_admin_set', f: f %>
</div>
</div>
</div>
</div>
<% else %>
<div id="metadata" class="tab-pane active">
<div class="panel panel-default labels">
<div class="panel-body">
<%= render 'form_metadata', f: f %>
</div>
</div>
</div>
<% end %>
<div id="settings" class="tab-pane">
<div class="panel panel-default labels">
<div class="panel-body">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= f.input :title, :input_html => { :disabled => true } %>
<%= f.input :description, as: :text %>
2 changes: 1 addition & 1 deletion app/views/hyrax/admin/collection_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<tr>
<td><%= collection_type.title %></td>
<td>
<%= link_to hyrax.edit_admin_collection_type_path(collection_type), class: 'btn btn-primary btn-sm' do %>
<%= link_to hyrax.edit_admin_collection_type_path(collection_type), class: 'btn btn-primary btn-sm', data: { turbolinks: false } do %>
<%= t('helpers.action.edit') %>
<% end %>
<% unless collection_type.admin_set? || collection_type.user_collection? %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
RSpec.describe 'hyrax/admin/collection_types/_form.html.erb', type: :view do
let(:collection_type) { build(:collection_type) }
# let(:collection_type) { build(:collection_type, machine_id: "type_does_not_matter") }
let(:form) { Hyrax::Forms::Admin::CollectionTypeForm.new(collection_type: collection_type) }

before do
assign(:form, form)
assign(:collection_type, collection_type)
end

it "has 3 tabs" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe 'hyrax/admin/collection_types/_form_metadata.html.erb', type: :view do
let(:collection_type) { Hyrax::CollectionType.new }
let(:collection_type) { create(:collection_type) }
let(:collection_type_form) { Hyrax::Forms::Admin::CollectionTypeForm.new }

let(:form) do
Expand All @@ -17,6 +17,7 @@
it "renders the name field" do
expect(rendered).to have_content(I18n.t("simple_form.labels.collection_type.title"))
expect(rendered).to have_selector("input#collection_type_title")
expect(rendered).not_to have_css("#collection_type_title[disabled]")
end

it "renders the description field" do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
RSpec.describe 'hyrax/admin/collection_types/_form_metadata_admin_set.html.erb', type: :view do
let(:collection_type) { create(:admin_set_collection_type) }
let(:collection_type_form) { Hyrax::Forms::Admin::CollectionTypeForm.new }

let(:form) do
view.simple_form_for(collection_type, url: '/update') do |fs_form|
return fs_form
end
end

before do
assign(:form, collection_type_form)
allow(view).to receive(:f).and_return(form)
render
end

it "renders the name field as readonly" do
expect(rendered).to have_content(I18n.t("simple_form.labels.collection_type.title"))
expect(rendered).to have_selector("input#collection_type_title")
expect(rendered).to have_css("#collection_type_title[disabled]")
end

it "renders the description field" do
expect(rendered).to have_content(I18n.t("simple_form.labels.collection_type.description"))
expect(rendered).to have_selector("textarea#collection_type_description")
end
end

0 comments on commit 3f815e9

Please sign in to comment.