Add visible checkbox to enterprises index page to allow bulk editing of visibility

This commit is contained in:
Rob H
2014-06-18 11:44:47 +10:00
parent 2e749ef1f3
commit 45b16d52dd
3 changed files with 20 additions and 2 deletions

View File

@@ -10,7 +10,8 @@ module Admin
def bulk_update
@enterprise_set = EnterpriseSet.new(params[:enterprise_set])
if @enterprise_set.save
redirect_to main_app.admin_enterprises_path, :notice => 'Distributor collection times updated.'
flash[:success] = 'Enterprises updated successfully'
redirect_to main_app.admin_enterprises_path
else
render :index
end

View File

@@ -36,7 +36,7 @@
Producer
- else
%h1.icon-exclamation-sign.with-tip{"data-powertip" => "This enterprise does not have any roles", style: "text-align: center;color: #DA5354"}
%td= enterprise.visible ? 'Visible' : 'Invisible'
%td= enterprise_form.check_box :visible
%td= enterprise.description
%td{"data-hook" => "admin_users_index_row_actions"}
= link_to_with_icon('icon-edit', 'Edit Profile', main_app.edit_admin_enterprise_path(enterprise), class: 'edit')

View File

@@ -33,6 +33,23 @@ feature %q{
end
end
scenario "editing enterprises in bulk" do
s = create(:supplier_enterprise)
d = create(:distributor_enterprise)
login_to_admin_section
click_link 'Enterprises'
within("tr.enterprise-#{d.id}") do
page.should have_field "enterprise_set_collection_attributes_0_visible", checked: true
uncheck "enterprise_set_collection_attributes_0_visible"
end
click_button "Update"
flash_message.should == 'Enterprises updated successfully'
distributor = Enterprise.find(d.id)
distributor.visible.should == false
end
scenario "viewing an enterprise" do
e = create(:enterprise)