<% admin_breadcrumb(link_to plural_resource_name(Spree::Product), spree.admin_products_path) %>
<% admin_breadcrumb(link_to plural_resource_name(Spree::OptionType), spree.admin_option_types_path) %>
<% admin_breadcrumb(@option_type.name) %>

<% content_for :page_actions do %>
  <li>
    <span id="new_add_option_value" data-hook>
      <%= button_tag t('spree.add_option_value'), type: 'button',
            data: { target: 'tbody#option_values' },
            class: 'btn btn-primary spree_add_fields' %>
    </span>
  </li>
<% end %>

<%= render partial: 'spree/shared/error_messages', locals: { target: @option_type } %>

<%= form_for [:admin, @option_type] do |f| %>

  <fieldset class="no-border-bottom">
    <legend><%= Spree::OptionType.model_name.human %></legend>
    <%= render partial: 'form', locals: { f: f } %>
  </fieldset>

  <fieldset>
    <legend><%= plural_resource_name(Spree::OptionValue) %></legend>
    <table class="index sortable" data-hook data-sortable-link="<%= update_values_positions_admin_option_types_url %>">
      <thead data-hook="option_header">
        <tr>
          <th></th>
          <th><%= Spree::OptionValue.human_attribute_name(:name) %></th>
          <th><%= Spree::OptionValue.human_attribute_name(:presentation) %></th>
          <th class="actions"></th>
        </tr>
      </thead>
      <tbody id="option_values">
        <%= f.fields_for :option_values, @option_values do |option_value_form| %>
          <%= render partial: 'option_value_fields', locals: { f: option_value_form } %>
        <% end %>
      </tbody>
    </table>
    <%= render partial: 'spree/admin/shared/edit_resource_links' %>
  </fieldset>
<% end %>
