Files
grecia/app/components/budgets/investments/ballot_component.html.erb
Javi Martín f384451d9f Always generate <button> tags with button_to
In Rails 6.1 and earlier, `button_to` generated a <button> tag when it
received the content as a block, but an <input> tag when receiving
the content as the first parameter.

That's why we were using blocks with `button_to` most of the time; for
starters, <button> tags accept pseudocontent and so are easier to style.

In Rails 7.0, `button_to` always generates a <button> tag [1], so we're
simplifying the code what uses `button_to`, passing the content as a
first parameter instead of passing it as a block.

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-action-view-button-to-generates-button-tag
2024-04-15 15:39:28 +02:00

46 lines
1.9 KiB
Plaintext

<div class="supports ballot">
<% if voted? %>
<div class="remove supported">
<span class="icon-check-circle"
title="<%= t("budgets.investments.investment.already_added") %>">
</span>
<% if investment.should_show_price? %>
<p class="investment-project-amount">
<%= investment.formatted_price %>
</p>
<% end %>
<% if investment.should_show_ballots? %>
<%= button_to t("budgets.ballots.show.remove"),
budget_ballot_line_path(id: investment.id,
budget_id: investment.budget_id,
investments_ids: investment_ids),
class: "button button-remove-support expanded",
method: :delete,
remote: true,
"aria-label": remove_vote_aria_label %>
<% end %>
</div>
<% else %>
<div class="add in-favor">
<% if investment.should_show_price? %>
<p class="investment-project-amount">
<%= investment.formatted_price %>
</p>
<% end %>
<% if investment.should_show_ballots? %>
<%= button_to t("budgets.investments.investment.add"),
budget_ballot_lines_path(investment_id: investment.id,
budget_id: investment.budget_id,
investments_ids: investment_ids),
class: "button button-support expanded",
title: t("budgets.investments.investment.support_title"),
method: :post,
remote: true,
"aria-label": vote_aria_label %>
<% end %>
</div>
<% end %>
<%= render Shared::ParticipationNotAllowedComponent.new(investment, cannot_vote_text: cannot_vote_text) %>
</div>