= error_messages_for @product - url = comable.admin_products_path if @product.new_record? - url ||= comable.admin_product_path(@product) = form_for @product, url: url, html: { multipart: true } do |f| .hidden = f.submit fieldset .col-sm-3 legend = Comable.t('admin.general') .help-block .col-sm-9 .form-group = f.label :code = f.text_field :code .form-group = f.label :name = f.text_field :name .form-group = f.label :caption = f.text_field :caption .form-group = f.label :price = f.text_field :price = stylesheet_link_tag 'http://rawgithub.com/aehlke/tag-it/master/css/jquery.tagit.css', media: 'all' = stylesheet_link_tag 'http://rawgithub.com/aehlke/tag-it/master/css/tagit.ui-zendesk.css', media: 'all' = javascript_include_tag 'http://rawgithub.com/aehlke/tag-it/master/js/tag-it.min.js' / TODO: Refactoring javascript: comable_tagit_available_tags = #{raw Comable::Category.all.map(&:path).map { |path| path.map(&:name).join(' > ') }.sort.to_json}; coffee: $(document).ready(-> $("#comable-tagit").tagit({ fieldName: 'product[category_path_names][]', availableTags: comable_tagit_available_tags, autocomplete: { delay: 0, minLength: 0 }, showAutocompleteOnFocus: true, removeConfirmation: true, # Only allow available tags beforeTagAdded: (event, ui) -> (comable_tagit_available_tags.indexOf(ui.tagLabel) != -1) }) ) .form-group = f.label :categories ul#comable-tagit - @product.categories.each do |category| li = category.path.map(&:name).join(' > ') hr fieldset .col-sm-3 legend = Comable.t('admin.stocks') .help-block - if @product.sku? || (@product.persisted? && @product.stocks.empty?) = Comable.t('admin.link_to_add_new_stock') = link_to Comable.t('admin.actions.new'), comable.new_admin_product_stock_path(@product) .col-sm-9 - if @product.stocks.any? table.table.table-striped thead th = @product.stocks.human_attribute_name(:code) th = @product.stocks.human_attribute_name(:quantity) - if @product.sku? - if @product.sku_h? th = @product.sku_h_item_name - if @product.sku_v? th = @product.sku_v_item_name th = Comable.t('admin.operation') tbody - @product.stocks.each do |stock| tr td = stock.code td strong class="#{(stock.quantity <= 0) ? 'text-danger' : (stock.quantity <= 10) ? 'text-warning' : 'text-success'}" = number_with_delimiter stock.quantity - if @product.sku? - if @product.sku_h? td = stock.sku_h_choice_name - if @product.sku_v? td = stock.sku_v_choice_name td = link_to comable.admin_stock_path(stock), class: 'btn btn-default' i.fa.fa-edit> = Comable.t('admin.actions.edit') .form-group = f.label :sku_h_item_name = f.text_field :sku_h_item_name .help-block = Comable.t('admin.please_fill_when_using_sku') .form-group = f.label :sku_v_item_name = f.text_field :sku_v_item_name hr fieldset .col-sm-3 legend = Comable.t('admin.images') .help-block .col-sm-9 - images = @product.images - main_image = images.first || @product.images.build - sub_images = images - [main_image] .row .col-sm-6 = f.fields_for :images, main_image do |ff| label = Comable.t('admin.main_image') p = ff.file_field :file - if ff.object.url .thumbnail = image_tag ff.object.url - if ff.object.persisted? label.remove span> = ff.check_box :_destroy span> = Comable.t('admin.actions.destroy') .col-sm-6 .row - sub_images.each.with_index(1) do |image, index| = f.fields_for :images, image do |ff| = render 'image_fields', ff: ff, index: index .col-sm-6 = link_to_add_fields Comable.t('admin.add_sub_image'), f, :images