Save progress

This commit is contained in:
2014-03-30 15:55:22 +02:00
parent e179f6e582
commit 013a41b9f6
71 changed files with 1699 additions and 107 deletions
@@ -3,19 +3,26 @@ Qsupplier.App.Order = DS.Model.extend
state: attr('string')
list: DS.belongsTo('list')
price: attr('number')
product_orders: attr()
section: DS.belongsTo('section')
section_id: attr('string')
product_orders: DS.hasMany('product_order')
active: (-> @get('state') == 'active').property('state')
delivered: (-> @get('state') == 'delivered').property('state')
placed: (-> @get('state') == 'placed').property('state')
needs_supplier_attention: (-> @get('state') == 'placed' || @get('state') == 'active').property('state')
display: (->
return '' unless @get('product_orders')
@get('product_orders').map((po)-> "#{po.product_name} (#{po.quantity})").join(',')
).property('product_orders')
#display: (->
#return '' unless @get('product_orders')
#@get('product_orders').map((po)-> "#{po.product_name} (#{po.quantity})").join(',')
#).property('product_orders')
markClosed: ->
@set 'state', 'closed'
total: (->
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.price')
display: (->
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.name')
@@ -1,3 +1,6 @@
attr = DS.attr
Qsupplier.App.Product = DS.Model.extend
order: DS.belongsTo('order')
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
Qsupplier.App.ProductCategory = DS.Model.extend
name: attr('string')
products: DS.hasMany('product')
@@ -0,0 +1,8 @@
attr = DS.attr
Qsupplier.App.ProductOrder = DS.Model.extend
quantity: attr 'number', defaultValue: 1
product: DS.belongsTo('product')
order: DS.belongsTo('order')
increment: ->
@set('quantity', @get('quantity') + 1)
total: (-> @get('quantity') * @get('product.price')).property('quantity', 'product.price')
@@ -0,0 +1,3 @@
Qsupplier.App.ApplicationRoute = Ember.Route.extend
setupController: (controller)->
controller.set 'product_categories', @store.find('product_category')
@@ -3,6 +3,13 @@ DS.RESTAdapter.reopen
namespace: 'supplier'
Qsupplier.App.ApplicationSerializer = DS.ActiveModelSerializer
Qsupplier.App.CustomAdapter = DS.RESTAdapter.extend
# user underscored paths
pathForType: (type)->
decamelized = Ember.String.decamelize(type)
Ember.String.pluralize(decamelized)
Qsupplier.App.Store = DS.Store.extend
revision: 13
adapter: DS.RESTAdapter
adapter: Qsupplier.App.CustomAdapter
@@ -2,7 +2,7 @@ td {{view.content.display}}
td.numeric.table_number
view Qsupplier.App.ActiveOrderTableNumberView contextBinding=view.content
td.section_title {{view.content.section.title}}
td.currency {{currency view.content.price }}
td.currency {{currency view.content.total }}
td.actions
if view.content.placed
button.btn.btn-success{ action markOrderActive view.content.id} {{t 'order.being_processed'}}
@@ -15,7 +15,7 @@ div class="table-actions table-actions-#{unbound table.id}"
a href="suppliers_table_path(@table)" {{t 'section.tables_view.table_actions.got_to_table'}}
each user in table.active_list.users
img src="http://graph.facebook.com/#{user.uid}/picture?type=square"
if editmode_beta
if editmode
.table-settings
select
option Round