All specs green, ember transition successful

This commit is contained in:
2014-06-27 14:52:18 +02:00
parent a5e8d38882
commit b5a68e9627
19 changed files with 100 additions and 14 deletions
@@ -1,3 +1,4 @@
Qsupplier.App = Ember.Application.create
LOG_TRANSITIONS: true
rootElement: '#ember-app-container'
store: -> @__container__.lookup('controller:application').store
@@ -9,7 +9,8 @@ Qsupplier.App.List = DS.Model.extend
#has_active_orders: attr 'boolean'
has_active_orders: (->
return false unless @get('state') == 'active'
!!@get('orders').filterProperty('state', 'active').length
#!!@get('orders').filterProperty('state', 'active').length
!!@get('orders').filter( (order) -> order.get('state') is 'active' or order.get('state') is 'placed').length
).property('state', 'orders.@each.state')
price: attr 'number'
closed_at: DS.attr('date')
@@ -20,19 +20,30 @@ DS.Model.reopenClass
else
#@store.find(@, attributes.id)
@pushByAttriburtes(attributes)
pushByAttriburtes: (attributes)->
pushByAttriburtes: (attributes, options = {})->
#store = @all().get('store')
#Ugly hack at the cost of an extra request since I do not yet know the proper
#code for adding a record by its attributes and having its associations set
#@find(attributes.id)
decamelized = Ember.String.decamelize(@typeKey)
self_name = Ember.String.pluralize(decamelized)
self_name = self_name.substr(1) if self_name[0] == '.'
Ember.get(@, 'relationships').forEach (model, relation)=>
relation = relation[0]
if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
attributes[relation.name] = id unless attributes[relation.name]
#belongs_tos = {}
#Ember.get(@, 'relationships').forEach (model, relation)=>
#relation = relation[0]
#if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
#attributes[relation.name] = id unless attributes[relation.name]
#debugger if options.debug
#belongs_tos[relation.name] = id
@store.push @toString(), attributes
nested_attributes = {}
nested_attributes[self_name] = attributes
# pushPayload makes association back references, just push not yet 2014-06-27
new_record = @store.pushPayload(@toString(), nested_attributes)
#debugger if options.debug
#promises = []
#association_names = []
@@ -1,11 +1,16 @@
.display-row
.display-label=t 'attributes.list.created_at'
.display-field=time list.created_at
if list.closed_at
.display-row
.display-label=t 'attributes.list.closed_at'
.display-field=time list.closed_at
.display-row
.display-label=t 'attributes.list.state'
.display-field=state 'list' list.state
each user in list.users
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
.row
each user in list.users
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
if list.orders
.list-orders-container
each order in list.sorted_orders
@@ -5,7 +5,11 @@ root.Qsupplier=
faye.subscribe "/supplier/"+supplier_id, (e)=>
console.log(e)
if(e.event == 'new_order')
Qsupplier.App.Order.pushByAttriburtes(e.data.order) if Qsupplier.App
if Qsupplier.App
Qsupplier.App.store().pushPayload e.data
#Qsupplier.App.Order.pushByAttriburtes(e.data.order)
#for product_order in e.data.product_orders
#Qsupplier.App.ProductOrder.pushByAttriburtes product_order, debug: true
else if(e.event == 'list_needs_help')
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.markNeedsHelp()