mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Fix bulk product edit page. on_hand and on_demand should never be mixed on the server side, the UI can make the decision to show on_demand on the on_hand column if on_demand is true
This commit is contained in:
@@ -25,7 +25,8 @@ class Api::Admin::ProductSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def on_hand
|
||||
object.on_hand.nil? ? 0 : object.on_hand.to_f.finite? ? object.on_hand : I18n.t(:on_demand)
|
||||
return 0 if object.on_hand.nil?
|
||||
object.on_hand
|
||||
end
|
||||
|
||||
def price
|
||||
|
||||
@@ -4,7 +4,8 @@ class Api::Admin::VariantSerializer < ActiveModel::Serializer
|
||||
has_many :variant_overrides
|
||||
|
||||
def on_hand
|
||||
object.on_hand.nil? ? 0 : ( object.on_hand.to_f.finite? ? object.on_hand : I18n.t(:on_demand) )
|
||||
return 0 if object.on_hand.nil?
|
||||
object.on_hand
|
||||
end
|
||||
|
||||
def price
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
%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', 'ng-if' => '!variant.on_demand', 'ofn-track-variant' => 'on_hand', :type => 'number' }
|
||||
%span{ 'ng-bind' => 'variant.on_hand', :name => 'variant_on_hand', 'ng-if' => 'variant.on_demand' }
|
||||
%span{ :name => 'variant_on_hand', 'ng-if' => 'variant.on_demand' }
|
||||
= t(:on_demand)
|
||||
%td{ 'ng-show' => 'columns.on_demand.visible' }
|
||||
%input.field{ 'ng-model' => 'variant.on_demand', :name => 'variant_on_demand', 'ofn-track-variant' => 'on_demand', :type => 'checkbox' }
|
||||
%td{ 'ng-show' => 'columns.category.visible' }
|
||||
|
||||
Reference in New Issue
Block a user