AyuntamientoMadrid/participacion

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

Summary

Maintainability
Test Coverage
<div class="supports">

  <span class="total-supports <%= "no-button" unless voting_allowed? || user_voted_for? %>">
    <%= t("budgets.investments.investment.supports", count: investment.total_votes) %>
  </span>

  <div class="in-favor">
    <% if investment.should_show_votes? %>
      <% if user_voted_for? %>
        <div class="supported">
          <div class="callout success">
            <%= t("budgets.investments.votes.already_supported") %>
          </div>
          <% if feature?(:remove_investments_supports) %>
            <%= button_to t("budgets.investments.votes.remove_support"),
                          remove_support_path,
                          class: "button button-remove-support expanded",
                          method: "delete",
                          remote: true,
                          "aria-label": remove_support_aria_label %>
          <% end %>
        </div>
      <% else %>
        <%= button_to t("budgets.investments.votes.support"), support_path,
                      class: "button button-support expanded",
                      title: t("budgets.investments.investment.support_title"),
                      method: "post",
                      remote: !display_support_alert?,
                      data: ({ confirm: confirm_vote_message } if display_support_alert?),
                      "aria-label": support_aria_label %>
      <% end %>
    <% end %>
  </div>

  <%= render Shared::ParticipationNotAllowedComponent.new(investment, cannot_vote_text: cannot_vote_text) %>

  <% if user_voted_for? && setting["twitter_handle"] %>
    <div class="share-supported">
      <%= render "shared/social_share",
                 title: investment.title,
                 image_url: image_absolute_url(investment.image, :thumb),
                 url: budget_investment_url(investment.budget, investment),
                 description: investment.title,
                 mobile: investment.title %>
    </div>
  <% end %>
</div>