diff --git a/app/assets/stylesheets/admin/select2.css.scss b/app/assets/stylesheets/admin/select2.css.scss index 0acf00c0888..ec8f3234b64 100644 --- a/app/assets/stylesheets/admin/select2.css.scss +++ b/app/assets/stylesheets/admin/select2.css.scss @@ -3,7 +3,7 @@ .select2-container { .select2-choice { .select2-search-choice-close { - display: none; + display: none !important; } .select2-arrow { width: 22px; diff --git a/app/overrides/spree/admin/product_properties/_product_property_fields/replace_free_text_with_select.html.haml.deface b/app/overrides/spree/admin/product_properties/_product_property_fields/replace_free_text_with_select.html.haml.deface deleted file mode 100644 index 486d35014e3..00000000000 --- a/app/overrides/spree/admin/product_properties/_product_property_fields/replace_free_text_with_select.html.haml.deface +++ /dev/null @@ -1,6 +0,0 @@ -/ replace_contents "td.property_name" - -- if spree_current_user.admin? - = f.text_field :property_name, :class => 'autocomplete' -- else - = f.select :property_name, @properties, { :include_blank => true }, { class: 'select2 fullwidth' } diff --git a/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface b/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface deleted file mode 100644 index 149f72015af..00000000000 --- a/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface +++ /dev/null @@ -1,26 +0,0 @@ -/ insert_after 'table.index.sortable' - -=f.check_box :inherits_properties -=f.label :inherits_properties, t(".inherits_properties_checkbox_hint", supplier: @product.supplier.name) -%br -%br - -#inherited_properties - %table.index - %thead - %tr{"data-hook" => "producer_properties_header"} - %th= t('admin.products.properties.inherited_property') - %th= t('admin.description') - %th.actions - %tbody#producer_properties{"data-hook" => ""} - - @product.supplier.producer_properties.each do |producer_property| - %tr - %td= producer_property.property.presentation - %td= producer_property.value - %td.actions - -:coffee - $(document).ready -> - $("#inherited_properties").toggle $("input#product_inherits_properties").is(':checked') - $("input#product_inherits_properties").change -> - $("#inherited_properties").toggle $(this).is(':checked') diff --git a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface deleted file mode 100644 index 011580c1bb6..00000000000 --- a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface +++ /dev/null @@ -1,5 +0,0 @@ -/ replace "tr[data-hook='product_properties_header']" -%tr{"data-hook" => "product_properties_header"} - %th= t('admin.products.properties.property_name') - %th= t('admin.description') - %th.actions diff --git a/app/views/spree/admin/product_properties/_product_property_fields.html.haml b/app/views/spree/admin/product_properties/_product_property_fields.html.haml new file mode 100644 index 00000000000..d4362c43667 --- /dev/null +++ b/app/views/spree/admin/product_properties/_product_property_fields.html.haml @@ -0,0 +1,14 @@ +%tr.product_property.fields{"data-hook" => "product_property", id: "spree_#{dom_id(f.object)}"} + %td.no-border + %span.handle + = f.hidden_field :id + %td.property_name + - if spree_current_user.admin? + = f.text_field :property_name, class: 'autocomplete' + - else + = f.select :property_name, @properties, { include_blank: true }, { class: 'select2 fullwidth' } + %td.value + = f.text_field :value, class: 'autocomplete' + %td.actions + - if f.object.persisted? + = link_to_delete f.object, no_text: true diff --git a/app/views/spree/admin/product_properties/index.html.haml b/app/views/spree/admin/product_properties/index.html.haml new file mode 100644 index 00000000000..e97d559111f --- /dev/null +++ b/app/views/spree/admin/product_properties/index.html.haml @@ -0,0 +1,71 @@ += render partial: 'spree/admin/shared/product_sub_menu' + += render partial: 'spree/admin/shared/product_tabs', locals: { current: 'Product Properties' } + += render partial: 'spree/shared/error_messages', locals: { target: @product } + +- content_for :page_actions do + %ul.tollbar.inline-menu + %li + = link_to_add_fields Spree.t(:add_product_properties), 'tbody#product_properties', class: 'icon-plus button' + %li + %span#new_ptype_link + = link_to Spree.t(:select_from_prototype), available_admin_prototypes_url, remote: true, 'data-update' => 'prototypes', class: 'button icon-copy' + += form_for @product, url: admin_product_url(@product), method: :put do |f| + %fieldset.no-border-top + .add_product_properties + #prototypes + = image_tag 'select2-spinner.gif', plugin: 'spree', style: 'display:none;', id: 'busy_indicator' + + %table.index.sortable{"data-sortable-link" => update_positions_admin_product_product_properties_url} + %thead + %tr + %th.no-border + %th= t('admin.products.properties.property_name') + %th= t('admin.description') + %th.actions + + %tbody#product_properties + = f.fields_for :product_properties do |pp_form| + = render partial: 'product_property_fields', locals: { f: pp_form } + + = f.check_box :inherits_properties + = f.label :inherits_properties, t(".inherits_properties_checkbox_hint", supplier: @product.supplier.name) + %br + %br + + #inherited_properties + %table.index + %thead + %tr + %th= t('admin.products.properties.inherited_property') + %th= t('admin.description') + %th.actions + %tbody#producer_properties + - @product.supplier.producer_properties.each do |producer_property| + %tr + %td= producer_property.property.presentation + %td= producer_property.value + %td.actions + + + = render partial: 'spree/admin/shared/edit_resource_links' + + = hidden_field_tag 'clear_product_properties', 'true' + +:coffee + $(document).ready -> + $("#inherited_properties").toggle $("input#product_inherits_properties").is(':checked') + $("input#product_inherits_properties").change -> + $("#inherited_properties").toggle $(this).is(':checked') + +:javascript + var properties = #{raw(@properties.to_json)}; + $("#product_properties input.autocomplete").live("keydown", function(){ + already_auto_completed = $(this).is('ac_input'); + if (!already_auto_completed) { + $(this).autocomplete({source: properties}); + $(this).focus(); + } + }); diff --git a/app/views/spree/admin/shared/_edit_resource_links.html.haml b/app/views/spree/admin/shared/_edit_resource_links.html.haml new file mode 100644 index 00000000000..44db947bba8 --- /dev/null +++ b/app/views/spree/admin/shared/_edit_resource_links.html.haml @@ -0,0 +1,4 @@ +.form-buttons.filter-actions.actions + = button Spree.t('actions.update'), 'icon-refresh' + %span.or= Spree.t(:or) + = button_link_to Spree.t('actions.cancel'), collection_url, icon: 'icon-remove' diff --git a/app/views/spree/admin/shared/_product_sub_menu.html.haml b/app/views/spree/admin/shared/_product_sub_menu.html.haml new file mode 100644 index 00000000000..385fbd9993b --- /dev/null +++ b/app/views/spree/admin/shared/_product_sub_menu.html.haml @@ -0,0 +1,6 @@ +- content_for :sub_menu do + %ul#sub_nav.inline-menu + = tab :products, match_path: '/products' + = tab :option_types, match_path: '/option_types' + = tab :properties + = tab :prototypes diff --git a/app/views/spree/shared/_error_messages.html.haml b/app/views/spree/shared/_error_messages.html.haml new file mode 100644 index 00000000000..54fabd313e8 --- /dev/null +++ b/app/views/spree/shared/_error_messages.html.haml @@ -0,0 +1,11 @@ +- if target && target.errors.any? + #errorExplanation.errorExplanation + %h2 + = Spree.t(:errors_prohibited_this_record_from_being_saved, count: target.errors.count) + \: + %p + = Spree.t(:there_were_problems_with_the_following_fields) + \: + %ul + - target.errors.full_messages.each do |msg| + %li= msg