End of day commit
This commit is contained in:
@@ -14,22 +14,29 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
@get('orders').filter (o)->( o.get('needs_supplier_attention') )
|
||||
).property('orders.@each.state', 'active_section.id')
|
||||
|
||||
markListAsHelped: (id)->
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
list.is_helped()
|
||||
actions:
|
||||
markListAsHelped: (id)->
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
list.is_helped()
|
||||
|
||||
closeList: (id)->
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
list.close()
|
||||
closeList: (id)->
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
list.close()
|
||||
|
||||
markOrderDelivered: (id)->
|
||||
$.post('/supplier/order_is_delivered', order_id: id)
|
||||
if order = Qsupplier.App.Order.findCached(id)
|
||||
order.set('state', 'delivered')
|
||||
markOrderDelivered: (id)->
|
||||
$.post('/supplier/order_is_delivered', order_id: id)
|
||||
if order = Qsupplier.App.Order.findCached(id)
|
||||
order.set('state', 'delivered')
|
||||
|
||||
markOrderActive: (id)->
|
||||
$.post('/supplier/mark_order_in_process', order_id: id)
|
||||
if order = Qsupplier.App.Order.findCached(id)
|
||||
order.set('state', 'active')
|
||||
cancelOrder: (order)->
|
||||
$.post "/supplier/orders/#{order.id}/cancel"
|
||||
order.set 'state', 'cancelled'
|
||||
showList: (id)->
|
||||
@transitionToRoute 'list', id
|
||||
showListInfo: (view, link)->
|
||||
debugger
|
||||
|
||||
markOrderActive: (id)->
|
||||
$.post('/supplier/mark_order_in_process', order_id: id)
|
||||
if order = Qsupplier.App.Order.findCached(id)
|
||||
order.set('state', 'active')
|
||||
showListInfo: (view, link)->
|
||||
debugger
|
||||
|
||||
@@ -34,9 +34,12 @@ Qsupplier.App.List = DS.Model.extend
|
||||
@set 'needs_payment', true
|
||||
markIsPaid: ->
|
||||
@set 'needs_payment', false
|
||||
relevant_orders: (-> @get('orders').filter((o)->o.get('state') isnt 'cancelled')).property('orders.@each.state')
|
||||
active_orders: (-> @get('orders').filter((o)->o.get('state') is 'placed' or o.get('state') is 'active')).property('orders.@each.state')
|
||||
|
||||
total: (->
|
||||
@get('orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('orders.@each.total')
|
||||
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('relevant_orders.@each.total')
|
||||
|
||||
close: ->
|
||||
@markClosed()
|
||||
@@ -45,4 +48,4 @@ Qsupplier.App.List = DS.Model.extend
|
||||
is_helped: ->
|
||||
@markHelped()
|
||||
$.post Routes.supplier_mark_list_as_helped_path(), list_id: @id
|
||||
sorted_orders: (-> @get('orders').sortBy('created_at').reverseObjects()).property('orders.@each.isLoaded')
|
||||
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.@each.isLoaded')
|
||||
|
||||
@@ -19,6 +19,8 @@ Qsupplier.App.Order = DS.Model.extend
|
||||
|
||||
markClosed: ->
|
||||
@set 'state', 'closed'
|
||||
markCancelled: ->
|
||||
@set 'state', 'cancelled'
|
||||
total: (->
|
||||
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.price')
|
||||
|
||||
@@ -11,7 +11,7 @@ if list.closed_at
|
||||
.row
|
||||
each user in list.users
|
||||
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
|
||||
if list.orders
|
||||
if list.sorted_orders
|
||||
.list-orders-container
|
||||
each order in list.sorted_orders
|
||||
.list-order-container class=order.state
|
||||
|
||||
@@ -6,7 +6,7 @@ td.status-icons
|
||||
span.icon.needs-payment
|
||||
td.numeric.table_number {{view.content.table.number}}
|
||||
td.section_title {{view.content.section.title}}
|
||||
td.currency.total_list_amount {{currency view.content.price}}
|
||||
td.currency.total_list_amount {{currency view.content.total}}
|
||||
td.actions
|
||||
if view.content.needs_help
|
||||
button.mark_list_as_helped{ action markListAsHelped view.content.id}
|
||||
@@ -14,8 +14,5 @@ td.actions
|
||||
i.fa.fa-bell.fa-stack-small
|
||||
i.fa.fa-ban.revoke
|
||||
/span.button-text=t 'list.is_helped_button'
|
||||
button.close_list{ action closeList view.content.id}
|
||||
span.fa.fa-times.fa-2x
|
||||
span.button-text=t 'list.close_list'
|
||||
a.btn.hide href="/supplier/lists/{{unbound view.content.id}}"
|
||||
span.icon-list
|
||||
button.close_list{ action closeList view.content.id}: span
|
||||
button.show-list.button{action "showList" view.content.id}: span
|
||||
|
||||
@@ -21,3 +21,4 @@ td.actions
|
||||
/button.hide.mark-order-delivered{ action markOrderDelivered view.content.id}
|
||||
span.button-icon
|
||||
span.button-text= t 'order.being_served'
|
||||
button.remove-order{ action "cancelOrder" view.content }: span
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
.page-header
|
||||
div.dashboard-section-selection
|
||||
'{{view 'Qsupplier.App.HomeSectionSelectorView' selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name}}
|
||||
'{{view 'Qsupplier.App.HomeSectionJumperView'}}
|
||||
h3 {{t 'active_lists.title'}}
|
||||
Qsupplier.App.HomeSectionSelectorView selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name
|
||||
Qsupplier.App.HomeSectionJumperView
|
||||
h3=t 'active_lists.title'
|
||||
.well
|
||||
table.active-lists-table.table
|
||||
thead
|
||||
tr
|
||||
th.status-icons
|
||||
th.numeric {{t 'table_number'}}
|
||||
th {{t 'models.section'}}
|
||||
th.currency {{t 'active_lists.price'}}
|
||||
th.numeric=t 'table_number'
|
||||
th=t 'models.section'
|
||||
th.currency=t 'active_lists.price'
|
||||
th.actions
|
||||
tbody
|
||||
each list in controller.active_lists
|
||||
' {{view 'Qsupplier.App.ActiveListView' contentBinding="list"}}
|
||||
each list in controller.active_lists: Qsupplier.App.ActiveListView contentBinding="list"
|
||||
.page-header
|
||||
h3 {{t 'active_orders.title' }}
|
||||
h3=t 'active_orders.title'
|
||||
.well
|
||||
table.active-orders-table.table
|
||||
thead
|
||||
tr
|
||||
th.status-icons
|
||||
th {{t 'models.order'}}
|
||||
th.numeric {{t 'table_number'}}
|
||||
th {{t 'models.section'}}
|
||||
th.currency {{t 'active_orders.price'}}
|
||||
th=t 'models.order'
|
||||
th.numeric=t 'table_number'
|
||||
th=t 'models.section'
|
||||
th.currency=t 'active_orders.price'
|
||||
th.actions
|
||||
tbody
|
||||
each order in controller.active_orders
|
||||
' {{view 'Qsupplier.App.ActiveOrderView' contentBinding="order"}}
|
||||
each order in controller.active_orders: Qsupplier.App.ActiveOrderView contentBinding="order"
|
||||
|
||||
@@ -6,10 +6,13 @@ root.Qsupplier=
|
||||
console.log(e)
|
||||
if(e.event == 'new_order')
|
||||
if Qsupplier.App
|
||||
Qsupplier.App.store().pushPayload e.data
|
||||
#Qsupplier.App.Order.pushByAttriburtes(e.data.order)
|
||||
#for product_order in e.data.product_orders
|
||||
#Qsupplier.App.ProductOrder.pushByAttriburtes product_order, debug: true
|
||||
Qsupplier.App.store().pushPayload(e.data)
|
||||
# Fix for ember pushPayload bug not creating the proper relations/triggers
|
||||
setTimeout ->
|
||||
if order = Qsupplier.App.store().all('order').findProperty('id', e.data.order.id)
|
||||
list = order.get('list')
|
||||
list.get('orders').addRecord order
|
||||
, 100
|
||||
else if(e.event == 'list_needs_help')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.markNeedsHelp()
|
||||
@@ -57,6 +60,12 @@ root.Qsupplier=
|
||||
$('.supplier-orders-placed-count-number').text e.data.count
|
||||
else if e.event == 'list_changed_table'
|
||||
Qsupplier.App && Qsupplier.App.List.updateOrAdd(e.data.list)
|
||||
else if e.event == 'order_cancelled'
|
||||
if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
order.markCancelled()
|
||||
$('.supplier-orders-placed-count-number').text(e.data.orders_placed_count) if Number.isInteger(e.data.orders_placed_count)
|
||||
$('.supplier-orders-in-process-count-number').text(e.data.orders_in_process_count) if Number.isInteger(e.data.orders_in_process_count)
|
||||
|
||||
|
||||
# old stuff
|
||||
#list = new List(e.data.list)
|
||||
|
||||
Reference in New Issue
Block a user