Add supplier messages for new orders and sounds

This commit is contained in:
2015-01-23 14:40:58 +01:00
parent cf80f6ea31
commit cab883b3ce
87 changed files with 423 additions and 5 deletions
@@ -6,6 +6,7 @@
#= require shared-ember-helpers/all
#= require ./app
#= require ./controllers/modals/base_controller
#= require ion.sound
#= require_tree .
@$assets_path = '/assets/';
@EmberENV = {FEATURES: {'query-params-new': true}}
@@ -1,5 +1,6 @@
App.ApplicationController = Ember.Controller.extend
active_section: null
flash_message: ''
#init: ->
#success = (supplier)=>
## A supplier record with id current and with the content of the returned supplier is created
@@ -33,6 +33,11 @@ App.Order = DS.Model.extend
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.name')
display_with_table: (->
table = t('models.table').toLowerCase()
"#{@get('display')} #{table} #{@get('list.table.number')}".htmlSafe()
).property('display', 'list.table.number')
display_tag: (->
"<span class='display order-display order-#{@get('id')} #{@get('state')}'><span class='pre-display'></span>#{@get('display')}<span class='post-display'></span></span>".htmlSafe()
).property('display', 'state')
@@ -69,16 +69,36 @@ App.ApplicationRoute = Ember.Route.extend
body: options.body
cancel: options.cancel
ok: options.ok
newOrder: (order_id)->
@store.findById('order', order_id).then (order)=>
controller = @controllerFor('application')
return if controller.get('active_section.id') and order.get('section.id') isnt controller.get('active_section.id')
$('body').addClass('new-order')
controller.set 'flash_message', order.get('display_with_table')
setTimeout (-> $('body').removeClass('new-order')), 4000
try ion.sound.play('water_droplet')
events:
list_needs_help: (data) -> list.markNeedsHelp() if list = @store.getById('list', data.id)
list_needs_payment: (data) -> list.markNeedsPayment() if list = @store.getById('list', data.id)
list_needs_help: (data) ->
if list = @store.getById('list', data.id)
list.markNeedsHelp()
controller = @controllerFor('application')
return if controller.get('active_section.id') and list.get('section.id') isnt controller.get('active_section.id')
try ion.sound.play 'bell_ring'
list_needs_payment: (data) ->
if list = @store.getById('list', data.id)
list.markNeedsPayment()
controller = @controllerFor('application')
return if controller.get('active_section.id') and list.get('section.id') isnt controller.get('active_section.id')
try ion.sound.play 'water_droplet_3'
list_is_paid: (data) -> list.markIsPaid() if list = @store.getById('list', data.id)
list_update: (data) ->
if data.new_order_id
@send 'newOrder', data.new_order_id
@store.pushPayload('list', data)
# Fix broken reference. TODO: remove this when single source of
# truth is working
@store.findById('list', e.data.list.id).then (list)->
list.get('table').then (table)->table.set('active_list', list)
#@store.findById('list', data.list.id).then (list)->
# list.get('table').then (table)->table.set('active_list', list)
list_changed_table: (data) -> @store.pushPayload('list', lists: [data.list])
list_closed: (data) -> list.markClosed() if list = @store.getById('list', data.id)
list_helped: (data) -> list.markHelped() if list = @store.getById('list', data.id)
@@ -1,3 +1,4 @@
= partial "global/top_menu"
.main-section= outlet
= view flash_message
= outlet modal
@@ -0,0 +1 @@
= flash_message
@@ -11,6 +11,14 @@ App.ApplicationView = Ember.View.extend
menu.show().animate left: 0
toggle.animate left: 222 - 30, -> $(@).addClass('open')
ion.sound
sounds: [
{name: "bell_ring", volume: 0.8}
{name: "water_droplet"}
{name: "water_droplet_3"}
]
path: "/sounds/"
preload: true
#selector_mappings =
#'.top-menu-root': '/'
#'.top-menu-lists': 'lists'
@@ -0,0 +1,10 @@
App.FlashMessageView = Ember.View.extend
templateName: 'flash_message'
classNames: ['flash-message']
classNameBindings: ['message:active']
message: (-> @get('controller.flash_message')).property('controller.flash_message')
inactivator: (->
if @get('message')
Ember.run.later (=> @set 'controller.flash_message', ''), 4000
).observes('message')
@@ -1,6 +1,7 @@
//= require qtip
//= require_directory ../base1-shared
//= require pickdate
@import bourbon
@import ./qconstants
@import ./foundation_and_overrides
@import ./qstructure
@@ -0,0 +1,25 @@
.flash-message
position: fixed
top: 60px
right: -440px
background-color: rgba(200,200,200,0.8)
padding: 20px
width: 400px
border-radius: 9999px
font-weight: bold
font-size: 1.4
+animation(flashMessageInactive 0.5s)
&.active
+animation(flashMessageActive 0.5s)
right: 20px
+keyframes(flashMessageActive)
from
right: -440px
to
right: 20px
+keyframes(flashMessageInactive)
from
right: 20px
to
right: -440px
+1 -1
View File
@@ -286,7 +286,7 @@ class List
broadcast_users 'new_order', UserExtendedListSerializer.new(order.list).as_json
# broadcast_users 'orders_placed_count', count: orders_placed_count
broadcast_supplier supplier.id, 'list_update', SupplierListSerializer.new(self).as_json
broadcast_supplier supplier.id, 'list_update', SupplierListSerializer.new(self).as_json.merge(new_order_id: order.id)
# broadcast_supplier supplier.id, 'new_order', OrderSerializer.new(order)
broadcast_supplier supplier.id, 'orders_placed_count', count: orders_placed_count
order