<%= link_to admin_spending_proposal_path(@spending_proposal, SpendingProposal.filter_params(params)), class: 'back' do %>
  <span class="icon-angle-left"></span> <%= t("admin.spending_proposals.show.back") %>
<% end %>

<%= form_for @spending_proposal,
             url: admin_spending_proposal_path(@spending_proposal) do |f| %>

  <% SpendingProposal.filter_params(params).each do |filter_name, filter_value| %>
   <%= hidden_field_tag filter_name, filter_value %>
  <% end %>

  <div class="row">
    <div class="small-12 column">
      <%= f.text_field :title, maxlength: SpendingProposal.title_max_length %>
    </div>

    <div class="ckeditor small-12 column">
      <%= f.cktext_area :description, maxlength: SpendingProposal.description_max_length, ckeditor: { language: I18n.locale } %>
    </div>

    <div class="small-12 column">
      <%= f.text_field :external_url %>
    </div>

    <div class="small-12 column">
      <%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %>
    </div>

    <div class="small-12 column">
      <%= f.text_field :association_name, placeholder: t("spending_proposals.form.association_name") %>
    </div>
  </div>

  <h2 id="classification"><%= t("admin.spending_proposals.edit.classification") %></h2>

  <div class="row">

    <div class="small-12 column">
      <%= f.select(:administrator_id,
                     @admins.collect{ |a| [a.name_and_email, a.id ] },
                     { include_blank: t("admin.spending_proposals.edit.undefined") }) %>
    </div>


    <div class="small-12 column">
      <%= f.label :tag_list, t("admin.spending_proposals.edit.tags") %>
      <div class="tags">
        <% @tags.each do |tag| %>
          <a class="js-add-tag-link"><%= tag.name %></a>
        <% end %>
      </div>
      <%= f.text_field :tag_list, value: @spending_proposal.tag_list.to_s,
                        label: false,
                        placeholder: t("admin.spending_proposals.edit.tags_placeholder"),
                        class: 'js-tag-list' %>
    </div>

    <div class="small-12 column">
      <%= f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %>

      <%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
          <%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
      <% end %>
    </div>
  </div>

  <p class="clear">
    <%= f.submit(class: "button", value: t("admin.spending_proposals.edit.submit_button")) %>
  </p>
<% end %>

<hr>
<%= render 'valuation/spending_proposals/written_by_valuators' %>
