Add concept waiter section
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
@App = Ember.Application.create
|
||||
LOG_TRANSITIONS: true
|
||||
rootElement: '#ember-app-container'
|
||||
@@ -0,0 +1,8 @@
|
||||
#= require_self
|
||||
#= require handlebars
|
||||
#= require ember
|
||||
#= require ember-data
|
||||
#= require shared-ember-helpers/all
|
||||
#= require ./app
|
||||
#= require_tree .
|
||||
@EmberENV = {FEATURES: {'query-params-new': true}}
|
||||
@@ -0,0 +1,11 @@
|
||||
App.ProductCategoriesController = Ember.ArrayController.extend
|
||||
needs: ['table']
|
||||
actions:
|
||||
addProduct: (product)->
|
||||
if table = @get('controllers.table.model')
|
||||
if existing = @store.all('product_order').find((po)->po.get('table') == table and po.get('product') == product)
|
||||
existing.increment()
|
||||
else
|
||||
@store.createRecord 'product_order', table: table, product: product
|
||||
else
|
||||
alert "Please select a table first"
|
||||
@@ -0,0 +1 @@
|
||||
App.SectionsController = Ember.ArrayController.extend {}
|
||||
@@ -0,0 +1,8 @@
|
||||
App.TableController = Ember.ObjectController.extend
|
||||
orderTotal: (->
|
||||
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('product_orders.@each.quantity')
|
||||
|
||||
actions:
|
||||
clearProductOrders: ->
|
||||
@get('product_orders').every (product_order)->product_order.deleteRecord()
|
||||
@@ -0,0 +1,12 @@
|
||||
attr = DS.attr
|
||||
App.List = DS.Model.extend
|
||||
state: attr 'string'
|
||||
needs_help: attr 'boolean'
|
||||
needs_payment: attr 'boolean'
|
||||
is_paid: attr 'boolean'
|
||||
has_active_orders: attr 'boolean'
|
||||
price: attr 'number'
|
||||
table_number: attr 'number'
|
||||
table: DS.belongsTo('table', inverse: 'active_list')
|
||||
section: DS.belongsTo('section')
|
||||
section_id: attr('string')
|
||||
@@ -0,0 +1,6 @@
|
||||
attr = DS.attr
|
||||
App.Product = DS.Model.extend
|
||||
name: attr 'string'
|
||||
price: attr 'number'
|
||||
product_category: DS.belongsTo('product_category')
|
||||
product_orders: DS.hasMany('product_order')
|
||||
@@ -0,0 +1,4 @@
|
||||
attr = DS.attr
|
||||
App.ProductCategory = DS.Model.extend
|
||||
name: attr 'string'
|
||||
products: DS.hasMany('product')
|
||||
@@ -0,0 +1,8 @@
|
||||
attr = DS.attr
|
||||
App.ProductOrder = DS.Model.extend
|
||||
quantity: attr 'number', defaultValue: 1
|
||||
product: DS.belongsTo('product')
|
||||
table: DS.belongsTo('table')
|
||||
increment: ->
|
||||
@set('quantity', @get('quantity') + 1)
|
||||
total: (-> @get('quantity') * @get('product.price')).property('quantity')
|
||||
@@ -0,0 +1,6 @@
|
||||
attr = DS.attr
|
||||
App.Section = DS.Model.extend
|
||||
title: attr 'string'
|
||||
width: attr 'number'
|
||||
height: attr 'number'
|
||||
tables: DS.hasMany('table')
|
||||
@@ -0,0 +1,14 @@
|
||||
attr = DS.attr
|
||||
App.Table = DS.Model.extend
|
||||
number: attr 'number'
|
||||
width: attr 'number'
|
||||
height: attr 'number'
|
||||
position_x: attr 'number'
|
||||
position_y: attr 'number'
|
||||
occupied: attr 'boolean'
|
||||
section: DS.belongsTo('section')
|
||||
product_orders: DS.hasMany('product_order')
|
||||
#active_list: DS.belongsTo('list')
|
||||
#active_list: (->
|
||||
#@get('list')
|
||||
#).property('list')
|
||||
@@ -0,0 +1,11 @@
|
||||
# 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'
|
||||
rootURL: '/waiter'
|
||||
|
||||
App.Router.map ->
|
||||
@resource 'sections', ->
|
||||
@resource 'section', path: ':section_id', ->
|
||||
@resource 'tables', ->
|
||||
@resource 'table', path: ':table_id'
|
||||
@@ -0,0 +1,3 @@
|
||||
App.ApplicationRoute = Ember.Route.extend
|
||||
setupController: ->
|
||||
@controllerFor('product_categories').set 'model', @store.find('product_category')
|
||||
@@ -0,0 +1,2 @@
|
||||
App.IndexRoute = Ember.Route.extend
|
||||
redirect: -> @transitionTo('sections')
|
||||
@@ -0,0 +1,2 @@
|
||||
App.SectionsRoute = Ember.Route.extend
|
||||
model: -> @store.find('section')
|
||||
@@ -0,0 +1,13 @@
|
||||
# http://emberjs.com/guides/models/defining-a-store/
|
||||
DS.RESTAdapter.reopen
|
||||
namespace: 'waiter'
|
||||
|
||||
App.ApplicationSerializer = DS.ActiveModelSerializer
|
||||
App.CustomAdapter = DS.RESTAdapter.extend
|
||||
|
||||
# user underscored paths
|
||||
pathForType: (type)->
|
||||
decamelized = Ember.String.decamelize(type)
|
||||
Ember.String.pluralize(decamelized)
|
||||
App.Store = DS.Store.extend
|
||||
adapter: App.CustomAdapter
|
||||
@@ -0,0 +1,5 @@
|
||||
.row
|
||||
.twelve.columns
|
||||
h1 Qwaiter
|
||||
hr
|
||||
.waiter-application-container= outlet
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
h2 Food!
|
||||
each product_category in controller
|
||||
if product_category.products
|
||||
h5= product_category.name
|
||||
hr
|
||||
ul.product_category-products
|
||||
each product in product_category.products
|
||||
li
|
||||
a{action addProduct product } href="#" = product.name
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
.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
|
||||
.small-12.medium-6.large-4.columns= render 'product_categories'
|
||||
.large-4.columns= outlet
|
||||
@@ -0,0 +1,10 @@
|
||||
dl.sub-nav
|
||||
dt Section:
|
||||
each section in controller
|
||||
dd
|
||||
= link-to 'section' section
|
||||
= section.title
|
||||
else
|
||||
dd No available sections
|
||||
hr
|
||||
= outlet
|
||||
@@ -0,0 +1,19 @@
|
||||
hr.hide-for-large-up
|
||||
if product_orders
|
||||
a.tiny.button.right{action clearProductOrders} href="#" x
|
||||
h4
|
||||
| Table
|
||||
= number
|
||||
.panel
|
||||
ul.product-orders
|
||||
each product_order in product_orders
|
||||
li
|
||||
= product_order.quantity
|
||||
| x
|
||||
= product_order.product.name
|
||||
span.currency=currency product_order.product.price
|
||||
else
|
||||
li No products
|
||||
li.total
|
||||
| Total
|
||||
span.currency=currency orderTotal
|
||||
@@ -0,0 +1,7 @@
|
||||
#= require jquery
|
||||
#= require jquery_ujs
|
||||
#= require ./app/application
|
||||
#= require foundation
|
||||
#= require_directory .
|
||||
#= require_self
|
||||
$(document).foundation()
|
||||
Reference in New Issue
Block a user