Created
July 12, 2014 18:23
-
-
Save brancusi/efdc271fbdd6a35f89a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, { | |
| setupController:function(controller, model) { | |
| this.productStockCollection().then(function(collection){ | |
| controller.set('productStockCollection', collection); | |
| }); | |
| this.productSpoilageCollection().then(function(collection){ | |
| controller.set('productSpoilageCollection', collection); | |
| }); | |
| this.invoice().then(function(invoice){ | |
| controller.set('invoice', invoice); | |
| }); | |
| }, | |
| model:function(params){ | |
| console.log(params.client_id); | |
| }, | |
| invoice:function(){ | |
| // Need to grab params.date from here | |
| var client_id = this.controllerFor('client').get('model.id'); | |
| return this.store.find('invoice', {client_id:client_id, invoice_date:'2014-07-12'}).then(function(result){ | |
| return result.get('content')[0]; | |
| }); | |
| }, | |
| productStockCollection:function(){ | |
| var _this = this; | |
| return this.store.find('product').then(function(products){ | |
| return products.map(function(product){ | |
| return _this.store.createRecord('productStock', {product:product}); | |
| }); | |
| }); | |
| }, | |
| productSpoilageCollection:function(){ | |
| var _this = this; | |
| return this.store.find('product').then(function(products){ | |
| return products.map(function(product){ | |
| return _this.store.createRecord('productSpoilage', {product:product}); | |
| }); | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment