AyuntamientoMadrid/participacion

View on GitHub
app/views/admin/poll/questions/show.html.erb

Summary

Maintainability
Test Coverage
<%= back_link_to admin_poll_path(@question.poll) %>

<% if can?(:update, @question) %>
  <%= link_to t("admin.questions.show.edit_question"), edit_admin_question_path(@question),
              class: "button hollow float-right" %>
<% end %>

<div class="clear"></div>

<div class="small-12 medium-6">
  <div class="callout highlight">
    <p>
      <strong><%= t("admin.questions.show.question") %></strong>
      <br>
      <%= @question.title %>
    </p>

    <p>
      <strong><%= t("admin.questions.show.author") %></strong>
      <br>
      <%= link_to @question.author.name, user_path(@question.author) %>
    </p>

    <% if @question.proposal.present? %>
      <p>
        <strong><%= t("admin.questions.show.proposal") %></strong>
        <br>
        <%= link_to @question.proposal.title, proposal_path(@question.proposal) %>
      </p>
    <% end %>

    <% if @question.votation_type.present? %>
      <p>
        <strong><%= t("admin.polls.votation_type.title") %></strong>
        <br>
        <%= VotationType.human_attribute_name("vote_type.#{@question.vote_type}") %>
      </p>
      <% if @question.max_votes.present? %>
        <p>
          <strong><%= VotationType.human_attribute_name("max_votes") %></strong>
          <br>
          <%= @question.max_votes %>
        </p>
      <% end %>
    <% end %>
  </div>
</div>

<div class="clear">
  <% if can?(:create, Poll::Question::Option.new(question: @question)) %>
    <%= link_to t("admin.questions.show.add_answer"), new_admin_question_option_path(@question),
                class: "button float-right" %>
  <% else %>
    <div class="callout warning">
      <strong><%= t("admin.questions.no_edit") %></strong>
    </div>
  <% end %>
</div>

<table class="margin-top">
  <caption><%= t("admin.questions.show.valid_answers") %></caption>
  <thead>
    <tr>
      <th><%= t("admin.questions.show.answers.title") %></th>
      <th scope="col" class="medium-7"><%= t("admin.questions.show.answers.description") %></th>
      <th scope="col" class="text-center"><%= t("admin.questions.show.answers.images") %></th>
      <th scope="col" class="text-center"><%= t("admin.questions.show.answers.documents") %></th>
      <th scope="col" class="text-center"><%= t("admin.questions.show.answers.videos") %></th>
      <th><%= t("admin.actions.actions") %></th>
    </tr>
  </thead>

  <tbody class="sortable" data-js-url="<%= admin_question_options_order_options_path(@question.id) %>">
    <% @question.question_options.each do |option| %>
      <tr id="<%= dom_id(option) %>" class="poll_question_option" data-option-id="<%= option.id %>">
        <td class="align-top"><%= option.title %></td>
        <td class="align-top break"><%= wysiwyg(option.description) %></td>
        <td class="align-top text-center">
          (<%= option.images.count %>)
          <br>
          <%= link_to t("admin.questions.show.answers.images_list"),
                      admin_option_images_path(option) %>
        </td>
        <td class="align-top text-center">
          (<%= option.documents.count rescue 0 %>)
          <br>
          <%= link_to t("admin.questions.show.answers.documents_list"),
                      admin_option_documents_path(option) %>
        </td>
        <td class="align-top text-center">
          (<%= option.videos.count %>)
          <br>
          <%= link_to t("admin.questions.show.answers.video_list"),
                      admin_option_videos_path(option) %>
        </td>
        <td>
          <%= render Admin::Poll::Questions::Options::TableActionsComponent.new(option) %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<% if @question.video_url.present? %>
  <p>
    <strong><%= t("admin.questions.show.video_url") %></strong>
    <br>
    <a href="<%= @question.video_url %>"><%= @question.video_url %></a>
  </p>
<% end %>