<% provide :title do %>
  <%= t("admin.header.title") %> - <%= t("admin.menu.legislation") %> - <%= @process.title %> - <%= t("admin.legislation.questions.index.title") %>
<% end %>

<div class="legislation-draft-versions-index">
  <%= back_link_to admin_legislation_processes_path, t("admin.legislation.questions.index.back") %>

  <h2><%= @process.title %></h2>

  <%= render "admin/legislation/processes/subnav", process: @process, active: "questions" %>

  <div class="small-12 column">
    <h4 class="inline-block"><%= t("admin.legislation.questions.index.title") %></h4>

    <div class="float-right">
      <%= link_to t("admin.legislation.questions.index.create"), new_admin_legislation_process_question_path, class: "button" %>
    </div>

    <% if @process.questions.any? %>
      <table class="stack">
       <thead>
          <tr>
            <th><%= t("admin.legislation.questions.table.title") %></th>
            <th><%= t("admin.legislation.questions.table.question_options") %></th>
            <th class="text-center"><%= t("admin.legislation.questions.table.answers_count") %></th>
            <th class="text-center"><%= t("admin.legislation.questions.table.comments_count") %></th>
          </tr>
        </thead>
        <tbody>
        <% @process.questions.each do |question| %>
          <tr id="<%= dom_id(question) %>">
            <td>
              <%= link_to question.title, edit_admin_legislation_process_question_path(@process, question) %>
            </td>
            <td>
              <ul>
                <% question.question_options.each do |question_option| %>
                  <li><%= "#{question_option.value} (#{question_option.answers_count})" %></li>
                <% end %>
              </ul>
            </td>
            <td class="text-center"><%= question.answers_count %></td>
            <td class="text-center"><%= link_to question.comments.count, legislation_process_question_path(@process, question, anchor: "comments") %></td>
          </tr>
        <% end %>
        </tbody>
      </table>
    <% end %>
  </div>
</div>
