<% if @active_sale_event.try(:errors).present? %> <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @active_sale_event } %> <% end %> <%= form_for [:admin, @active_sale, @active_sale_event], :html => { :id => 'admin_active_sale_event', :multipart => true } do |f| %>
<%= f.field_container :name do %> <%= f.label :name, raw(t('spree.active_sale.event.active_record.name') + content_tag(:span, ' *', :class => 'required')) %> <%= f.text_field :name, :class => 'fullwidth' %> <%= f.error_message_on :name %> <% end %> <%= f.field_container :description do %> <%= f.label :description, t('spree.active_sale.event.active_record.description') %> <%= f.text_area :description, {:cols => 60, :rows => 10, :class => 'fullwidth'} %> <%= f.error_message_on :description %> <% end %>
<%= f.field_container :start_date do %> <%= f.label :start_date, t('spree.active_sale.event.active_record.start_date') %> <%= f.error_message_on :start_date %> <% if @active_sale_event.start_date? %> <% start_date = l(@active_sale_event.start_date, :format => t('spree.active_sale.event.datetimepicker.format')) %> <% else %> <% start_date = l(Time.zone.now, :format => t('spree.active_sale.event.datetimepicker.format')) %> <% end %> <%= f.text_field :start_date, :value => start_date, :class => 'timepicker' %> <% end %>
<%= f.field_container :end_date do %> <%= f.label :end_date, t('spree.active_sale.event.active_record.end_date') %> <%= f.error_message_on :end_date %> <% end_date = l((@active_sale_event.end_date? ? @active_sale_event.end_date : Time.zone.now+1.day), :format => t('spree.active_sale.event.datetimepicker.format')) %> <%= f.text_field :end_date, :value => end_date, :class => 'timepicker' %> <% end %>
<%= f.label :eventable, t('spree.active_sale.event.active_record.eventable_type', :default => :evenetable) %>

<%= t('spree.active_sale.event.eventable_hint') %>

<%= f.select :eventable_type, [["Product","Spree::Product"], ["Taxon","Spree::Taxon"]], { :include_blank => false }, { :class => 'select2' } %> <%= f.error_message_on :eventable %>
<%= f.label :eventable_name, t('spree.active_sale.event.active_record.eventable_name', :default => :eventable_name) %>

<%= t('spree.active_sale.event.eventable_name_hint') %>

<%= f.error_message_on :eventable_name %> <%= f.text_field :eventable_name, :class => 'autocomplete', :data => { :auto_complete_url => eventables_admin_active_sale_active_sale_events_url(:active_sale_id => @active_sale.id) } %>
<%= f.field_container :is_active, :class => ['checkbox'] do %> <% end %> <%= f.field_container :is_hidden, :class => ['checkbox'] do %> <% end %> <%= f.field_container :is_permanent, :class => ['checkbox'] do %> <% end %>
<%= f.field_container :discount do %> <%= f.label :discount, t('spree.active_sale.event.active_record.discount', :default => :discount) %>

<%= t('spree.active_sale.event.discount_hint') %>

<%= f.error_message_on :discount %> <%= f.text_field :discount, :size => 2, :maxlength => 2 %> <% end %>
<% unless @active_sale_event.new_record? %>
<%= render 'spree/admin/shared/sale_images' %> <% end %>

<% if @active_sale_event.new_record? %> <%= render :partial => 'spree/admin/shared/new_resource_links' %> <% else %> <%= render :partial => 'spree/admin/shared/edit_resource_links' %> <% end %>

<% end %> <%= javascript_tag do -%> var properties = "<%= raw(@properties.to_json) %>"; $("#admin_active_sale_event input.autocomplete").live("keydown", function(){ var eventable_type = $('#active_sale_event_eventable_type :selected').val(); var eventable_name = $('#active_sale_event_eventable_name').val(); var url = $(this).data('auto-complete-url') already_auto_completed = $(this).is('ac_input'); if (!already_auto_completed) { $(this).autocomplete({ source: url+"?eventable_type="+eventable_type+"&name="+eventable_name }); $(this).focus(); } }); <% end -%>