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])
|
@proposals = @proposals.send("sort_by_#{@current_order}").page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def toggle_selection
|
||||||
@proposal.selected = !@proposal.selected
|
@proposal.toggle :selected
|
||||||
|
@proposal.save!
|
||||||
if @proposal.save
|
redirect_to admin_legislation_process_proposals_path,
|
||||||
notice = t('admin.legislation.proposals.update.notice')
|
notice: t('admin.legislation.proposals.update.notice')
|
||||||
else
|
|
||||||
notice = t('admin.legislation.proposals.update.error')
|
|
||||||
end
|
end
|
||||||
redirect_to admin_legislation_process_proposals_path, notice: notice
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -5,4 +5,8 @@
|
|||||||
button_text = t("admin.legislation.proposals.index.select")
|
button_text = t("admin.legislation.proposals.index.select")
|
||||||
clas = 'button hollow expanded'
|
clas = 'button hollow expanded'
|
||||||
end %>
|
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
|
namespace :legislation do
|
||||||
resources :processes do
|
resources :processes do
|
||||||
resources :questions
|
resources :questions
|
||||||
resources :proposals
|
resources :proposals do
|
||||||
|
member { patch :toggle_selection }
|
||||||
|
end
|
||||||
resources :draft_versions
|
resources :draft_versions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user