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)