End of day commit

This commit is contained in:
2015-09-09 20:21:52 +02:00
parent 968d042501
commit 36e5b21b13
9 changed files with 58 additions and 29 deletions
@@ -3,7 +3,8 @@ App.FlashMessageComponent = Ember.Component.extend
classNames: ['flash-message']
classNameBindings: ['message:active']
message: Ember.computed.alias 'globals.flash_message'
click: -> @set 'globals.flash_message', ''
inactivator: (->
if @get('message')
Ember.run.later((=> @set 'message', ''), 4000)
Ember.run.later((=> @set 'globals.flash_message', ''), 4000)
).observes('message')
@@ -13,13 +13,18 @@ App.IndexController = Ember.Controller.extend
lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
).property('lists.@each.state', 'active_section.id')
active_orders: (->
if @get('active_section.id')
orders = @get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
else
orders = @get('orders').filter (o)->( o.get('needs_supplier_attention') )
orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
).property('orders.@each.state', 'active_section.id')
active_orders: Ember.computed 'active_lists.[]', 'active_orders.@each.state', ->
orders = Ember.A()
@get('active_lists').forEach (list)->
list.get('orders').filterBy('needs_supplier_attention').forEach (order)->
orders.push order
return orders
#if @get('active_section.id')
# orders = @get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
#else
# orders = @get('orders').filter (o)->( o.get('needs_supplier_attention') )
#orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
#).property('orders.@each.state', 'active_section.id')
show_lists_table: Ember.computed 'show_lists', 'active_lists.[]', ->
@get('show_lists') and @get('active_lists.length')
@@ -3,13 +3,14 @@ App.ProductOrder = DS.Model.extend
quantity: attr 'number', defaultValue: 1
price: attr 'number'
product_variant: attr('string')
product_name: attr('string')
product: DS.belongsTo('product', async: true)
order: DS.belongsTo('order')
increment: ->
@set('quantity', @get('quantity') + 1)
total: (-> @get('quantity') * @get('price')).property('quantity', 'price')
display: Ember.computed 'quantity', 'product_variant', 'product.name', ->
disp = "#{@get('quantity')} x #{@get('product.name')}"
display: Ember.computed 'quantity', 'product_variant', 'product_name', ->
disp = "#{@get('quantity')} x #{@get('product_name')}"
if variant = @get('product_variant')
disp = "#{disp} (#{variant})"
disp.htmlSafe()
@@ -3,9 +3,9 @@ App.Section = DS.Model.extend
title: attr 'string'
width: attr 'number'
height: attr 'number'
tables: DS.hasMany('table')
section_elements: DS.hasMany('section-element')
section_areas: DS.hasMany('section-area')
tables: DS.hasMany('table', async: false)
section_elements: DS.hasMany('section-element', async: false)
section_areas: DS.hasMany('section-area', async: false)
editmode: false
@@ -88,13 +88,13 @@ App.ApplicationRoute = Ember.Route.extend
body: options.body
cancel: options.cancel
ok: options.ok
newOrder: (order_id)->
if order = @store.peekRecord('order', order_id)
return if @get('globals.active_section.id') and order.get('section.id') isnt @get('globals.active_section.id')
$('body').addClass('new-order')
@set 'globals.flash_message', order.get('display_with_table')
setTimeout (-> $('body').removeClass('new-order')), 4000
try ion.sound.play('water_droplet')
#newOrder: (order_id)->
# if order = @store.peekRecord('order', order_id)
# return if @get('globals.active_section.id') and order.get('section.id') isnt @get('globals.active_section.id')
# $('body').addClass('new-order')
# @set 'globals.flash_message', order.get('display_with_table')
# setTimeout (-> $('body').removeClass('new-order')), 4000
# try ion.sound.play('water_droplet')
showDashboardOrders: (section)->
@set('globals.active_section', section)
@transitionTo 'index'
@@ -126,11 +126,17 @@ App.ApplicationRoute = Ember.Route.extend
return if @get('globals.active_section.id') and list.get('section.id') isnt @get('globals.active_section.id')
try ion.sound.play 'water_droplet_3'
list_is_paid: (data) -> list.isPaid() if list = @store.peekRecord('list', data.id)
list_update: (data) ->
new_order_id = data.new_order_id
delete data.new_order_id
@store.pushPayload(data)
@send 'newOrder', new_order_id if new_order_id
new_order: (data) ->
if data.payload
@store.pushPayload(data.payload)
if order_id = data.payload.data.id
order = @store.peekRecord('order', order_id)
return if @get('globals.active_section.id') and order.get('section.id') isnt @get('globals.active_section.id')
@set 'globals.flash_message', order.get('display_with_table')
try ion.sound.play('water_droplet')
new_list: (data)->
debugger
try ion.sound.play('water_droplet')
list_changed_table: (data) -> @store.pushPayload('list', lists: [data.list])
list_closed: (data) -> list.isClosed() if list = @store.peekRecord('list', data.id)
list_helped: (data) -> list.isHelped() if list = @store.peekRecord('list', data.id)
@@ -8,6 +8,7 @@
border-radius: 9999px
font-weight: bold
font-size: 1.4
z-index: 8976
+animation(flashMessageInactive 0.5s)
&.active
+animation(flashMessageActive 0.5s)
@@ -28,8 +28,7 @@ module Suppliers
orders.product_orders
orders.product_orders.product
users
join_requests
join_requests.user
section
table
])
end
+17 -2
View File
@@ -309,14 +309,29 @@ class List
if first_order
# broadcast_users 'orders_placed_count', count: orders_placed_count
broadcast_supplier supplier.id, 'list_update', Supplier::ListSerializer.new(self).as_json.merge(new_order_id: order.id)
supplier_payload = JSONAPI::Serializer.serialize(self, serializer: Suppliers::ListSerializer, include: %w[
orders
orders.list
orders.user
orders.product_orders
orders.product_orders.product
users
section
table
])
# broadcast_supplier supplier.id, 'new_order', OrderSerializer.new(order)
broadcast_supplier supplier.id, 'new_list', supplier_orders_placed_count: orders_placed_count, payload: supplier_payload
else
# broadcast_users 'new_order', order: order.with_products_as_json, total_amount: price
user_payload = JSONAPI::Serializer.serialize(order, serializer: Users::OrderSerializer, include: %w[list user product_orders product_orders.order])
supplier_payload = JSONAPI::Serializer.serialize(order, serializer: Suppliers::OrderSerializer, include: %w[
user
product_orders
])
broadcast_users 'new_order', user_payload
broadcast_supplier supplier.id, 'list_update', Supplier::ListSerializer.new(self).as_json.merge(new_order_id: order.id)
broadcast_supplier supplier.id, 'new_order', supplier_orders_placed_count: orders_placed_count, payload: supplier_payload
end
broadcast_supplier supplier.id, 'orders_placed_count', count: orders_placed_count
#broadcast_supplier supplier.id, 'orders_placed_count', count: orders_placed_count # done inside new order payload
order
end
@@ -6,4 +6,5 @@ class Suppliers::ListSerializer
has_many :join_requests, serializer: Suppliers::JoinRequestSerializer
has_many :users, serializer: Suppliers::UserSerializer
has_one :table, serializer: Suppliers::TableSerializer
has_one :section, serializer: Suppliers::SectionSerializer
end