<%= render :partial => 'spree/admin/shared/product_sub_menu' %>

<h1><%= t(:editing_product_group) %></h1>

<fieldset id="product_group_forms_container" data-hook>

  <%= form_for [:admin, @product_group], :html => { :id => 'product-group-form', :method => :put } do |f| %>

      <%= f.field_container :name do %>
        <%= f.label :name, t(:name) %><br />
        <%= f.text_field :name %>
        <%= f.error_message_on :name %>
      <% end %>

      <%= f.field_container :permalink do %>
        <%= f.label :permalink, t(:permalink) %><br />
        <%= f.text_field :permalink %>
        <%= f.error_message_on :permalink %>
      <% end %>

      <%= f.field_container :order_scope do %>
        <%= f.label :order_scope, t(:sort_ordering) %><br />
        <%= f.select(:order_scope, Spree::Product.simple_scopes.collect{|p| [ t(:name, :scope =>[:product_scopes, :scopes, p]), p.to_s ] }) %>
      <% end %>

      <table id="product_scopes" data-hook>
        <%= render :partial => 'product_scope', :collection => @product_group.product_scopes.reject {|s| s.is_ordering? } %>
      </table>

    <%= button t(:update) %>

  <% end %>

  <%= form_tag admin_product_group_product_scopes_path(@product_group), :remote => true, :id => 'new_product_group_form' do %>
    <%
    options =
    grouped_options_for_select(
    Spree::ProductScope.all_scopes.map do |group_name, scopes|
      [
        t(:name, :scope => [:product_scopes, :groups, group_name]),
        scopes.keys.map do |scope_name|
          [ t(:name, :scope => [:product_scopes, :scopes, scope_name]), scope_name]
        end
      ]
    end
    )
    %>
    <p>
      <%= label_tag :product_scope_name, t(:add_scope) %>
      <%= select_tag 'product_scope[name]', options %>
      <%= submit_tag t(:add) %>
    </p>
  <% end %>

</fieldset>

<fieldset id="preview_container" data-hook>
  <%= render :partial => 'preview' %>
</fieldset>
