<div class="tracks">
  <div class="content">
    <h1>Removing <%= @track.label %></h1>

    <%= form_for @track, method: :delete do |f| %>

    <div class="form-group">
      <% if @track.errors.any? %>
        <div class="alert alert-danger %>">
          <p><strong>Track could not be deleted.</strong></p>
          <ul>
          <% @track.errors.each do |error| -%>
            <li><%= error.message %></li>
          <% end -%>
          </ul>
        </div>
      <% end %>
    </div>

    <div class="form-group">
      <div class="row">
        <div class="col">
          Your are going to delete the track: <strong><%= @track.name %></strong>
        </div>
      </div>
    </div>

    <div class="form-group">
      <div class="row">
        <div class="col">
          <strong>Papers in this track: </strong>
          <%= link_to "In-progress", dashboard_in_progress_path(track_id: @track) %>:
          <strong><%= @in_progress_papers %></strong>,
          Total:
          <strong><%= @assigned_papers %></strong>
        </div>
      </div>
    </div>

    <% if @assigned_papers > 0 %>
    <div class="form-group">
      <div class="row">
        <div class="col"><strong>All the papers in this track will be reassigned to:</strong></div>
      </div>
      <div class="row">
        <div class="col">
          <%= select_tag :new_track_id, options_from_collection_for_select(@other_tracks, :id, :name), prompt: "Select track",  class: "form-control", style: "margin-right: 12px;" %>
        </div>
        <div class="col"></div>
      </div>
    </div>
    <% end %>

    <% unless @editors.empty? %>
    <div class="form-group">
      <div class="row">
        <div class="col"><strong>Editors currently assigned to this track:</strong></div>
      </div>
      <div class="row">
        <div class="col">
          <table>
          <% @editors.each do |e| %>
            <tr><td><%= e.full_name %></td></tr>
          <% end %>
        </table>
        </div>
        <div class="col"></div>
      </div>
    </div>
    <% end %>

    <% unless @subjects.empty? %>
    <div class="form-group">
      <div class="row">
        <div class="col"><strong>All these subjects will be deleted:</strong></div>
      </div>
      <div class="row">
        <div class="col">
          <table>
          <% @subjects.in_groups_of(2).each do |subject_pair| %>
            <tr>
              <% subject_pair.each do |subject| %>
              <td><%= subject.name if subject %></td>
              <% end %>
            </tr>
          <% end %>
        </table>
        </div>
      </div>
    </div>
    <% end %>


    <div class="form-actions">
      <%= f.submit "Reassign papers and Delete track", class: "btn btn-danger" %>
    </div>
    <% end %>


    <div class="links">
      <%= link_to 'Show', @track %> |
      <%= link_to 'Edit', edit_track_path(@track) %> |
      <%= link_to 'List', tracks_path %>
    </div>
  </div>
</div>
