diff --git a/app/controllers/concerns/flag_actions.rb b/app/controllers/concerns/flag_actions.rb index cc305dca1..797b94778 100644 --- a/app/controllers/concerns/flag_actions.rb +++ b/app/controllers/concerns/flag_actions.rb @@ -18,6 +18,8 @@ module FlagActions def flaggable if resource_model.to_s == "Budget::Investment" instance_variable_get("@investment") + elsif resource_model.to_s == "Legislation::Proposal" + instance_variable_get("@proposal") else instance_variable_get("@#{resource_model.to_s.downcase}") end diff --git a/app/views/legislation/proposals/_flag_actions.html.erb b/app/views/legislation/proposals/_flag_actions.html.erb index 7bcb03205..6d86b63a2 100644 --- a/app/views/legislation/proposals/_flag_actions.html.erb +++ b/app/views/legislation/proposals/_flag_actions.html.erb @@ -1,21 +1,19 @@ - - - <% if show_flag_action? proposal %> - "> - - - - <%= link_to t("shared.flag"), flag_proposal_path(proposal), method: :put, remote: true, id: "flag-proposal-#{proposal.id}" %> - - <% end %> + + <% if show_flag_action? proposal %> + "> + + + + <%= link_to t("shared.flag"), flag_legislation_process_proposal_path(proposal.process, proposal), method: :put, remote: true, id: "flag-proposal-#{proposal.id}" %> + + <% end %> - <% if show_unflag_action? proposal %> - "> - - - - <%= link_to t("shared.unflag"), unflag_proposal_path(proposal), method: :put, remote: true, id: "unflag-proposal-#{proposal.id}" %> - - <% end %> - + <% if show_unflag_action? proposal %> + "> + + + + <%= link_to t("shared.unflag"), unflag_legislation_process_proposal_path(proposal.process, proposal), method: :put, remote: true, id: "unflag-proposal-#{proposal.id}" %> + + <% end %> diff --git a/app/views/legislation/proposals/_refresh_flag_actions.js.erb b/app/views/legislation/proposals/_refresh_flag_actions.js.erb index a8e4e0b7b..a9bbab7e3 100644 --- a/app/views/legislation/proposals/_refresh_flag_actions.js.erb +++ b/app/views/legislation/proposals/_refresh_flag_actions.js.erb @@ -1 +1 @@ -$("#<%= dom_id(@proposal) %> .js-flag-actions").html("<%= j render("proposals/flag_actions", proposal: @proposal) %>"); +App.Flaggable.update("<%= dom_id(@proposal) %>", "<%= j render("legislation/proposals/flag_actions", proposal: @proposal) %>"); diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index c581567c5..fd6c2280c 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -45,7 +45,9 @@ <% if current_user %>  •  - <%= render "proposals/flag_actions", proposal: @proposal %> + + <%= render "legislation/proposals/flag_actions", proposal: @proposal %> + <% end %> diff --git a/spec/system/legislation/proposals_spec.rb b/spec/system/legislation/proposals_spec.rb index 130d41d91..db773cf69 100644 --- a/spec/system/legislation/proposals_spec.rb +++ b/spec/system/legislation/proposals_spec.rb @@ -8,6 +8,7 @@ describe "Legislation Proposals" do context "Concerns" do it_behaves_like "notifiable in-app", :legislation_proposal + it_behaves_like "flaggable", :legislation_proposal end scenario "Only one menu element has 'active' CSS selector" do