<%# Copied from decidim-consultation's _vote_button.html.erb %>
<% if question.consultation.upcoming? %>
<% elsif question.consultation.finished? && signed_in? && question.voted_by?(delegation.granter) %>
<%= button_to decidim_consultations.question_question_votes_path(question),
method: :delete,
remote: true,
data: { disable: true },
class: "button expanded success disabled delegation_unvote_button" do %>
<%= t("questions.vote_button.already_voted", scope: "decidim") %>
<% end %>
<% elsif signed_in? && question.consultation.active? %>
<% if allowed_to? :unvote_delegation, :question, { question: question, delegation: delegation }, [Decidim::ActionDelegator::Permissions, Decidim::Admin::Permissions, Decidim::Permissions] %>
<%= button_to decidim_consultations.question_question_votes_path(question),
method: :delete,
remote: true,
data: { disable: true },
class: "button expanded success delegation_unvote_button" do %>
<%= hidden_field_tag "decidim_consultations_delegation_id", delegation.id, id: "decidim_consultations_delegation_id_delete_#{delegation.id}" %>
"
data-replace="<%= t("questions.vote_button.already_voted_hover", scope: "decidim") %>">
<%= t("questions.vote_button.already_voted", scope: "decidim") %>
<% end %>
<% elsif allowed_to? :vote_delegation, :question, { question: question, delegation: delegation }, [Decidim::ActionDelegator::Permissions, Decidim::Admin::Permissions, Decidim::Permissions] %>
<% if question.multiple? %>
<%= link_to decidim_consultations.question_question_multiple_votes_path(question, delegation: delegation.id),
class: "button expanded",
id: "multivote_button" do %>
<%= t "questions.vote_button.vote", scope: "decidim" %>
<% end %>
<% else %>
<%# This link is slightly modified from _vote_button to add stuff needed by delegations %>
<%= link_to "#", class: "button expanded delegation-vote-button", data: { "delegation-id" => delegation.id, "delegation-granter-name" => delegation.granter.name } do %>
<%= t "questions.vote_button.vote", scope: "decidim" %>
<% end %>
<% end %>
<% else %>
<%= authorized_vote_modal_button(question, remote: true, class: "button expanded light button--sc") do %>
<%= t("questions.vote_button.verification_required", scope: "decidim") %>
<% end %>
<% end %>
<% elsif question.consultation.active? %>
<%= logged_button_to decidim_consultations.question_question_votes_path(question),
class: "button expanded",
data: { disable: true },
id: "vote_button" do %>
<%= t("questions.vote_button.vote", scope: "decidim") %>
<% end %>
<% end %>