From cc4dc068ab209362d954d5510a23d2313e8cf139 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 18 Dec 2015 13:47:17 +1100 Subject: [PATCH] Adding variant SKU field to BPE --- .../javascripts/admin/bulk_product_update.js.coffee | 3 +++ .../admin/products/bulk_edit/_products_variant.html.haml | 1 + spec/features/admin/bulk_product_update_spec.rb | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index b3d24f00c0..6c85a4fd54 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -352,6 +352,9 @@ filterSubmitVariant = (variant) -> filteredVariant = {} if not variant.deleted_at? and variant.hasOwnProperty("id") filteredVariant.id = variant.id unless variant.id <= 0 + if variant.hasOwnProperty("sku") + filteredVariant.sku = variant.sku + hasUpdatableProperty = true if variant.hasOwnProperty("on_hand") filteredVariant.on_hand = variant.on_hand hasUpdatableProperty = true diff --git a/app/views/spree/admin/products/bulk_edit/_products_variant.html.haml b/app/views/spree/admin/products/bulk_edit/_products_variant.html.haml index cc85566577..ff345cb259 100644 --- a/app/views/spree/admin/products/bulk_edit/_products_variant.html.haml +++ b/app/views/spree/admin/products/bulk_edit/_products_variant.html.haml @@ -4,6 +4,7 @@ %a{ :class => "add-variant icon-plus-sign", 'ng-click' => "addVariant(product)", 'ng-show' => "$last" } %td{ 'ng-show' => 'columns.producer.visible' } %td{ 'ng-show' => 'columns.sku.visible' } + %input{ 'ng-model' => "variant.sku", :name => 'variant_sku', 'ofn-track-variant' => 'sku', :type => 'text' } %td{ 'ng-show' => 'columns.name.visible' } %input{ 'ng-model' => 'variant.display_name', :name => 'variant_display_name', 'ofn-track-variant' => 'display_name', :type => 'text', placeholder: "{{ product.name }}" } %td.unit_value{ 'ng-show' => 'columns.unit.visible' } diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 1a2c715e34..9dabf93028 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -308,6 +308,7 @@ feature %q{ p = FactoryGirl.create(:product, supplier: s1, available_on: Date.current, variant_unit: 'volume', variant_unit_scale: 0.001, price: 3.0, on_hand: 9, unit_value: 0.25, unit_description: '(bottle)' ) v = p.variants.first + v.update_column(:sku, "VARIANTSKU") login_to_admin_section @@ -315,12 +316,18 @@ feature %q{ expect(page).to have_selector "a.view-variants" first("a.view-variants").trigger('click') + first("div#columns-dropdown", :text => "COLUMNS").click + first("div#columns-dropdown div.menu div.menu_item", text: "SKU").click + first("div#columns-dropdown", :text => "COLUMNS").click + + expect(page).to have_field "variant_sku", with: "VARIANTSKU" expect(page).to have_field "variant_price", with: "3.0" expect(page).to have_field "variant_unit_value_with_description", with: "250 (bottle)" expect(page).to have_field "variant_on_hand", with: "9" expect(page).to have_selector "span[name='on_hand']", "9" select "Volume (L)", from: "variant_unit_with_scale" + fill_in "variant_sku", with: "NEWSKU" fill_in "variant_price", with: "4.0" fill_in "variant_on_hand", with: "10" fill_in "variant_unit_value_with_description", with: "2 (8x250 mL bottles)" @@ -331,6 +338,7 @@ feature %q{ expect(page.find("#status-message")).to have_content "Changes saved." v.reload + expect(v.sku).to eq "NEWSKU" expect(v.price).to eq 4.0 expect(v.on_hand).to eq 10 expect(v.unit_value).to eq 2 # 2L in L