many changes

This commit is contained in:
2012-12-03 18:39:36 +01:00
parent e3dc6a7c68
commit 7d64ab2022
37 changed files with 540 additions and 101 deletions
+11 -13
View File
@@ -85,11 +85,17 @@ class UserController < ApplicationController
handle_message_params
end
format.json do
products = list.supplier.products
products.include_relation(:product_categories)
products.sort_by!{|p| p.product_category.try(:position) || 90000}
h = products.inject({table_number: list.table_number, supplier_name: @supplier.name}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
h = ProductCategory.for_user(current_user, table: list.table, list: list) # list is performance parameter
render json: h
#products = list.supplier.products
#product_categories = list.supplier.product_categories
#other = product_categories.find(&:other?) || (product_categories << ProductCategory.other).last # Container for non categorized products
#product_categories.sort_by!{|p| p.product_category.try(:position) || 90000}
#h = {table_number: list.table_number, supplier_name: @supplier.name}
#h[:categories] = product_categories.map{|pc| {pc.name => pc.product_ids.map{|p| p.as_json}}}
#){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
#render json: h
end
end
end
@@ -100,15 +106,7 @@ class UserController < ApplicationController
format.html do
end
format.json do
products = @table.supplier.products
products.include_relation(:product_categories)
products.sort_by!{|p| p.product_category.try(:position) || 90000}
h = products.inject({
table_number: @table.number,
supplier_name: @table.supplier.name,
has_occupied_info: true,
is_occupied: @table.occupied?
}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
h = ProductCategory.for_user(current_user, table: @table)
render json: h
end
end