Speccing and fixing user list loading and adding orders to other users
This commit is contained in:
@@ -68,6 +68,12 @@ App.ApplicationController = Ember.Controller.extend
|
||||
@set 'list.supplier.orders_in_process_count', data.count
|
||||
orders_placed_count: (data)->
|
||||
@set 'list.supplier.orders_placed_count', data.count
|
||||
new_order: (data)->
|
||||
return if @store.all('order').findProperty('id', data.order.id)
|
||||
@store.pushPayload data
|
||||
@store.findById('order', data.order.id).then (order)->
|
||||
list = order.get('list')
|
||||
list.get('orders').addObject(order)
|
||||
|
||||
|
||||
setCurrentList: (callback)->
|
||||
|
||||
@@ -6,6 +6,7 @@ module Users
|
||||
lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25)
|
||||
#lists.include_relation(:supplier)
|
||||
lists.reject!{|l| l.id == params[:exclude_list]} if params[:exclude_list].present?
|
||||
lists.reject!{|l| l.id == current_user.active_list_id } if current_user && current_user.active_list_id.present? # see spec Loading lists and switching to the order products view works, lists loading may unlink active list orders
|
||||
lists.include_relation(:users, :orders, :supplier)
|
||||
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||
end
|
||||
|
||||
+2
-1
@@ -273,7 +273,8 @@ class List
|
||||
save
|
||||
|
||||
|
||||
broadcast_users 'new_order', order: order.with_products_as_json, total_amount: price
|
||||
# broadcast_users 'new_order', order: order.with_products_as_json, total_amount: price
|
||||
broadcast_users 'new_order', OrderSerializer.new(order).as_json
|
||||
broadcast_users 'orders_placed_count', count: orders_placed_count
|
||||
|
||||
broadcast_supplier supplier.id, 'list_update', SupplierListSerializer.new(self).as_json
|
||||
|
||||
Reference in New Issue
Block a user