Move logic from view to helper
This commit is contained in:
@@ -10,4 +10,20 @@ module LegislationHelper
|
||||
def new_legislation_proposal_link_text(process)
|
||||
t("proposals.index.start_proposal")
|
||||
end
|
||||
|
||||
def link_to_toggle_legislation_proposal_selection(proposal)
|
||||
if proposal.selected?
|
||||
button_text = t("admin.legislation.proposals.index.selected")
|
||||
html_class = 'button expanded'
|
||||
else
|
||||
button_text = t("admin.legislation.proposals.index.select")
|
||||
html_class = 'button hollow expanded'
|
||||
end
|
||||
|
||||
link_to button_text,
|
||||
toggle_selection_admin_legislation_process_proposal_path(proposal.process, proposal),
|
||||
remote: true,
|
||||
method: :patch,
|
||||
class: html_class
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1 @@
|
||||
<% if proposal.selected?
|
||||
button_text = t("admin.legislation.proposals.index.selected")
|
||||
clas = 'button expanded'
|
||||
else
|
||||
button_text = t("admin.legislation.proposals.index.select")
|
||||
clas = 'button hollow expanded'
|
||||
end %>
|
||||
|
||||
<%= link_to button_text,
|
||||
toggle_selection_admin_legislation_process_proposal_path(proposal.process, proposal),
|
||||
remote: true,
|
||||
method: :patch,
|
||||
class: clas %>
|
||||
<%= link_to_toggle_legislation_proposal_selection(proposal) %>
|
||||
|
||||
Reference in New Issue
Block a user