Use toggle_select action for legislation proposals
The `update` action is usually expected to behave the same way it does everywhere else, which is updating a record using the `params` hash. The name `toggle_select` comes from the name we use in a similar situation for budget investments.
This commit is contained in:
@@ -9,15 +9,10 @@ class Admin::Legislation::ProposalsController < Admin::Legislation::BaseControll
|
||||
@proposals = @proposals.send("sort_by_#{@current_order}").page(params[:page])
|
||||
end
|
||||
|
||||
def update
|
||||
@proposal.selected = !@proposal.selected
|
||||
|
||||
if @proposal.save
|
||||
notice = t('admin.legislation.proposals.update.notice')
|
||||
else
|
||||
notice = t('admin.legislation.proposals.update.error')
|
||||
def toggle_selection
|
||||
@proposal.toggle :selected
|
||||
@proposal.save!
|
||||
redirect_to admin_legislation_process_proposals_path,
|
||||
notice: t('admin.legislation.proposals.update.notice')
|
||||
end
|
||||
redirect_to admin_legislation_process_proposals_path, notice: notice
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5,4 +5,8 @@
|
||||
button_text = t("admin.legislation.proposals.index.select")
|
||||
clas = 'button hollow expanded'
|
||||
end %>
|
||||
<%= link_to button_text, admin_legislation_process_proposal_path(proposal.process, proposal), method: 'PUT', class: clas %>
|
||||
|
||||
<%= link_to button_text,
|
||||
toggle_selection_admin_legislation_process_proposal_path(proposal.process, proposal),
|
||||
method: :patch,
|
||||
class: clas %>
|
||||
|
||||
@@ -194,7 +194,9 @@ namespace :admin do
|
||||
namespace :legislation do
|
||||
resources :processes do
|
||||
resources :questions
|
||||
resources :proposals
|
||||
resources :proposals do
|
||||
member { patch :toggle_selection }
|
||||
end
|
||||
resources :draft_versions
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user