Implement waiter ordering and improvements

This commit is contained in:
2014-03-24 10:02:57 +01:00
parent 474d5f88c6
commit 6c2427e082
24 changed files with 128 additions and 48 deletions
@@ -1,8 +1,9 @@
App.ProductCategoriesController = Ember.ArrayController.extend
needs: ['table']
#needs: ['table']
actions:
addProduct: (product)->
if table = @get('controllers.table.model')
if table_route = App.Router.router.currentHandlerInfos.find((r) -> r.name == 'table')
table = table_route.context
if existing = @store.all('product_order').find((po)->po.get('table') == table and po.get('product') == product)
existing.increment()
else
@@ -0,0 +1 @@
App.SectionController = Ember.ObjectController.extend {}
@@ -1 +1,2 @@
App.SectionsController = Ember.ArrayController.extend {}
App.SectionsController = Ember.ArrayController.extend
needs: ['section']
@@ -5,4 +5,19 @@ App.TableController = Ember.ObjectController.extend
actions:
clearProductOrders: ->
@get('product_orders').every (product_order)->product_order.deleteRecord()
@get('product_orders').toArray().forEach (product_order)->
product_order.unloadRecord()
orderProducts: ->
orders = @get('product_orders').toArray()
data = orders.map( (order)->order.serialize() )
dataObject = {order: {}}
for product_order in data
dataObject['table_id'] = product_order.table_id
dataObject['order'][product_order.product_id] = product_order.quantity
$.ajax
url: Routes.order_products_waiter_path(),
type: "POST",
data: JSON.stringify(dataObject),
contentType: "application/json",
dataType: 'json'
orders.invoke 'unloadRecord'
@@ -1,7 +1,7 @@
# For more information see: http://emberjs.com/guides/routing/
# and for queryParams: https://github.com/alexspeller/website/blob/a96d9afe4506454b155cc64299e86e558ce3c9f1/source/guides/routing/query-params.md
App.Router.reopen
location: 'history'
#location: 'history'
rootURL: '/waiter'
App.Router.map ->
@@ -1,4 +1,3 @@
h2 Food!
each product_category in controller
if product_category.products
h5= product_category.name
@@ -1,6 +1,5 @@
.row
.section-tables.small-12.medium-6.large-4.columns
h2 Tables
each table in tables
= link-to 'table' table class="panel section-table"
= table.number
@@ -0,0 +1,2 @@
= link-to 'section' this
= title
@@ -1,9 +1,7 @@
dl.sub-nav
dt Section:
dt= t 'model.section'
each section in controller
dd
= link-to 'section' section
= section.title
view App.SectionHeaderView context=section
else
dd No available sections
hr
@@ -2,7 +2,8 @@ hr.hide-for-large-up
if product_orders
a.tiny.button.right{action clearProductOrders} href="#" x
h4
| Table
= t 'models.table'
|
= number
.panel
ul.product-orders
@@ -17,3 +18,5 @@ h4
li.total
| Total
span.currency=currency orderTotal
if product_orders
a.tiny.button.right{action orderProducts} href="#" = t 'product_orders.order_button'
@@ -0,0 +1,8 @@
App.SectionHeaderView = Ember.View.extend
templateName: 'section_header'
tagName: 'dd'
classNameBindings: ['active']
active: (->
if @get('context.id') == @get('controller.controllers.section.model.id') then 'active' else ''
).property('controller.controllers.section.model.id')
@@ -1,7 +0,0 @@
#= require jquery
#= require jquery_ujs
#= require ./app/application
#= require foundation
#= require_directory .
#= require_self
$(document).foundation()
@@ -0,0 +1,15 @@
#= require jquery
#= require jquery_ujs
#= require ./app/application
#= require foundation
#= require moment
#= require jquery.ui.datepicker
#= require translations
#= require js-routes
#= require_directory .
#= require_self
@Qstorage = localStorage
$.extend($translations.en, <%= I18n.t('waiter', locale: :en).to_json %>);
$.extend($translations.nl, <%= I18n.t('waiter', locale: :nl).to_json %>);
$(document).foundation()
setLocale('en')