From b21263e1c0591af78a1db9f0d827f3fdeb161e4d Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 6 Dec 2013 12:06:16 +1100 Subject: [PATCH] Display text field for variant_unit_name --- app/views/spree/admin/products/bulk_edit.html.haml | 1 + spec/features/admin/bulk_product_update_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/app/views/spree/admin/products/bulk_edit.html.haml b/app/views/spree/admin/products/bulk_edit.html.haml index e975cd4923..fc64926447 100644 --- a/app/views/spree/admin/products/bulk_edit.html.haml +++ b/app/views/spree/admin/products/bulk_edit.html.haml @@ -50,6 +50,7 @@ %input{ 'ng-model' => 'product.price', 'ofn-decimal' => :true, :name => 'price', 'ofn-track-product' => 'price', :type => 'text' } %td{ 'ng-show' => 'columns.unit.visible' } %select.select2{ 'ng-model' => 'product.variant_unit_with_scale', :name => 'variant_unit_with_scale', 'ofn-track-product' => 'variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options' } + %input{ 'ng-model' => 'product.variant_unit_name', :name => 'variant_unit_name', 'ng-track-product' => 'variant_unit_name', 'ng-show' => "product.variant_unit_with_scale == 'items'", :type => 'text' } %td{ 'ng-show' => 'columns.on_hand.visible' } %span{ 'ng-bind' => 'product.on_hand', :name => 'on_hand', 'ng-show' => 'hasVariants(product)' } %input.field{ 'ng-model' => 'product.on_hand', :name => 'on_hand', 'ofn-track-product' => 'on_hand', 'ng-show' => '!hasVariants(product)', :type => 'number' } diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index ff06549375..ef0fdb504a 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -106,6 +106,15 @@ feature %q{ page.should have_select "variant_unit_with_scale", selected: "Weight (g)" end + + it "displays a text field for the item name when unit is set to 'Items'" do + p = FactoryGirl.create(:product, variant_unit: 'items', variant_unit_scale: nil, variant_unit_name: 'packet') + + visit '/admin/products/bulk_edit' + + page.should have_select "variant_unit_with_scale", selected: "Items" + page.should have_field "variant_unit_name", with: "packet" + end end describe "listing variants" do