Making our form on_demand and count_on_hand aware

This commit is contained in:
Will Marshall
2014-01-17 15:07:43 +11:00
parent ef00927885
commit f5777bc7a1
2 changed files with 24 additions and 13 deletions

View File

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

View File

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