% if proposal.rejected? || proposal.withdrawn? %>
<% else %>
<% if component_settings.participatory_texts_enabled? && from_proposals_list %>
<%= render partial: "decidim/proposals/proposals/participatory_texts/proposal_vote_button", locals: { proposal: proposal, from_proposals_list: true } %>
<% else %>
<% if !current_user %>
<% if current_settings.votes_blocked? %>
<%= action_authorized_button_to :vote, t("decidim.proposals.proposals.vote_button.votes_blocked"), proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list: from_proposals_list), resource: proposal, class: "button #{vote_button_classes(from_proposals_list)} disabled", disabled: true %>
<% else %>
<%= action_authorized_button_to :vote, proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list: from_proposals_list), resource: proposal, class: "button #{vote_button_classes(from_proposals_list)}", data: { disable: true, "redirect-url": proposal_path(proposal) } do %>
<%= t("decidim.proposals.proposals.vote_button.vote") %>
<%= decidim_html_escape(present(proposal).title) %>
<% end %>
<% end %>
<% else %>
<% if @voted_proposals ? @voted_proposals.include?(proposal.id) : proposal.voted_by?(current_user) %>
<%= action_authorized_button_to(
:vote,
proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list: from_proposals_list),
resource: proposal,
method: :delete,
remote: true,
data: {
disable: true,
original: t("decidim.proposals.proposals.vote_button.already_voted"),
replace: t("decidim.proposals.proposals.vote_button.already_voted_hover"),
"redirect-url": proposal_path(proposal)
},
class: "button #{vote_button_classes(from_proposals_list)} active light",
id: "vote_button-#{proposal.id}"
) do %>
<%= icon("check", class: "icon--small") %>
<%= t("decidim.proposals.proposals.vote_button.already_voted") %>
<%= decidim_html_escape(present(proposal).title) %>
<% end %>
<% else %>
<% if proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
<%= content_tag :button, t("decidim.proposals.proposals.vote_button.maximum_votes_reached"), class: "button #{vote_button_classes(from_proposals_list)} disabled", disabled: true %>
<% else %>
<% if vote_limit_enabled? && remaining_votes_count_for(current_user) == 0 %>
<%= content_tag :button, t("decidim.proposals.proposals.vote_button.no_votes_remaining"), class: "button #{vote_button_classes(from_proposals_list)}", disabled: true %>
<% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %>
<%= content_tag :button, t("decidim.proposals.proposals.vote_button.votes_blocked"), class: "button #{vote_button_classes(from_proposals_list)} disabled", disabled: true %>
<% else %>
<%= action_authorized_button_to :vote, proposal_proposal_vote_path(proposal_id: proposal, from_proposals_list: from_proposals_list), resource: proposal, remote: true, data: { disable: true, "redirect-url": proposal_path(proposal) }, class: "button #{vote_button_classes(from_proposals_list)}" do %>
<%= t("decidim.proposals.proposals.vote_button.vote") %>
<%= decidim_html_escape(present(proposal).title) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>