Adding variant SKU field to BPE

This commit is contained in:
Rob Harrington
2015-12-18 13:47:17 +11:00
parent 64cd52e067
commit cc4dc068ab
3 changed files with 12 additions and 0 deletions

View File

@@ -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

View File

@@ -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' }

View File

@@ -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