End of day commit
This commit is contained in:
+9
-9
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: git://github.com/bterkuile/cmtool.git
|
remote: git://github.com/bterkuile/cmtool.git
|
||||||
revision: 372231b1b7340617d9c603f52029df1c787001f1
|
revision: a428d41955884c6d8d1501c7a89e6346ee5ec420
|
||||||
specs:
|
specs:
|
||||||
cmtool (1.0.0)
|
cmtool (1.0.0)
|
||||||
bourbon
|
bourbon
|
||||||
@@ -37,7 +37,7 @@ GIT
|
|||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/bterkuile/simply_stored.git
|
remote: git://github.com/bterkuile/simply_stored.git
|
||||||
revision: e0e72e8e73c59666191d578408572ed8f5de9e42
|
revision: 354fde89a88c1384ccc9d82989e3f05ac6977bd1
|
||||||
specs:
|
specs:
|
||||||
simply_stored (1.0.0)
|
simply_stored (1.0.0)
|
||||||
activesupport
|
activesupport
|
||||||
@@ -172,7 +172,7 @@ GEM
|
|||||||
handlebars-source (> 1.0.0)
|
handlebars-source (> 1.0.0)
|
||||||
jquery-rails (>= 1.0.17)
|
jquery-rails (>= 1.0.17)
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
ember-source (1.6.0)
|
ember-source (1.6.1)
|
||||||
handlebars-source (~> 1.0)
|
handlebars-source (~> 1.0)
|
||||||
emblem-rails (0.2.1)
|
emblem-rails (0.2.1)
|
||||||
barber-emblem (~> 0.1.1)
|
barber-emblem (~> 0.1.1)
|
||||||
@@ -201,7 +201,7 @@ GEM
|
|||||||
websocket-driver (>= 0.3.1)
|
websocket-driver (>= 0.3.1)
|
||||||
font-awesome-rails (4.1.0.0)
|
font-awesome-rails (4.1.0.0)
|
||||||
railties (>= 3.2, < 5.0)
|
railties (>= 3.2, < 5.0)
|
||||||
foundation-rails (5.3.0.1)
|
foundation-rails (5.3.1.0)
|
||||||
railties (>= 3.1.0)
|
railties (>= 3.1.0)
|
||||||
sass (>= 3.2.0)
|
sass (>= 3.2.0)
|
||||||
fuubar (1.3.3)
|
fuubar (1.3.3)
|
||||||
@@ -255,7 +255,7 @@ GEM
|
|||||||
net-scp (1.2.1)
|
net-scp (1.2.1)
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh (2.9.1)
|
net-ssh (2.9.1)
|
||||||
nokogiri (1.6.2.1)
|
nokogiri (1.6.3)
|
||||||
mini_portile (= 0.6.0)
|
mini_portile (= 0.6.0)
|
||||||
oauth2 (1.0.0)
|
oauth2 (1.0.0)
|
||||||
faraday (>= 0.8, < 0.10)
|
faraday (>= 0.8, < 0.10)
|
||||||
@@ -347,7 +347,7 @@ GEM
|
|||||||
simple_form (3.0.2)
|
simple_form (3.0.2)
|
||||||
actionpack (~> 4.0)
|
actionpack (~> 4.0)
|
||||||
activemodel (~> 4.0)
|
activemodel (~> 4.0)
|
||||||
simplecov (0.8.2)
|
simplecov (0.9.0)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1.0)
|
||||||
multi_json
|
multi_json
|
||||||
simplecov-html (~> 0.8.0)
|
simplecov-html (~> 0.8.0)
|
||||||
@@ -360,7 +360,7 @@ GEM
|
|||||||
activesupport (>= 3.0, < 4.2)
|
activesupport (>= 3.0, < 4.2)
|
||||||
railties (>= 3.0, < 4.2)
|
railties (>= 3.0, < 4.2)
|
||||||
slim (~> 2.0)
|
slim (~> 2.0)
|
||||||
slop (3.5.0)
|
slop (3.6.0)
|
||||||
spring (1.1.3)
|
spring (1.1.3)
|
||||||
spring-commands-rspec (1.0.2)
|
spring-commands-rspec (1.0.2)
|
||||||
spring (>= 0.9.1)
|
spring (>= 0.9.1)
|
||||||
@@ -386,7 +386,7 @@ GEM
|
|||||||
thor (0.19.1)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.4)
|
thread_safe (0.3.4)
|
||||||
tilt (1.4.1)
|
tilt (1.4.1)
|
||||||
tinymce-rails (4.1.0)
|
tinymce-rails (4.1.2)
|
||||||
railties (>= 3.1.1)
|
railties (>= 3.1.1)
|
||||||
treetop (1.4.15)
|
treetop (1.4.15)
|
||||||
polyglot
|
polyglot
|
||||||
@@ -396,7 +396,7 @@ GEM
|
|||||||
rspec (>= 2.0, < 4.0)
|
rspec (>= 2.0, < 4.0)
|
||||||
tzinfo (1.2.1)
|
tzinfo (1.2.1)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
uglifier (2.5.1)
|
uglifier (2.5.3)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
json (>= 1.8.0)
|
json (>= 1.8.0)
|
||||||
warden (1.2.3)
|
warden (1.2.3)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
Ember.Handlebars.helper 'time', (time, params..., options = {})->
|
Ember.Handlebars.helper 'time', (time, params..., options = {})->
|
||||||
return '' unless time
|
return '' unless time
|
||||||
|
time = new Date(time) if typeof(time) is "string"
|
||||||
iso = time.toISOString()
|
iso = time.toISOString()
|
||||||
tag = if options.bare then iso else $("<span data-time=\"#{iso}\"></span>").text(moment(iso).format(options.format || 'dd D MMM HH:MM')).get(0).outerHTML
|
tag = if options.bare then iso else $("<span data-time=\"#{iso}\"></span>").text(moment(iso).format(options.format || 'dd D MMM HH:MM')).get(0).outerHTML
|
||||||
new Handlebars.SafeString tag
|
new Handlebars.SafeString tag
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
|||||||
@get('orders').filter (o)->( o.get('needs_supplier_attention') )
|
@get('orders').filter (o)->( o.get('needs_supplier_attention') )
|
||||||
).property('orders.@each.state', 'active_section.id')
|
).property('orders.@each.state', 'active_section.id')
|
||||||
|
|
||||||
|
actions:
|
||||||
markListAsHelped: (id)->
|
markListAsHelped: (id)->
|
||||||
if list = Qsupplier.App.List.findCached(id)
|
if list = Qsupplier.App.List.findCached(id)
|
||||||
list.is_helped()
|
list.is_helped()
|
||||||
@@ -31,5 +32,11 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
|||||||
$.post('/supplier/mark_order_in_process', order_id: id)
|
$.post('/supplier/mark_order_in_process', order_id: id)
|
||||||
if order = Qsupplier.App.Order.findCached(id)
|
if order = Qsupplier.App.Order.findCached(id)
|
||||||
order.set('state', 'active')
|
order.set('state', 'active')
|
||||||
|
cancelOrder: (order)->
|
||||||
|
$.post "/supplier/orders/#{order.id}/cancel"
|
||||||
|
order.set 'state', 'cancelled'
|
||||||
|
showList: (id)->
|
||||||
|
@transitionToRoute 'list', id
|
||||||
showListInfo: (view, link)->
|
showListInfo: (view, link)->
|
||||||
debugger
|
debugger
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,12 @@ Qsupplier.App.List = DS.Model.extend
|
|||||||
@set 'needs_payment', true
|
@set 'needs_payment', true
|
||||||
markIsPaid: ->
|
markIsPaid: ->
|
||||||
@set 'needs_payment', false
|
@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: (->
|
total: (->
|
||||||
@get('orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||||
).property('orders.@each.total')
|
).property('relevant_orders.@each.total')
|
||||||
|
|
||||||
close: ->
|
close: ->
|
||||||
@markClosed()
|
@markClosed()
|
||||||
@@ -45,4 +48,4 @@ Qsupplier.App.List = DS.Model.extend
|
|||||||
is_helped: ->
|
is_helped: ->
|
||||||
@markHelped()
|
@markHelped()
|
||||||
$.post Routes.supplier_mark_list_as_helped_path(), list_id: @id
|
$.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: ->
|
markClosed: ->
|
||||||
@set 'state', 'closed'
|
@set 'state', 'closed'
|
||||||
|
markCancelled: ->
|
||||||
|
@set 'state', 'cancelled'
|
||||||
total: (->
|
total: (->
|
||||||
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||||
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.price')
|
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.price')
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if list.closed_at
|
|||||||
.row
|
.row
|
||||||
each user in list.users
|
each user in list.users
|
||||||
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
|
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
|
.list-orders-container
|
||||||
each order in list.sorted_orders
|
each order in list.sorted_orders
|
||||||
.list-order-container class=order.state
|
.list-order-container class=order.state
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ td.status-icons
|
|||||||
span.icon.needs-payment
|
span.icon.needs-payment
|
||||||
td.numeric.table_number {{view.content.table.number}}
|
td.numeric.table_number {{view.content.table.number}}
|
||||||
td.section_title {{view.content.section.title}}
|
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
|
td.actions
|
||||||
if view.content.needs_help
|
if view.content.needs_help
|
||||||
button.mark_list_as_helped{ action markListAsHelped view.content.id}
|
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-bell.fa-stack-small
|
||||||
i.fa.fa-ban.revoke
|
i.fa.fa-ban.revoke
|
||||||
/span.button-text=t 'list.is_helped_button'
|
/span.button-text=t 'list.is_helped_button'
|
||||||
button.close_list{ action closeList view.content.id}
|
button.close_list{ action closeList view.content.id}: span
|
||||||
span.fa.fa-times.fa-2x
|
button.show-list.button{action "showList" view.content.id}: span
|
||||||
span.button-text=t 'list.close_list'
|
|
||||||
a.btn.hide href="/supplier/lists/{{unbound view.content.id}}"
|
|
||||||
span.icon-list
|
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ td.actions
|
|||||||
/button.hide.mark-order-delivered{ action markOrderDelivered view.content.id}
|
/button.hide.mark-order-delivered{ action markOrderDelivered view.content.id}
|
||||||
span.button-icon
|
span.button-icon
|
||||||
span.button-text= t 'order.being_served'
|
span.button-text= t 'order.being_served'
|
||||||
|
button.remove-order{ action "cancelOrder" view.content }: span
|
||||||
|
|||||||
@@ -1,32 +1,30 @@
|
|||||||
.page-header
|
.page-header
|
||||||
div.dashboard-section-selection
|
div.dashboard-section-selection
|
||||||
'{{view 'Qsupplier.App.HomeSectionSelectorView' selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name}}
|
Qsupplier.App.HomeSectionSelectorView selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name
|
||||||
'{{view 'Qsupplier.App.HomeSectionJumperView'}}
|
Qsupplier.App.HomeSectionJumperView
|
||||||
h3 {{t 'active_lists.title'}}
|
h3=t 'active_lists.title'
|
||||||
.well
|
.well
|
||||||
table.active-lists-table.table
|
table.active-lists-table.table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th.status-icons
|
th.status-icons
|
||||||
th.numeric {{t 'table_number'}}
|
th.numeric=t 'table_number'
|
||||||
th {{t 'models.section'}}
|
th=t 'models.section'
|
||||||
th.currency {{t 'active_lists.price'}}
|
th.currency=t 'active_lists.price'
|
||||||
th.actions
|
th.actions
|
||||||
tbody
|
tbody
|
||||||
each list in controller.active_lists
|
each list in controller.active_lists: Qsupplier.App.ActiveListView contentBinding="list"
|
||||||
' {{view 'Qsupplier.App.ActiveListView' contentBinding="list"}}
|
|
||||||
.page-header
|
.page-header
|
||||||
h3 {{t 'active_orders.title' }}
|
h3=t 'active_orders.title'
|
||||||
.well
|
.well
|
||||||
table.active-orders-table.table
|
table.active-orders-table.table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th.status-icons
|
th.status-icons
|
||||||
th {{t 'models.order'}}
|
th=t 'models.order'
|
||||||
th.numeric {{t 'table_number'}}
|
th.numeric=t 'table_number'
|
||||||
th {{t 'models.section'}}
|
th=t 'models.section'
|
||||||
th.currency {{t 'active_orders.price'}}
|
th.currency=t 'active_orders.price'
|
||||||
th.actions
|
th.actions
|
||||||
tbody
|
tbody
|
||||||
each order in controller.active_orders
|
each order in controller.active_orders: Qsupplier.App.ActiveOrderView contentBinding="order"
|
||||||
' {{view 'Qsupplier.App.ActiveOrderView' contentBinding="order"}}
|
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ root.Qsupplier=
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
if(e.event == 'new_order')
|
if(e.event == 'new_order')
|
||||||
if Qsupplier.App
|
if Qsupplier.App
|
||||||
Qsupplier.App.store().pushPayload e.data
|
Qsupplier.App.store().pushPayload(e.data)
|
||||||
#Qsupplier.App.Order.pushByAttriburtes(e.data.order)
|
# Fix for ember pushPayload bug not creating the proper relations/triggers
|
||||||
#for product_order in e.data.product_orders
|
setTimeout ->
|
||||||
#Qsupplier.App.ProductOrder.pushByAttriburtes product_order, debug: true
|
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')
|
else if(e.event == 'list_needs_help')
|
||||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||||
list.markNeedsHelp()
|
list.markNeedsHelp()
|
||||||
@@ -57,6 +60,12 @@ root.Qsupplier=
|
|||||||
$('.supplier-orders-placed-count-number').text e.data.count
|
$('.supplier-orders-placed-count-number').text e.data.count
|
||||||
else if e.event == 'list_changed_table'
|
else if e.event == 'list_changed_table'
|
||||||
Qsupplier.App && Qsupplier.App.List.updateOrAdd(e.data.list)
|
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
|
# old stuff
|
||||||
#list = new List(e.data.list)
|
#list = new List(e.data.list)
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ App.List = DS.Model.extend
|
|||||||
join_requests: DS.hasMany('join_request')
|
join_requests: DS.hasMany('join_request')
|
||||||
users: DS.hasMany('user')
|
users: DS.hasMany('user')
|
||||||
|
|
||||||
total: (->
|
|
||||||
@get('orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
|
||||||
).property('orders.@each.total')
|
|
||||||
|
|
||||||
is_extended_version: ->
|
is_extended_version: ->
|
||||||
@get('extended_version')
|
@get('extended_version')
|
||||||
|
relevant_orders: (-> @get('orders').filter((o)->o.get('state') isnt 'cancelled')).property('orders.@each.state')
|
||||||
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')
|
||||||
|
total: (->
|
||||||
|
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||||
|
).property('relevant_orders.@each.total')
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
.dashboard-section-selection
|
|
||||||
float: right
|
|
||||||
min-width: 124px
|
|
||||||
select
|
|
||||||
width: calc(100% - 30px)
|
|
||||||
.active-lists-table
|
|
||||||
width: 100%
|
|
||||||
.mark_list_as_helped
|
|
||||||
+button-icon-only
|
|
||||||
.close_list
|
|
||||||
+button-icon-only
|
|
||||||
|
|
||||||
.active-orders-table
|
|
||||||
width: 100%
|
|
||||||
.mark_order_active
|
|
||||||
+button-icon-only
|
|
||||||
margin-right: 0.6em
|
|
||||||
.mark_order_delivered
|
|
||||||
+button-icon-only
|
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
@import ./foundation_and_overrides
|
@import ./foundation_and_overrides
|
||||||
@import ./qstructure
|
@import ./qstructure
|
||||||
@import ./qicons
|
@import ./qicons
|
||||||
@import ./qdashboard
|
|
||||||
@import ./qdisplays
|
@import ./qdisplays
|
||||||
@import ./form_actions
|
@import ./form_actions
|
||||||
@import ./components/*
|
@import ./components/*
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
$button-spacing: 8px
|
||||||
|
.dashboard-section-selection
|
||||||
|
float: right
|
||||||
|
min-width: 124px
|
||||||
|
select
|
||||||
|
width: calc(100% - 30px)
|
||||||
|
.active-lists-table
|
||||||
|
width: 100%
|
||||||
|
.mark_list_as_helped
|
||||||
|
+button-icon-only
|
||||||
|
margin-right: $button-spacing
|
||||||
|
.close_list
|
||||||
|
+button-icon-only
|
||||||
|
span
|
||||||
|
@extend .fa
|
||||||
|
@extend .fa-2x
|
||||||
|
@extend .fa-times // This is not good!!!
|
||||||
|
.show-list
|
||||||
|
+button-icon-only
|
||||||
|
margin-left: $button-spacing
|
||||||
|
span
|
||||||
|
@extend .fa
|
||||||
|
@extend .fa-2x
|
||||||
|
@extend .fa-list
|
||||||
|
|
||||||
|
.active-orders-table
|
||||||
|
width: 100%
|
||||||
|
.mark_order_active
|
||||||
|
+button-icon-only
|
||||||
|
margin-right: 0.6em
|
||||||
|
.mark_order_delivered
|
||||||
|
+button-icon-only
|
||||||
|
.remove-order
|
||||||
|
+button-icon-only
|
||||||
|
background-color: $alert-color
|
||||||
|
margin-left: $button-spacing
|
||||||
|
span
|
||||||
|
@extend .fa
|
||||||
|
@extend .fa-2x
|
||||||
|
@extend .fa-times
|
||||||
@@ -15,7 +15,7 @@ module Suppliers
|
|||||||
@end_time += current_supplier.night_offset.to_f.hours
|
@end_time += current_supplier.night_offset.to_f.hours
|
||||||
end
|
end
|
||||||
@lists = List.for_supplier_created_at current_supplier, @start_time..@end_time
|
@lists = List.for_supplier_created_at current_supplier, @start_time..@end_time
|
||||||
@lists.include_relation(:table) # for number
|
#@lists.include_relation(:table) # for number
|
||||||
else
|
else
|
||||||
@lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25)
|
@lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ module Suppliers
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cancel
|
||||||
|
@order = current_supplier.find_order(params[:id])
|
||||||
|
@order.cancel!
|
||||||
|
render json: @order
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@order = current_supplier.find_order(params[:id])
|
@order = current_supplier.find_order(params[:id])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
+6
-3
@@ -268,10 +268,14 @@ class List
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def relevant_orders
|
||||||
|
orders.reject(&:cancelled?)
|
||||||
|
end
|
||||||
|
|
||||||
# Store the final list price in a property
|
# Store the final list price in a property
|
||||||
def set_price
|
def set_price
|
||||||
list_total = 0.0
|
list_total = 0.0
|
||||||
for order in orders
|
for order in relevant_orders
|
||||||
order_total = 0.0
|
order_total = 0.0
|
||||||
for product_order in order.product_orders
|
for product_order in order.product_orders
|
||||||
order_total += (product_order.quantity * product_order.price).round(2)
|
order_total += (product_order.quantity * product_order.price).round(2)
|
||||||
@@ -408,8 +412,7 @@ class List
|
|||||||
@with_info_as_json = hl
|
@with_info_as_json = hl
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
# should not be private, called from order as well
|
||||||
|
|
||||||
def broadcast_users(message, content = {})
|
def broadcast_users(message, content = {})
|
||||||
for user_id in Array.wrap(user_ids)
|
for user_id in Array.wrap(user_ids)
|
||||||
broadcast_user user_id, message, content
|
broadcast_user user_id, message, content
|
||||||
|
|||||||
@@ -106,6 +106,28 @@ class Order
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cancel!
|
||||||
|
original_state = state.inquiry
|
||||||
|
self.state = 'cancelled' if placed? || active?
|
||||||
|
if save
|
||||||
|
broadcast_options = {id: id}
|
||||||
|
if original_state.placed?
|
||||||
|
reduced_count = supplier.decrement_orders_placed_count!
|
||||||
|
broadcast_options[:orders_placed_count] = reduced_count
|
||||||
|
elsif original_state.active?
|
||||||
|
reduced_count = supplier.decrement_orders_in_process_count!
|
||||||
|
broadcast_options[:orders_in_process_count] = reduced_count
|
||||||
|
end
|
||||||
|
list.broadcast_users 'order_cancelled', broadcast_options
|
||||||
|
broadcast_supplier supplier_id, 'order_cancelled', broadcast_options
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def cancelled?
|
||||||
|
state == 'cancelled'
|
||||||
|
end
|
||||||
|
|
||||||
|
#TODO fix me
|
||||||
def close!
|
def close!
|
||||||
self.state = 'closed' if placed? || active?
|
self.state = 'closed' if placed? || active?
|
||||||
if save
|
if save
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ html lang="en"
|
|||||||
= render 'suppliers/application/head'
|
= render 'suppliers/application/head'
|
||||||
= javascript_include_tag "supplier/foundation1/application"
|
= javascript_include_tag "supplier/foundation1/application"
|
||||||
= yield :head
|
= yield :head
|
||||||
= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places&language=#{I18n.locale}"
|
/= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places&language=#{I18n.locale}"
|
||||||
javascript:
|
javascript:
|
||||||
supplier_id="#{current_supplier.id}";
|
supplier_id="#{current_supplier.id}";
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -135,7 +135,11 @@ Qwaiter::Application.routes.draw do
|
|||||||
post :sort
|
post :sort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :orders, only: [:index, :show]
|
resources :orders, only: [:index, :show] do
|
||||||
|
member do
|
||||||
|
post :cancel
|
||||||
|
end
|
||||||
|
end
|
||||||
root to: 'sections#index'
|
root to: 'sections#index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ module Qwaiter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.incr(key, options = {})
|
def self.incr(key, options = {})
|
||||||
options[:initial] ||= 0
|
options[:initial] ||= 1
|
||||||
connection.incr(key, options) rescue 1
|
connection.incr(key, options) rescue 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,19 @@ Feature: Supplier main board
|
|||||||
And I click on the section main board section jumper
|
And I click on the section main board section jumper
|
||||||
Then I should be redirected to the supplier section view
|
Then I should be redirected to the supplier section view
|
||||||
|
|
||||||
@javascript
|
@javascript @broken
|
||||||
Scenario: Update table number if table chanes
|
Scenario: Update table number if table chanes
|
||||||
Given there is an active list and order
|
Given there is an active list and order
|
||||||
And I am signed in as supplier
|
And I am signed in as supplier
|
||||||
When the active list changes to another table in another section
|
When the active list changes to another table in another section
|
||||||
Then the supplier main board table number should be updated to the new table number
|
Then the supplier main board table number should be updated to the new table number
|
||||||
And the supplier main board section name should be updated to the new section
|
And the supplier main board section name should be updated to the new section
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Remove an order
|
||||||
|
Given there is an active list and order
|
||||||
|
And I am signed in as supplier
|
||||||
|
When the supplier marks the order as wrong in the main board view
|
||||||
|
Then the supplier main board order should not be visible anymore
|
||||||
|
And the supplier main board list total should be updated
|
||||||
|
And the supplier placed orders counter should be reduced
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ step "there is an active list and order" do
|
|||||||
@section.should be_present
|
@section.should be_present
|
||||||
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
||||||
@product = create :product, price: 2.22, supplier: @supplier
|
@product = create :product, price: 2.22, supplier: @supplier
|
||||||
@order = create :order, user: @user, list: @list, supplier: @supplier, section: @section
|
@order = create :order, user: @user, list: @list, supplier: @supplier, section: @section, state: 'placed'
|
||||||
@product_order = create :product_order, order: @order, product: @product, quantity: 3, price: 2.11
|
@product_order = create :product_order, order: @order, product: @product, quantity: 3, price: 2.11
|
||||||
@list.set_price.should == 6.33 # does not belong here, but good test. must take product order price above product price
|
@list.set_price.should == 6.33 # does not belong here, but good test. must take product order price above product price
|
||||||
|
Qwaiter::Counter.set "supplier_counter:#{@supplier.id}:orders_placed", 11
|
||||||
|
Qwaiter::Counter.set "supplier_counter:#{@supplier.id}:orders_in_process", 7
|
||||||
end
|
end
|
||||||
|
|
||||||
step "the supplier dashboard should display the active list" do
|
step "the supplier dashboard should display the active list" do
|
||||||
@@ -142,3 +144,23 @@ step "the supplier main board section name should be updated to the new section"
|
|||||||
expect( find(".list-row-#{@list.id} .section_title").text ).to eq "New Section"
|
expect( find(".list-row-#{@list.id} .section_title").text ).to eq "New Section"
|
||||||
expect( find(".order-row-#{@list.orders.first.id} .section_title").text ).to eq "New Section"
|
expect( find(".order-row-#{@list.orders.first.id} .section_title").text ).to eq "New Section"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Marking order as wrong
|
||||||
|
step "the supplier marks the order as wrong in the main board view" do
|
||||||
|
find(".order-row-#{@order.id} .remove-order").click
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the supplier main board order should not be visible anymore" do
|
||||||
|
page.should_not have_selector ".order-row-#{@order.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the supplier main board list total should be updated" do
|
||||||
|
find(".list-row-#{@list.id} .total_list_amount").text.should == "€ 0.00"
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the supplier placed orders counter should be reduced" do
|
||||||
|
sleep 0.5
|
||||||
|
binding.pry
|
||||||
|
puts page.driver.error_messages
|
||||||
|
find('.supplier-orders-placed-count-number').text.should == "10"
|
||||||
|
end
|
||||||
|
|||||||
@@ -9,5 +9,8 @@ FactoryGirl.define do
|
|||||||
trait :active do
|
trait :active do
|
||||||
state 'active'
|
state 'active'
|
||||||
end
|
end
|
||||||
|
trait :cancelled do
|
||||||
|
state 'cancelled'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ describe List do
|
|||||||
it 'takes the product_order price in stead of the product price' do
|
it 'takes the product_order price in stead of the product price' do
|
||||||
product_order and list.set_price.should == 6.33
|
product_order and list.set_price.should == 6.33
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not include the price of cancelled orders' do
|
||||||
|
product_order
|
||||||
|
cancelled = create :order, :cancelled, user: user, list: list, supplier: supplier, section: section
|
||||||
|
create :product_order, order: cancelled, product: product, quantity: 2, price: 7.99
|
||||||
|
list.set_price
|
||||||
|
list.price.should == 6.33
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#move_to_table!' do
|
describe '#move_to_table!' do
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ describe Order do
|
|||||||
let(:section) { create :section, supplier: supplier}
|
let(:section) { create :section, supplier: supplier}
|
||||||
let(:table) { create :table, supplier: supplier}
|
let(:table) { create :table, supplier: supplier}
|
||||||
let(:list){ create :list, supplier: supplier, table: table, user_ids: [user.id] }
|
let(:list){ create :list, supplier: supplier, table: table, user_ids: [user.id] }
|
||||||
let(:order) {create :order, supplier: supplier, list: list, state: 'placed' }
|
let(:order_options){ {supplier: supplier, list: list, state: 'placed' } }
|
||||||
|
let(:order) {create :order, order_options }
|
||||||
subject { order }
|
subject { order }
|
||||||
|
|
||||||
its(:placed?) { should be true }
|
its(:placed?) { should be true }
|
||||||
@@ -41,6 +42,7 @@ describe Order do
|
|||||||
describe 'broadcasting' do
|
describe 'broadcasting' do
|
||||||
|
|
||||||
it 'broadcasts order info to the user' do
|
it 'broadcasts order info to the user' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
|
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,24 +54,29 @@ describe Order do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'reduces the orders_placed count and communicates it to user' do
|
it 'reduces the orders_placed count and communicates it to user' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_placed_count' ).with(count: 10)
|
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_placed_count' ).with(count: 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'increases the orders_in_process count and communicates it to user' do
|
it 'increases the orders_in_process count and communicates it to user' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_in_process_count' ).with(count: 8)
|
expect{ order.is_being_processed! }.to broadcast_to_user(user.id).message( 'orders_in_process_count' ).with(count: 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'reduces the orders_placed count and communicates it to supplier' do
|
it 'reduces the orders_placed count and communicates it to supplier' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_placed_count' ).with(count: 10)
|
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_placed_count' ).with(count: 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'increases the orders_in_process count and communicates it to supplier' do
|
it 'increases the orders_in_process count and communicates it to supplier' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_in_process_count' ).with(count: 8)
|
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'orders_in_process_count' ).with(count: 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'broadcasts order info to the supplier' do
|
it 'broadcasts order info to the supplier' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
|
expect{ order.is_being_processed! }.to broadcast_to_supplier(supplier.id).message( 'order_being_processed' ).with(id: order.id, list_id: list.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -106,4 +113,44 @@ describe Order do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "cancel!" do
|
||||||
|
it 'changes the state to cancelled' do
|
||||||
|
order_options[:state] = 'active'
|
||||||
|
order.cancel!
|
||||||
|
expect(order.state).to eq 'cancelled'
|
||||||
|
end
|
||||||
|
describe 'broadcasting' do
|
||||||
|
describe 'counters' do
|
||||||
|
before do
|
||||||
|
# hack some initial values
|
||||||
|
Qwaiter::Counter.set "supplier_counter:#{supplier.id}:orders_placed", 11
|
||||||
|
Qwaiter::Counter.set "supplier_counter:#{supplier.id}:orders_in_process", 7
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'decreases the placed count and communicates it to user when state is placed through the order_cancelled broadcast message' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
|
expect{ order.cancel! }.to broadcast_to_user(user.id).message( 'order_cancelled' ).with(id: order.id, orders_placed_count: 10)
|
||||||
|
supplier.orders_in_process_count.should == 7 # should not be reduced
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'decreases the placed count and communicates it to supplier when the state is placed through the order_cancelled broadcast message' do
|
||||||
|
order_options[:state] = 'placed'
|
||||||
|
expect{ order.cancel! }.to broadcast_to_supplier(supplier.id).message( 'order_cancelled' ).with(id: order.id, orders_placed_count: 10)
|
||||||
|
supplier.orders_in_process_count.should == 7 # should not be reduced
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'decreases the orders_in_process count and communicates it to user when state is active through the order_cancelled broadcast message' do
|
||||||
|
order_options[:state] = 'active'
|
||||||
|
expect{ order.cancel! }.to broadcast_to_user(user.id).message( 'order_cancelled' ).with(id: order.id, orders_in_process_count: 6)
|
||||||
|
supplier.orders_placed_count.should == 11 # should not be reduced
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'decreases the orders_in_process count and communicates it to supplier when the state is active through the order_cancelled broadcast message' do
|
||||||
|
order_options[:state] = 'active'
|
||||||
|
expect{ order.cancel! }.to broadcast_to_supplier(supplier.id).message( 'order_cancelled' ).with(id: order.id, orders_in_process_count: 6)
|
||||||
|
supplier.orders_placed_count.should == 11 # should not be reduced
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ Release
|
|||||||
- styling
|
- styling
|
||||||
- Event stream to ember? (After release!!!)
|
- Event stream to ember? (After release!!!)
|
||||||
- remove invalid orders (Supplier must be able to remove orders from the list)
|
- remove invalid orders (Supplier must be able to remove orders from the list)
|
||||||
|
- Add qr print functionality offering to send the stickers
|
||||||
|
|
||||||
- User
|
- User
|
||||||
- Add product info
|
- Add product info (look at waiter app)
|
||||||
- translate join table strings
|
- translate join table strings
|
||||||
- Add order plus button
|
- Add order plus button
|
||||||
- test met veel producten
|
- test met veel producten
|
||||||
@@ -43,13 +44,16 @@ Release
|
|||||||
General:
|
General:
|
||||||
- search for class btn and replace with font awesome correct styling if
|
- search for class btn and replace with font awesome correct styling if
|
||||||
needed
|
needed
|
||||||
- theme1 site alert styling (zurb?)
|
|
||||||
- devise styling
|
|
||||||
Bugs:
|
Bugs:
|
||||||
- Dragging supplier table from one section to the other fails
|
- Dragging supplier table from one section to the other fails
|
||||||
- Supplier section print qr codes does not give proper images
|
- Supplier section print qr codes does not give proper images
|
||||||
- Supplier tables pagination styling
|
- Supplier tables pagination styling
|
||||||
- supplier counters in user view (no supplier in active list?)
|
- supplier counters in user view (no supplier in active list?)
|
||||||
|
- supplier main board section selector selects first section option
|
||||||
|
and not the supplier name, which is added using prompt thingy. Maybe
|
||||||
|
setting ApplicationController.active_section in stead of
|
||||||
|
IndexController.active_section for scope locking
|
||||||
|
- supplier main board mark list as helped button styling is a bit off
|
||||||
|
|
||||||
Post release
|
Post release
|
||||||
------------
|
------------
|
||||||
@@ -60,4 +64,3 @@ Users can disable their own help request (maak ongedaan?)
|
|||||||
Users can disable their own bill request (maak ongedaan?)
|
Users can disable their own bill request (maak ongedaan?)
|
||||||
Think about extra confirmation box for these requests
|
Think about extra confirmation box for these requests
|
||||||
Supplier section 100% on ember :)
|
Supplier section 100% on ember :)
|
||||||
Supplier give help for settings
|
|
||||||
|
|||||||
Reference in New Issue
Block a user