mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Making our form on_demand and count_on_hand aware
This commit is contained in:
@@ -24,7 +24,12 @@
|
||||
%td {{ product.master.options_text }}
|
||||
%td
|
||||
%span{"ng-show" => "(product.variants.length == 0)"}
|
||||
%input{type: :number, value: 0, min: 0, name: "variants[{{product.master.id}}]", id: "variants_{{product.master.id}}"}
|
||||
%input{type: :number,
|
||||
value: 0,
|
||||
min: 0,
|
||||
max: "{{product.on_demand && 9999 || product.count_on_hand }}",
|
||||
name: "variants[{{product.master.id}}]",
|
||||
id: "variants_{{product.master.id}}"}
|
||||
%td.group_buy
|
||||
%span{"ng-show" => "product.group_buy"}
|
||||
Available
|
||||
@@ -37,7 +42,11 @@
|
||||
%td{colspan: 3}
|
||||
%td {{variant.options_text}}
|
||||
%td
|
||||
%input{type: :number, value: 0, min: 0, name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"}
|
||||
%input{type: :number,
|
||||
value: 0,
|
||||
min: 0,
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"}
|
||||
%td.group_buy
|
||||
%span{"ng-show" => "product.group_buy"}
|
||||
Available
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
collection @products
|
||||
attributes :id, :name, :description, :price, :permalink
|
||||
attributes :id, :name, :description, :price, :permalink, :count_on_hand, :on_demand
|
||||
|
||||
child :supplier do
|
||||
attributes :id, :name, :description
|
||||
end
|
||||
|
||||
child :master => :master do
|
||||
attributes :id, :is_master, :count_on_hand, :options_text
|
||||
child :images => :images do
|
||||
attributes :id, :alt
|
||||
node do |img|
|
||||
{:small_url => img.attachment.url(:small, false)}
|
||||
end
|
||||
end
|
||||
end
|
||||
child :variants => :variants do |variant|
|
||||
attributes :id, :is_master, :count_on_hand, :options_text
|
||||
attributes :id, :is_master, :count_on_hand, :options_text, :count_on_hand, :on_demand
|
||||
child :images => :images do
|
||||
attributes :id, :alt
|
||||
node do |img|
|
||||
{:small_url => img.attachment.url(:small, false)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
child :variants => :variants do |variant|
|
||||
attributes :id, :is_master, :count_on_hand, :options_text, :count_on_hand, :on_demand
|
||||
child :images => :images do
|
||||
attributes :id, :alt
|
||||
node do |img|
|
||||
|
||||
Reference in New Issue
Block a user