Fix legislation proposals flag actions
We were treating legislation proposals as if they were proposals, omitting the "legislation" namespace, and so we were flagging/unflagging proposals when we wanted to flag/unflag a legislation proposal.
This commit is contained in:
@@ -18,6 +18,8 @@ module FlagActions
|
|||||||
def flaggable
|
def flaggable
|
||||||
if resource_model.to_s == "Budget::Investment"
|
if resource_model.to_s == "Budget::Investment"
|
||||||
instance_variable_get("@investment")
|
instance_variable_get("@investment")
|
||||||
|
elsif resource_model.to_s == "Legislation::Proposal"
|
||||||
|
instance_variable_get("@proposal")
|
||||||
else
|
else
|
||||||
instance_variable_get("@#{resource_model.to_s.downcase}")
|
instance_variable_get("@#{resource_model.to_s.downcase}")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
<span class="js-flag-actions">
|
<span class="flag-content">
|
||||||
<span class="flag-content">
|
<% if show_flag_action? proposal %>
|
||||||
<% if show_flag_action? proposal %>
|
<a id="flag-expand-proposal-<%= proposal.id %>" data-toggle="flag-drop-proposal-<%= proposal.id %>" title="<%= t("shared.flag") %>">
|
||||||
<a id="flag-expand-proposal-<%= proposal.id %>" data-toggle="flag-drop-proposal-<%= proposal.id %>" title="<%= t("shared.flag") %>">
|
<span class="icon-flag flag-disable"></span>
|
||||||
<span class="icon-flag flag-disable"></span>
|
</a>
|
||||||
</a>
|
<span class="dropdown-pane" id="flag-drop-proposal-<%= proposal.id %>" data-dropdown data-auto-focus="true">
|
||||||
<span class="dropdown-pane" id="flag-drop-proposal-<%= proposal.id %>" data-dropdown data-auto-focus="true">
|
<%= link_to t("shared.flag"), flag_legislation_process_proposal_path(proposal.process, proposal), method: :put, remote: true, id: "flag-proposal-#{proposal.id}" %>
|
||||||
<%= link_to t("shared.flag"), flag_proposal_path(proposal), method: :put, remote: true, id: "flag-proposal-#{proposal.id}" %>
|
</span>
|
||||||
</span>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if show_unflag_action? proposal %>
|
<% if show_unflag_action? proposal %>
|
||||||
<a id="unflag-expand-proposal-<%= proposal.id %>" data-toggle="unflag-drop-proposal-<%= proposal.id %>" title="<%= t("shared.unflag") %>">
|
<a id="unflag-expand-proposal-<%= proposal.id %>" data-toggle="unflag-drop-proposal-<%= proposal.id %>" title="<%= t("shared.unflag") %>">
|
||||||
<span class="icon-flag flag-active"></span>
|
<span class="icon-flag flag-active"></span>
|
||||||
</a>
|
</a>
|
||||||
<span class="dropdown-pane" id="unflag-drop-proposal-<%= proposal.id %>" data-dropdown data-auto-focus="true">
|
<span class="dropdown-pane" id="unflag-drop-proposal-<%= proposal.id %>" data-dropdown data-auto-focus="true">
|
||||||
<%= link_to t("shared.unflag"), unflag_proposal_path(proposal), method: :put, remote: true, id: "unflag-proposal-#{proposal.id}" %>
|
<%= link_to t("shared.unflag"), unflag_legislation_process_proposal_path(proposal.process, proposal), method: :put, remote: true, id: "unflag-proposal-#{proposal.id}" %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -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) %>");
|
||||||
|
|||||||
@@ -45,7 +45,9 @@
|
|||||||
|
|
||||||
<% if current_user %>
|
<% if current_user %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= render "proposals/flag_actions", proposal: @proposal %>
|
<span class="js-flag-actions">
|
||||||
|
<%= render "legislation/proposals/flag_actions", proposal: @proposal %>
|
||||||
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ describe "Legislation Proposals" do
|
|||||||
|
|
||||||
context "Concerns" do
|
context "Concerns" do
|
||||||
it_behaves_like "notifiable in-app", :legislation_proposal
|
it_behaves_like "notifiable in-app", :legislation_proposal
|
||||||
|
it_behaves_like "flaggable", :legislation_proposal
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Only one menu element has 'active' CSS selector" do
|
scenario "Only one menu element has 'active' CSS selector" do
|
||||||
|
|||||||
Reference in New Issue
Block a user