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