mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Display infinite on_hand as read-only
This commit is contained in:
@@ -121,8 +121,8 @@
|
||||
%td{ 'ng-show' => 'columns.price.visible' }
|
||||
%input{ 'ng-model' => 'product.price', 'ofn-decimal' => :true, :name => 'price', 'ofn-track-product' => 'price', :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' }
|
||||
%span{ 'ng-bind' => 'product.on_hand', :name => 'on_hand', 'ng-show' => 'hasVariants(product) || product.on_demand' }
|
||||
%input.field{ 'ng-model' => 'product.on_hand', :name => 'on_hand', 'ofn-track-product' => 'on_hand', 'ng-hide' => 'hasVariants(product) || product.on_demand', :type => 'number' }
|
||||
%td{ 'ng-show' => 'columns.available_on.visible' }
|
||||
%input{ 'ng-model' => 'product.available_on', :name => 'available_on', 'ofn-track-product' => 'available_on', 'datetimepicker' => 'product.available_on', type: "text" }
|
||||
%td.actions
|
||||
@@ -142,7 +142,8 @@
|
||||
%td{ 'ng-show' => 'columns.price.visible' }
|
||||
%input{ 'ng-model' => 'variant.price', 'ofn-decimal' => :true, :name => 'variant_price', 'ofn-track-variant' => 'price', :type => 'text' }
|
||||
%td{ 'ng-show' => 'columns.on_hand.visible' }
|
||||
%input.field{ 'ng-model' => 'variant.on_hand', 'ng-change' => 'updateOnHand(product)', :name => 'variant_on_hand', 'ofn-track-variant' => 'on_hand', :type => 'number' }
|
||||
%input.field{ 'ng-model' => 'variant.on_hand', 'ng-change' => 'updateOnHand(product)', :name => 'variant_on_hand', 'ng-hide' => 'variant.on_demand', 'ofn-track-variant' => 'on_hand', :type => 'number' }
|
||||
%span{ 'ng-bind' => 'variant.on_hand', :name => 'variant_on_hand', 'ng-show' => 'variant.on_demand' }
|
||||
%td{ 'ng-show' => 'columns.available_on.visible' }
|
||||
%td.actions
|
||||
%a{ 'ng-click' => 'editWarn(product,variant)', :class => "edit-variant icon-edit no-text" }
|
||||
|
||||
@@ -130,6 +130,30 @@ feature %q{
|
||||
page.should have_field "on_hand", with: "12"
|
||||
end
|
||||
|
||||
it "displays 'on demand' for the on hand count when the product is available on demand" do
|
||||
p1 = FactoryGirl.create(:product, on_demand: true)
|
||||
p1.master.on_demand = true; p1.master.save!
|
||||
|
||||
visit '/admin/products/bulk_edit'
|
||||
|
||||
page.should have_selector "span[name='on_hand']", text: "On demand"
|
||||
page.should_not have_field "on_hand", visible: true
|
||||
end
|
||||
|
||||
it "displays 'on demand' for any variant that is available on demand" do
|
||||
p1 = FactoryGirl.create(:product)
|
||||
v1 = FactoryGirl.create(:variant, product: p1, is_master: false, on_hand: 4)
|
||||
v2 = FactoryGirl.create(:variant, product: p1, is_master: false, on_hand: 0, on_demand: true)
|
||||
|
||||
visit '/admin/products/bulk_edit'
|
||||
first("a.view-variants").click
|
||||
|
||||
page.should have_selector "span[name='on_hand']", text: "On demand"
|
||||
page.should have_field "variant_on_hand", with: "4"
|
||||
page.should_not have_field "variant_on_hand", with: "", visible: true
|
||||
page.should have_selector ".variant span[name='on_hand']", text: "On demand"
|
||||
end
|
||||
|
||||
it "displays a select box for the unit of measure for the product's variants" do
|
||||
p = FactoryGirl.create(:product, variant_unit: 'weight', variant_unit_scale: 1, variant_unit_name: '')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user