<%= render 'spree/admin/shared/product_tabs', :current => 'Product Properties' %> <%= render 'spree/shared/error_messages', :target => @product %> <% content_for :page_actions do %> <% if can?(:create, Spree::ProductProperty) %> <% end %> <% end %> <%= form_for @product, :url => admin_product_url(@product), :method => :put do |f| %>
<%= Spree.t(:product_properties) %>
<%= image_tag 'select2-spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator' %> <%= f.fields_for :product_properties do |pp_form| %> <%= render 'product_property_fields', :f => pp_form %> <% end %>
<%= Spree.t(:property) %> <%= Spree.t(:value) %>
<% if can?([:create, :update], Spree::ProductProperty) %> <%= render 'spree/admin/shared/edit_resource_links' %> <% end %> <%= hidden_field_tag 'clear_product_properties', 'true' %>
<% end %> <%= form_tag admin_product_product_properties_path, method: :get, id: 'variant_option_value_selections' do %>
<%= Spree.t(:variant_properties) %>
<% @option_types.each do |option_type, option_values| %>
<%= label :option_type_presentation, option_type.presentation %> <%= select_tag "ovi[]", options_from_collection_for_select(option_values, :id, :presentation, params[:ovi]), class: 'select2 fullwidth', include_blank: true, id: "#{option_type.name}_option_type_select" %>
<% end %>
<%= button Spree.t(:filter_results) %> <% if @option_value_ids.present? %> <%= Spree.t(:or) %> <%= link_to_add_fields Spree.t(:add_variant_properties), 'tbody#variant_property_values', class: 'plus button' %> <% end %>
<% end %> <%= form_for @product, url: admin_product_url(@product), method: :put do |f| %> <%= f.fields_for :variant_property_rules, @variant_property_rule do |rule_form| %> <%= rule_form.hidden_field 'id', value: @variant_property_rule.id %> <%= rule_form.hidden_field 'option_value_ids', value: @option_value_ids.join(',') %> <% if @option_value_ids.present? %>
<%= rule_form.fields_for :values do |values_form| %> <%= render 'product_property_fields', f: values_form %> <% end %>
<%= Spree.t(:property) %> <%= Spree.t(:value) %>
<% if can?([:create, :update], Spree::VariantPropertyRule) %> <%= render 'spree/admin/shared/edit_resource_links' %> <% end %>
<% end %> <% end %> <% end %> <%= javascript_tag do -%> var properties = <%= raw(@properties.to_json) %>; $('#product_properties, #variant_property_values').on('keydown', 'input.autocomplete', function() { already_auto_completed = $(this).is('ac_input'); if (!already_auto_completed) { $(this).autocomplete({source: properties}); $(this).focus(); } }); <% end -%>