<%= form_for(@editor) do |f| %>
<div class="form-group">
  <% if @editor.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@editor.errors.count, "error") %> prohibited this editor from being saved:</h2>

      <ul>
      <% @editor.errors.each do |error| %>
        <li><%= error.attribute.to_s.humanize %>: <%= error.message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
</div>

<div class="form-group">
  <div class="row">
    <div class="col">
      <%= f.label :kind, "Kind" %>
      <% if @editor.pending? %>
        <%= f.text_field :kind, disabled: true, class: "form-control" %>
      <% else %>
        <%= f.select :kind, %w(topic board emeritus), {}, class: "form-control" %>
      <% end %>
    </div>
    <div class="col">
      <%= f.label :max_assignments, "Max number of assignments" %>
      <%= f.text_field :max_assignments, class: "form-control" %>
    </div>
    <div class="col">
      <%= f.label :availability_comment, "Comment on availability" %>
      <%= f.text_field :availability_comment, class: "form-control" %>
    </div>
    <div class="col">
      <%= f.label :title %>
      <%= f.text_field :title, disabled: @editor.kind != "board", class: "form-control" %>
    </div>
  </div>
</div>

<div class="form-group">
  <div class="row">
    <div class="col">
      <%= f.label :first_name %>
      <%= f.text_field :first_name, class: "form-control" %>
    </div>

    <div class="col">
      <%= f.label :last_name %>
      <%= f.text_field :last_name, class: "form-control" %>
    </div>
  </div>
</div>

<div class="form-group">
  <div class="row">
    <div class="col">
      <%= f.label :login %>
      <% if @editor.pending? %>
        <%= f.text_field :login, disabled: true, class: "form-control" %>
      <% else %>
        <%= f.select :login, Repository.editors, { include_blank: true, selected: "@#{@editor.login}" }, class: "form-control" %>
      <% end %>
    </div>

    <div class="col">
      <%= f.label :buddy %>
      <%= f.select :buddy_id, Editor.active.sort_by(&:first_name).collect { |e| ["#{e.full_name} (@#{e.login})", e.id] }, { include_blank: true }, { class: "form-control" } %>
    </div>

    <div class="col">
      <%= f.label :email %>
      <%= f.text_field :email, class: "form-control" %>
    </div>
  </div>
</div>

<div class="form-group">
  <div class="row">
    <div class="col">
      <%= f.label :avatar_url %>
      <%= f.text_field :avatar_url, class: "form-control" %>
    </div>

    <div class="col">
      <%= f.label :category_list, "Categories (comma separated)" %>
      <%= f.text_field :category_list, placeholder: "e.g., machine learning, image analysis, object detection", class: "form-control" %>
    </div>
  </div>
</div>

<div class="form-group">
  <%= f.label :url %>
  <%= f.text_field :url, class: "form-control" %>
</div>

<% if JournalFeatures.tracks? %>
<div class="form-group">
  <%= f.label :tracks %>
  <div class="row">
    <div class="col">
      <%= f.collection_check_boxes(:track_ids, Track.all, :id, :name)  do |b|
            b.label(class: "label-container-check-box") { b.check_box(class: "form-check-inline") + b.text }
          end %>
    </div>
  </div>
</div>
<% end %>

<div class="form-group">
  <%= f.label :affiliation, "Affiliation (institution, city, country — displayed publicly on the about page)" %>
  <%= f.text_field :affiliation, placeholder: "e.g., University of Cambridge, Cambridge, UK", class: "form-control" %>
</div>

<div class="form-group">
  <%= f.label :description %>
  <%= f.text_area :description, rows: 4, class: "form-control" %>
</div>

<div class="form-actions">
  <%= f.submit class: "btn paper-submit" %>
</div>
<% end %>
