- 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| .panel.panel-inverse .panel-heading .panel-title = Comable.t('admin.general') .panel-body .form-horizontal .form-group .col-sm-3.control-label = f.label :code .col-sm-6 = f.text_field :code .form-group .col-sm-3.control-label = f.label :name .col-sm-6 = f.text_field :name .form-group .col-sm-3.control-label = f.label :caption .col-sm-6 = f.text_field :caption .form-group .col-sm-3.control-label = f.label :price .col-sm-6 = 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 .col-sm-3.control-label = f.label :categories .col-sm-6 ul#comable-tagit - @product.categories.each do |category| li = category.path.map(&:name).join(' > ') fieldset legend.text-center.text-muted | SKU .form-group .col-sm-3.control-label = f.label :sku_h_item_name .col-sm-6 = f.text_field :sku_h_item_name span.help-block = Comable.t('admin.please_fill_when_using_sku') .form-group .col-sm-3.control-label = f.label :sku_v_item_name .col-sm-6 = f.text_field :sku_v_item_name .panel-footer = link_to Comable.t('admin.actions.cancel'), comable.admin_products_path, class: 'btn btn-default' .pull-right = f.submit .panel.panel-inverse .panel-heading .panel-title = Comable.t('admin.images') .panel-body - images = @product.images + [@product.images.build] - main_image = images.first - 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| .col-sm-6 label | #{Comable.t('admin.sub_image')} ##{index} 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') .panel-footer = link_to Comable.t('admin.actions.cancel'), comable.admin_products_path, class: 'btn btn-default' .pull-right = f.submit