Major supplier refactor making the whole system work better
This commit is contained in:
@@ -3,3 +3,4 @@ faye: thin start -R faye/config.ru -p 9296
|
|||||||
#faye: rackup faye.ru -s thin -E production
|
#faye: rackup faye.ru -s thin -E production
|
||||||
counters: bin/drb_counter.rb run
|
counters: bin/drb_counter.rb run
|
||||||
database: echo "BuenosAires" | sudo -S couchdb start | ~/bin/couch_output
|
database: echo "BuenosAires" | sudo -S couchdb start | ~/bin/couch_output
|
||||||
|
server: rails s
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.5 KiB |
@@ -2,5 +2,5 @@ Ember.Handlebars.helper 'time', (time, params..., options = {})->
|
|||||||
return '' unless time
|
return '' unless time
|
||||||
time = new Date(time) if typeof(time) is "string"
|
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
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
Qsupplier.App.IndexController = Ember.ObjectController.extend
|
Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
|
lists: (-> @store.all('list')).property()
|
||||||
|
orders: (-> @store.all('order')).property()
|
||||||
|
sections: (-> @store.all('section')).property()
|
||||||
active_lists: (->
|
active_lists: (->
|
||||||
if @get('active_section.id')
|
if @get('controllers.application.active_section.id')
|
||||||
@get('lists').filter (l)=>( l.get('section.id') == @get('active_section.id') && l.get('state') == 'active' )
|
@get('lists').filter (l)=>( l.get('section.id') == @get('controllers.application.active_section.id') && l.get('state') == 'active' )
|
||||||
else
|
else
|
||||||
@get('lists').filterProperty('state', 'active')
|
@get('lists').filterProperty('state', 'active')
|
||||||
).property('lists.@each.state', 'active_section.id')
|
).property('lists.@each.state', 'controllers.application.active_section.id')
|
||||||
|
|
||||||
active_section: (-> @get('controllers.application.active_section')).property('controllers.application.active_section')
|
active_section: (-> @get('controllers.application.active_section')).property('controllers.application.active_section')
|
||||||
active_orders: (->
|
active_orders: (->
|
||||||
|
|||||||
@@ -6,4 +6,15 @@ Qsupplier.App.ListsIndexController = Ember.ArrayController.extend
|
|||||||
lists.then => @set('loading', false)
|
lists.then => @set('loading', false)
|
||||||
@set 'model', lists
|
@set 'model', lists
|
||||||
).observes('date')
|
).observes('date')
|
||||||
lists: (-> @get('model')).property('model')
|
lists: (->
|
||||||
|
return @store.all('list') unless date = @get('date')
|
||||||
|
@store.filter('list', (l)->
|
||||||
|
return false unless list_date = l.get('created_at')
|
||||||
|
list_date = list_date.toISOString().substring(0,10) if typeof(list_date) is 'object'
|
||||||
|
list_date == date
|
||||||
|
)
|
||||||
|
).property('date')
|
||||||
|
|
||||||
|
sorted_lists: (->
|
||||||
|
@get('lists').sortBy('created_at').reverseObjects()
|
||||||
|
).property('lists.@each')
|
||||||
|
|||||||
+1
-1
@@ -3,5 +3,5 @@ Qsupplier.App.ModalCloseListController = Ember.ObjectController.extend
|
|||||||
close: ->
|
close: ->
|
||||||
@send 'closeModal'
|
@send 'closeModal'
|
||||||
confirm: ->
|
confirm: ->
|
||||||
@get('model').close()
|
@get('model').then (l)->l.close()
|
||||||
@send 'closeModal'
|
@send 'closeModal'
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend
|
|||||||
Routes.qr_codes_suppliers_tables_path section_id: section_id
|
Routes.qr_codes_suppliers_tables_path section_id: section_id
|
||||||
actions:
|
actions:
|
||||||
showDashboardOrders: (section)->
|
showDashboardOrders: (section)->
|
||||||
@transitionToRoute('index').then =>
|
@set 'controllers.application.active_section', section
|
||||||
@get('controllers.index').set 'active_section', section
|
@transitionToRoute('index')
|
||||||
addSection: -> @send 'openModal', 'modal_add_section', @get('model')
|
addSection: -> @send 'openModal', 'modal_add_section', @get('model')
|
||||||
goToSection: (section)->
|
goToSection: (section)->
|
||||||
@set 'controllers.application.active_section', section
|
@set 'controllers.application.active_section', section
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Qsupplier.App.List = DS.Model.extend
|
|||||||
price: attr 'number'
|
price: attr 'number'
|
||||||
closed_at: DS.attr('date')
|
closed_at: DS.attr('date')
|
||||||
#table_number: attr 'number'
|
#table_number: attr 'number'
|
||||||
table: DS.belongsTo('table', inverse: 'active_list')
|
table: DS.belongsTo('table', inverse: 'active_list', async: true)
|
||||||
#users: DS.hasMany('user', inverse: 'active_list')
|
#users: DS.hasMany('user', inverse: 'active_list')
|
||||||
orders: DS.hasMany('order')
|
orders: DS.hasMany('order')
|
||||||
section: DS.belongsTo('section')
|
section: DS.belongsTo('section')
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ DS.Model.reopen
|
|||||||
eraseRecord: ->
|
eraseRecord: ->
|
||||||
@clearRelationships()
|
@clearRelationships()
|
||||||
@transitionTo('deleted.saved')
|
@transitionTo('deleted.saved')
|
||||||
|
then: (callback) -> callback.call(@, @)
|
||||||
DS.Model.reopenClass
|
DS.Model.reopenClass
|
||||||
findCached: (id)->
|
findCached: (id)->
|
||||||
return null unless id
|
return null unless id
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ Qsupplier.App.Router.map ->
|
|||||||
@resource 'lists', ->
|
@resource 'lists', ->
|
||||||
@resource 'list', path: ':list_id'
|
@resource 'list', path: ':list_id'
|
||||||
@route 'settings'
|
@route 'settings'
|
||||||
|
@route 'empty'
|
||||||
#@resource 'lists', queryParams: ['state']
|
#@resource 'lists', queryParams: ['state']
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
Qsupplier.App.ApplicationRoute = Ember.Route.extend
|
Qsupplier.App.ApplicationRoute = Ember.Route.extend
|
||||||
beforeModel: ->
|
beforeModel: ->
|
||||||
# Preload only active lists and orders
|
# Preload only active lists and orders
|
||||||
@store.find 'product_category'
|
@supplier = @store.push 'supplier', supplier_object
|
||||||
|
@product_categories = @store.find 'product_category'
|
||||||
|
@sections = @store.find 'section'
|
||||||
|
Ember.RSVP.all([@product_categories, @sections]).then (results)=>
|
||||||
|
@store.find('list', state: 'active').then (lists) -> lists.invoke('get', 'table')
|
||||||
|
@lists = @store.all 'list'
|
||||||
|
# product_categories = controller.set 'product_categories', @store.all('product_category')
|
||||||
#@store.find 'order', state: 'active' included in list
|
#@store.find 'order', state: 'active' included in list
|
||||||
setupController: (controller)->
|
setupController: (controller)->
|
||||||
|
controller.set 'supplier', @supplier
|
||||||
# @set 'supplier', @store.find('supplier', supplier_id)
|
# @set 'supplier', @store.find('supplier', supplier_id)
|
||||||
supplier = @store.push 'supplier', supplier_object
|
controller.set 'sections', @sections
|
||||||
controller.set 'supplier', supplier
|
controller.set 'product_categories', @product_categories
|
||||||
|
|
||||||
@store.find 'list', state: 'active'
|
|
||||||
@store.find 'section'
|
|
||||||
|
|
||||||
controller.set 'product_categories', @store.all('product_category')
|
|
||||||
actions:
|
actions:
|
||||||
openModal: (modalName, model, options={})->
|
openModal: (modalName, model, options={})->
|
||||||
controller_name = options.controller || modalName
|
controller_name = options.controller || modalName
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
Qsupplier.App.IndexRoute = Ember.Route.extend
|
# Qsupplier.App.IndexRoute = Ember.Route.extend
|
||||||
model: (params, queryParams)->
|
# model: (params, queryParams)->
|
||||||
Ember.Object.create
|
# Ember.Object.create
|
||||||
# Find with condition does not work since the resulting array promise is not updated for newly created records
|
# # Find with condition does not work since the resulting array promise is not updated for newly created records
|
||||||
#lists: Qsupplier.App.List.find({state: 'active'})
|
# #lists: Qsupplier.App.List.find({state: 'active'})
|
||||||
#orders: Qsupplier.App.Order.find({state: 'active'})
|
# #orders: Qsupplier.App.Order.find({state: 'active'})
|
||||||
#lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
|
# #lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
|
||||||
# use filter to create a scope on all the records
|
# # use filter to create a scope on all the records
|
||||||
#lists: @store.filter 'list', -> true
|
# #lists: @store.filter 'list', -> true
|
||||||
lists: @store.all 'list'
|
# lists: @store.all 'list'
|
||||||
# mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
|
# # mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
|
||||||
#orders: @store.filter 'order', -> true
|
# #orders: @store.filter 'order', -> true
|
||||||
orders: @store.all 'order'
|
# orders: @store.all 'order'
|
||||||
sections: @store.all 'section'
|
# sections: @store.all 'section'
|
||||||
setupController: (controller, model)->
|
# setupController: (controller, model)->
|
||||||
controller.set('model', model)
|
# controller.set('model', model)
|
||||||
#$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
# #$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
||||||
#controller.set 'lists', @store.all('list')
|
# #controller.set 'lists', @store.all('list')
|
||||||
#controller.set 'lists', Qsupplier.App.List.all() #.filterProperty('state', 'active')
|
# #controller.set 'lists', Qsupplier.App.List.all() #.filterProperty('state', 'active')
|
||||||
#controller.set 'orders', Qsupplier.App.Order.all()
|
# #controller.set 'orders', Qsupplier.App.Order.all()
|
||||||
#controller.set 'lists', model.get('lists')
|
# #controller.set 'lists', model.get('lists')
|
||||||
#controller.set 'orders', model.get('orders')
|
# #controller.set 'orders', model.get('orders')
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
Qsupplier.App.SectionRoute = Ember.Route.extend
|
Qsupplier.App.SectionRoute = Ember.Route.extend
|
||||||
|
model: (params) -> @store.findById 'section', params.section_id
|
||||||
renderTemplate: ->
|
renderTemplate: ->
|
||||||
@render 'section'
|
@render 'section'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
h1=t 'models.plural.list'
|
h1=t 'models.plural.list'
|
||||||
Qsupplier.App.ListDisplayDateSelector valueBinding="date"
|
Qsupplier.App.ListDisplayDateSelector valueBinding="date"
|
||||||
if lists
|
if sorted_lists
|
||||||
table.table
|
table.table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
@@ -12,7 +12,7 @@ if lists
|
|||||||
th.currentcy=t 'attributes.list.price'
|
th.currentcy=t 'attributes.list.price'
|
||||||
th.timestamp=t 'attributes.list.created_at'
|
th.timestamp=t 'attributes.list.created_at'
|
||||||
tbody
|
tbody
|
||||||
each list in lists
|
each list in sorted_lists
|
||||||
tr
|
tr
|
||||||
td.state
|
td.state
|
||||||
link-to 'list' list.id
|
link-to 'list' list.id
|
||||||
@@ -20,7 +20,7 @@ if lists
|
|||||||
td.boolean.needs_help=boolean list.needs_help
|
td.boolean.needs_help=boolean list.needs_help
|
||||||
td.boolean.needs_payment=boolean list.needs_payment
|
td.boolean.needs_payment=boolean list.needs_payment
|
||||||
td.timestamp=time list.closed_at
|
td.timestamp=time list.closed_at
|
||||||
td.table_number 7
|
td.table_number= list.table.number
|
||||||
td.currency=currency list.price
|
td.currency=currency list.price
|
||||||
td.timestamp=time list.created_at
|
td.timestamp=time list.created_at
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -20,27 +20,18 @@
|
|||||||
Qsupplier.App.DropdownLink title="Action"
|
Qsupplier.App.DropdownLink title="Action"
|
||||||
ul
|
ul
|
||||||
li
|
li
|
||||||
a{action addTables}
|
a{action "addTables"}: span.section-add-tables-icon=t 'section.add_tables.button_label'
|
||||||
span.section-add-tables-icon
|
|
||||||
=t 'section.add_tables.button_label'
|
|
||||||
li
|
li
|
||||||
a{action arrangeTables}
|
a{action "arrangeTables"}: span.section-arrange-tables-icon=t 'section.arrange_tables.modal.title'
|
||||||
span.section-arrange-tables-icon
|
|
||||||
=t 'section.arrange_tables.modal.title'
|
|
||||||
li
|
li
|
||||||
a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}"
|
a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}": span.table-qr-codes=t 'tables.qr_codes.link'
|
||||||
span.table-qr-codes
|
|
||||||
=t 'tables.qr_codes.link'
|
|
||||||
li
|
li
|
||||||
/a.section-destroy href="{{route 'suppliers_section_path' id}}" data-method="delete" data-confirm="{{t 'helpers.links.are_you_sure' bare=true}}"
|
a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
|
||||||
a.section-destroy{action destroySection}
|
|
||||||
span.section-remove-icon
|
|
||||||
=t 'helpers.links.destroy'
|
|
||||||
Ember.TextField valueBinding="title" class="section-edit-title-field"
|
Ember.TextField valueBinding="title" class="section-edit-title-field"
|
||||||
Qsupplier.App.NumberField valueBinding="width" class="dimension section-edit-width-field"
|
Qsupplier.App.NumberField valueBinding="width" class="dimension section-edit-width-field"
|
||||||
span.fa.fa-lg.fa-times
|
span.fa.fa-lg.fa-times
|
||||||
Qsupplier.App.NumberField valueBinding="height" class="dimension section-edit-height-field"
|
Qsupplier.App.NumberField valueBinding="height" class="dimension section-edit-height-field"
|
||||||
a.section-normal-mode-button{ action finishEditable }: span
|
a.section-normal-mode-button{ action "finishEditable" }: span
|
||||||
else
|
else
|
||||||
a.section-edit-mode-button{ action makeEditable }: span
|
a.section-edit-mode-button{ action "makeEditable" }: span
|
||||||
Qsupplier.App.SectionTablesView contentBinding="tables"
|
Qsupplier.App.SectionTablesView contentBinding="tables"
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ if table.active_list
|
|||||||
div.table-actions
|
div.table-actions
|
||||||
.title= table.number
|
.title= table.number
|
||||||
.table-action-row
|
.table-action-row
|
||||||
Qsupplier.App.MarkListHelpedButtonView content=table.active_list
|
Qsupplier.App.MarkListHelpedButtonView contentBinding="table.active_list"
|
||||||
Qsupplier.App.CloseListButtonView content=table.active_list
|
Qsupplier.App.CloseListButtonView contentBinding="table.active_list"
|
||||||
.table-action-row=currency table.active_list.total
|
.table-action-row=currency table.active_list.total
|
||||||
/.table-action-row
|
/.table-action-row
|
||||||
a{action "editTable" table}: span.fa.fa-lg.fa-wrench
|
a{action "editTable" table}: span.fa.fa-lg.fa-wrench
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
each table in tables
|
each table in tables
|
||||||
Qsupplier.App.SectionTableView contentBinding="table"
|
Qsupplier.App.SectionTableView content=table
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ Qsupplier.App.MarkListHelpedButtonView = Ember.View.extend
|
|||||||
classNameBindings: ['content.needs_help:show:hide']
|
classNameBindings: ['content.needs_help:show:hide']
|
||||||
tagName: 'button'
|
tagName: 'button'
|
||||||
click: (e)->
|
click: (e)->
|
||||||
@get('content').is_helped()
|
@get('content').then (l)->l.is_helped()
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ root.Qsupplier=
|
|||||||
list = order.get('list')
|
list = order.get('list')
|
||||||
list.get('orders').addRecord order
|
list.get('orders').addRecord order
|
||||||
if table = list.get('table')
|
if table = list.get('table')
|
||||||
if table.get('active_list') isnt list
|
if table.get('active_list')
|
||||||
table.set 'active_list', list
|
table.get('active_list').then (table_list)->
|
||||||
|
table.set 'active_list', list if table_list isnt list
|
||||||
, 200
|
, 200
|
||||||
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)
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ function setTranslations(selector){
|
|||||||
if(selector){
|
if(selector){
|
||||||
$(selector).find('[data-t]').each(function(){$(this).html(t($(this).data('t'), $(this).data('tAttributes')))})
|
$(selector).find('[data-t]').each(function(){$(this).html(t($(this).data('t'), $(this).data('tAttributes')))})
|
||||||
$(selector).find('*[data-time]').each(function(){
|
$(selector).find('*[data-time]').each(function(){
|
||||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:MM'))
|
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:mm'))
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
$('[data-t]').each(function(){$(this).html(t($(this).data('t'),$(this).data('tAttributes')))})
|
$('[data-t]').each(function(){$(this).html(t($(this).data('t'),$(this).data('tAttributes')))})
|
||||||
$('*[data-time]').each(function(){
|
$('*[data-time]').each(function(){
|
||||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:MM'))
|
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:mm'))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$('.datepicker').datepicker("option", $.datepicker.regional[$locale])
|
$('.datepicker').datepicker("option", $.datepicker.regional[$locale])
|
||||||
|
|||||||
@@ -70,14 +70,14 @@
|
|||||||
$(this).html t($(this).data("t"), $(this).data("tAttributes"))
|
$(this).html t($(this).data("t"), $(this).data("tAttributes"))
|
||||||
|
|
||||||
selector.find("*[data-time]").each ->
|
selector.find("*[data-time]").each ->
|
||||||
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:MM")
|
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:mm")
|
||||||
|
|
||||||
else
|
else
|
||||||
$("[data-t]").each ->
|
$("[data-t]").each ->
|
||||||
$(this).html t($(this).data("t"), $(this).data("tAttributes"))
|
$(this).html t($(this).data("t"), $(this).data("tAttributes"))
|
||||||
|
|
||||||
$("*[data-time]").each ->
|
$("*[data-time]").each ->
|
||||||
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:MM")
|
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:mm")
|
||||||
|
|
||||||
# jQuery UI datepicker support
|
# jQuery UI datepicker support
|
||||||
$(".datepicker").datepicker "option", $.datepicker.regional[locale] if $.fn.datepicker
|
$(".datepicker").datepicker "option", $.datepicker.regional[locale] if $.fn.datepicker
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ td.boolean
|
|||||||
&.needs_help
|
&.needs_help
|
||||||
.boolean-true
|
.boolean-true
|
||||||
@extend .fa
|
@extend .fa
|
||||||
@extend .fa-exclamation
|
@extend .fa-bell
|
||||||
&.needs_payment
|
&.needs_payment
|
||||||
.boolean-true
|
.boolean-true
|
||||||
@extend .fa
|
@extend .fa
|
||||||
@@ -32,5 +32,3 @@ td.boolean
|
|||||||
padding: $padding
|
padding: $padding
|
||||||
border-top: 2px solid #444
|
border-top: 2px solid #444
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ module Suppliers
|
|||||||
end
|
end
|
||||||
@lists.include_relation(:table)
|
@lists.include_relation(:table)
|
||||||
|
|
||||||
respond_to do |format|
|
render json: @lists, each_serializer: SupplierListSerializer
|
||||||
format.html # index.html.erb
|
|
||||||
format.json { render json: @lists, each_serializer: SupplierListSerializer }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,21 @@ module Suppliers
|
|||||||
# GET /sections
|
# GET /sections
|
||||||
# GET /sections.json
|
# GET /sections.json
|
||||||
def index
|
def index
|
||||||
|
# render json: {} and return
|
||||||
@sections = current_supplier.sections
|
@sections = current_supplier.sections
|
||||||
@sections.include_relation(:tables)
|
@sections.include_relation(:tables)
|
||||||
@active_lists = List.active_for_supplier(current_supplier.id)
|
|
||||||
@active_table_ids = @active_lists.map(&:table_id).compact
|
|
||||||
for section in @sections
|
|
||||||
for table in section.tables
|
|
||||||
if active_list = @active_lists.find{|l| l.table_id == table.id}
|
|
||||||
table.active_list = active_list
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
# @active_lists = List.active_for_supplier(current_supplier.id)
|
||||||
format.html # index.html.erb
|
# @active_table_ids = @active_lists.map(&:table_id).compact
|
||||||
format.json { render json: @sections, each_serializer: SupplierExtendedSectionSerializer }
|
# for section in @sections
|
||||||
end
|
# for table in section.tables
|
||||||
|
# if active_list = @active_lists.find{|l| l.table_id == table.id}
|
||||||
|
# table.active_list = active_list
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
render json: @sections, each_serializer: SupplierExtendedSectionSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /sections/1
|
# GET /sections/1
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ class List
|
|||||||
set_price # should not be needed, but extra secure
|
set_price # should not be needed, but extra secure
|
||||||
orders.map(&:close!) # close the connected orders
|
orders.map(&:close!) # close the connected orders
|
||||||
self.state = 'closed'
|
self.state = 'closed'
|
||||||
|
self.is_helped! if needs_help?
|
||||||
self.user_requests_closing = false # if a user requested closing, not needed anymore
|
self.user_requests_closing = false # if a user requested closing, not needed anymore
|
||||||
self.closed_at = Time.now
|
self.closed_at = Time.now
|
||||||
if save
|
if save
|
||||||
|
|||||||
+7
-1
@@ -129,7 +129,13 @@ class Order
|
|||||||
|
|
||||||
#TODO fix me
|
#TODO fix me
|
||||||
def close!
|
def close!
|
||||||
self.state = 'closed' if placed? || active?
|
|
||||||
|
if placed? || active?
|
||||||
|
decrement_counter = placed? ? 'placed' : 'in_process'
|
||||||
|
self.state = 'closed'
|
||||||
|
supplier.public_send "decrement_orders_#{decrement_counter}_count!"
|
||||||
|
end
|
||||||
|
|
||||||
if save
|
if save
|
||||||
broadcast_user user.id, 'order_closed', id: id if user
|
broadcast_user user.id, 'order_closed', id: id if user
|
||||||
broadcast_supplier supplier_id, 'order_closed', id: id
|
broadcast_supplier supplier_id, 'order_closed', id: id
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class Supplier
|
|||||||
# Set all known counters to zero
|
# Set all known counters to zero
|
||||||
Qwaiter::Couchbase.flush_counters!
|
Qwaiter::Couchbase.flush_counters!
|
||||||
|
|
||||||
|
Qwaiter::Counter.connection.flush if Qwaiter::Counter.connection.respond_to?(:flush)
|
||||||
|
|
||||||
spec = Order.by_supplier_id_and_state(reduce: true, group_level: 2)
|
spec = Order.by_supplier_id_and_state(reduce: true, group_level: 2)
|
||||||
reset_order_counters_with_spec spec
|
reset_order_counters_with_spec spec
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class SupplierExtendedTableSerializer < Qwaiter::Serializer
|
class SupplierExtendedTableSerializer < Qwaiter::Serializer
|
||||||
root 'table'
|
root 'table'
|
||||||
embed :ids, include: true
|
embed :ids, include: true
|
||||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :active_list_id
|
attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id
|
||||||
|
|
||||||
#def list_id
|
#def list_id
|
||||||
#object.active_list_id || object.active_list.try(:id)
|
#object.active_list_id || object.active_list.try(:id)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ html lang="en"
|
|||||||
meta charset="utf-8"
|
meta charset="utf-8"
|
||||||
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||||
title= content_for?(:title) ? yield(:title) : application_title
|
title= application_title
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
|
|
||||||
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ html lang="en"
|
|||||||
meta charset="utf-8"
|
meta charset="utf-8"
|
||||||
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||||
title Qwaiter
|
title= application_title
|
||||||
= stylesheet_link_tag "user/foundation/application"
|
= stylesheet_link_tag "user/foundation/application"
|
||||||
= javascript_include_tag "vendor/modernizr"
|
= javascript_include_tag "vendor/modernizr"
|
||||||
= javascript_include_tag 'http://connect.facebook.net/en_US/all.js'
|
= javascript_include_tag 'http://connect.facebook.net/en_US/all.js'
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Feature: Supplier section view
|
|||||||
And I wait 0.5 seconds
|
And I wait 0.5 seconds
|
||||||
|
|
||||||
When I click on the close list button in the section table table popup
|
When I click on the close list button in the section table table popup
|
||||||
|
And confirm the supplier close list modal
|
||||||
And I wait 1 second
|
And I wait 1 second
|
||||||
Then the section table should not have any active list markings anymore
|
Then the section table should not have any active list markings anymore
|
||||||
And the list should be marked as closed
|
And the list should be marked as closed
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ step "I wait :number second/seconds" do |number|
|
|||||||
sleep number.to_f
|
sleep number.to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
placeholder :number do
|
||||||
|
match /[-+]?\d+(\.\d+)?/ do |number_string|
|
||||||
|
number_string.to_f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
step "I open the debugger" do
|
step "I open the debugger" do
|
||||||
binding.pry
|
binding.pry
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ step "I visit the supplier section path" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
step "I visit the supplier last section path" do
|
step "I visit the supplier last section path" do
|
||||||
visit "/supplier/sections/#{@sections.last.id}"
|
visit "/supplier#/sections/#{@sections.last.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
step "I should be redirected to the supplier settings page" do
|
step "I should be redirected to the supplier settings page" do
|
||||||
@@ -20,5 +20,5 @@ step "I should be redirected to the supplier settings page" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
step "I visit the supplier settings path" do
|
step "I visit the supplier settings path" do
|
||||||
visit supplier_settings_path
|
visit "/supplier#/settings"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ step "the section table should be marked as in need of help" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
step "the section table should not be marked as in need of help" do
|
step "the section table should not be marked as in need of help" do
|
||||||
binding.pry
|
|
||||||
table = page.find(".section-table-#{@table.id}")
|
table = page.find(".section-table-#{@table.id}")
|
||||||
table['class'].should_not include 'needs_help'
|
table['class'].should_not include 'needs_help'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -156,4 +156,12 @@ describe List do
|
|||||||
|
|
||||||
describe 'product order creation'
|
describe 'product order creation'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#close!' do
|
||||||
|
it 'removes the helped mark' do
|
||||||
|
list_options[:needs_help] = true
|
||||||
|
list.close!
|
||||||
|
expect( list.needs_help? ).not_to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -153,4 +153,26 @@ describe Order do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
describe '#close!' 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 "decrements the orders_placed_count for when a placed order is closed" do
|
||||||
|
order.close!
|
||||||
|
supplier.orders_placed_count.should == 10
|
||||||
|
supplier.orders_in_process_count.should == 7
|
||||||
|
end
|
||||||
|
|
||||||
|
it "decrements the orders_in_process_count for when an active order is closed" do
|
||||||
|
order_options[:state] = 'active'
|
||||||
|
order.close!
|
||||||
|
supplier.orders_placed_count.should == 11
|
||||||
|
supplier.orders_in_process_count.should == 6
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1949
-1329
File diff suppressed because it is too large
Load Diff
+4480
-2885
File diff suppressed because it is too large
Load Diff
+4
-11
File diff suppressed because one or more lines are too long
+20
-20
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user