Qwaiter supplier on Ember 1.0

This commit is contained in:
2013-09-30 17:49:22 +02:00
parent 6d7647c2c5
commit 8ea2e79dc2
44 changed files with 378 additions and 156 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ private
end
def set_locale
I18n.locale = (params[:locale].presence || :nl).to_sym
I18n.locale = (params[:locale].presence || Rails.configuration.i18n.default_locale).to_sym
end
def layout_by_resource
+2 -2
View File
@@ -43,8 +43,8 @@ class SupplierController < ApplicationController
ho = {products: []}
order_total = 0.0
for product_order in order.product_orders
order_total += (product_order.amount * product_order.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
order_total += (product_order.quantity * product_order.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.quantity, price: product_order.price}
end
ho[:total_amount] = order_total.round(2)
ho[:state] = order.state
@@ -33,7 +33,7 @@ module Suppliers
respond_to do |format|
format.html {}
format.json do
render json: {list: @list.with_orders_as_json}
render json: @list
end
end
end
@@ -6,12 +6,19 @@ module Suppliers
if params[:state] == 'active'
@orders = Order.active_for_supplier(current_supplier.id)
else
@orders = Order.for_supplier(current_supplier, page: params[:page], per_page: params['per_page'] || 10)
@orders = Order.for_supplier(current_supplier, page: params[:page], per_page: params['per_page'] || 25)
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: {orders: @orders.map(&:with_products_as_json)} }
format.json { render json: @orders }
end
end
def show
@order = current_supplier.find_order(params[:id])
respond_to do |format|
format.json { render json: @order }
end
end
end