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

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

<%= form_for [:admin, @product], :html => { :multipart => true } do |f| %>

<fieldset data-hook="new_product">

  <legend align="center"><%= t(:new_product) %></legend>

  <%= f.field_container :name do %>
    <%= f.label :name, t(:name) %> <span class="required">*</span><br />
    <%= f.text_field :name, :class => 'fullwidth title' %>
    <%= f.error_message_on :name %>
  <% end %>

  <div data-hook="new_product_attrs" class="row">
    <% unless @product.has_variants? %>
      <div class="alpha four columns">
        <%= f.field_container :sku do %>
          <%= f.label :sku, t(:sku) %><br />
          <%= f.text_field :sku, :size => 16, :class => 'fullwidth' %>
          <%= f.error_message_on :sku %>
        <% end %>  
      </div>      
    <% end %>

    <div class="four columns">
      <%= f.field_container :prototype do %>
        <%= f.label :prototype_id, t(:prototype) %><br />
        <%= f.collection_select :prototype_id, Spree::Prototype.all, :id, :name, {:include_blank => true}, {:class => 'select2 fullwidth'} %>
      <% end %>
    </div>
      
    <div class="four columns">
      <%= f.field_container :price do %>
        <%= f.label :price, t(:master_price) %> <span class="required">*</span><br />
        <%= f.text_field :price, :class => 'fullwidth' %>
        <%= f.error_message_on :price %>
      <% end %>
    </div>

    <div class="omega four columns">
      <%= f.field_container :available_on do %>
        <%= f.label :available_on, t(:available_on) %>
        <%= f.error_message_on :available_on %>
        <%= f.text_field :available_on, :class => 'datepicker fullwidth' %>
      <% end %>
    </div>
    
  </div>
  
  <div class="clearfix" data-hook="product-from-prototype" id="product-from-prototype">
    <%= render :file => 'spree/admin/prototypes/show' if @prototype %>
  </div>

  <%= render :partial => 'spree/admin/shared/new_resource_links' %>
  
</fieldset>
<% end %>

<script type="text/javascript">
//<![CDATA[
  (function($){
    var base_url = "<%= admin_prototypes_url %>";
    var prototype_select = $('#product_prototype_id');    
    prototype_select.change(function() {
      var id = prototype_select.val();
      if (id.length) {
        $('#product-from-prototype').load([ base_url, id ].join("/"));
      } else {
        $('#product-from-prototype').empty();
      }
    })
    if (prototype_select.html() == "") {
      prototype_select.change();
    }
  })(jQuery);
//]]>
</script>
<commit_msg>Use jsuri for products/new prototype selector too<commit_after><%= render :partial => 'spree/admin/shared/product_sub_menu' %>

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

<%= form_for [:admin, @product], :html => { :multipart => true } do |f| %>

<fieldset data-hook="new_product">

  <legend align="center"><%= t(:new_product) %></legend>

  <%= f.field_container :name do %>
    <%= f.label :name, t(:name) %> <span class="required">*</span><br />
    <%= f.text_field :name, :class => 'fullwidth title' %>
    <%= f.error_message_on :name %>
  <% end %>

  <div data-hook="new_product_attrs" class="row">
    <% unless @product.has_variants? %>
      <div class="alpha four columns">
        <%= f.field_container :sku do %>
          <%= f.label :sku, t(:sku) %><br />
          <%= f.text_field :sku, :size => 16, :class => 'fullwidth' %>
          <%= f.error_message_on :sku %>
        <% end %>  
      </div>      
    <% end %>

    <div class="four columns">
      <%= f.field_container :prototype do %>
        <%= f.label :prototype_id, t(:prototype) %><br />
        <%= f.collection_select :prototype_id, Spree::Prototype.all, :id, :name, {:include_blank => true}, {:class => 'select2 fullwidth'} %>
      <% end %>
    </div>
      
    <div class="four columns">
      <%= f.field_container :price do %>
        <%= f.label :price, t(:master_price) %> <span class="required">*</span><br />
        <%= f.text_field :price, :class => 'fullwidth' %>
        <%= f.error_message_on :price %>
      <% end %>
    </div>

    <div class="omega four columns">
      <%= f.field_container :available_on do %>
        <%= f.label :available_on, t(:available_on) %>
        <%= f.error_message_on :available_on %>
        <%= f.text_field :available_on, :class => 'datepicker fullwidth' %>
      <% end %>
    </div>
    
  </div>
  
  <div class="clearfix" data-hook="product-from-prototype" id="product-from-prototype">
    <%= render :file => 'spree/admin/prototypes/show' if @prototype %>
  </div>

  <%= render :partial => 'spree/admin/shared/new_resource_links' %>
  
</fieldset>
<% end %>

<script type="text/javascript">
//<![CDATA[
  (function($){
    var base_url = "<%= admin_prototypes_url %>";
    var prototype_select = $('#product_prototype_id');    
    prototype_select.change(function() {
      var id = prototype_select.val();
      if (id.length) {
        var url = new Uri(base_url);
        url.setPath(url.path() + '/' + id);
        $('#product-from-prototype').load(url.toString());
      } else {
        $('#product-from-prototype').empty();
      }
    })
    if (prototype_select.html() == "") {
      prototype_select.change();
    }
  })(jQuery);
//]]>
</script>

{'fraction_non_alphanumeric': 0.2079244584336234, 'fraction_numerical': 0.0011109053878911312, 'mean_word_length': 2.889128869690425, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 155, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3863534', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1801, 'n_words': 349}