AyuntamientoMadrid/participacion

View on GitHub
app/components/budgets/investments/ballot_component.html.erb

Summary

Maintainability
Test Coverage
<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>