Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flow
<!--
template: planbook.hbs
-->
{{render 'dates'}}
<!--
template: dates.hbs
controller: see DatesController below
itemControllers: see DateController below)
-->
{{#each arrangedContent}}
{{render 'planbook/date' controller.planbookDate}}
{{/each}}
<!--
template: planbook/date.hbs
model: see PlanbookDate below
-->
{{render 'routine' routine}}
var DatesController = Ember.ArrayController.extend({
init: function(){
this._super()
this._loadDates()
},
_loadDates: function(){
var range = this._getRange(); // returns array of dates ["2014-02-02", "2014-02-03"]
var content = range.map(this._createDateController, this)
this.pushObjects(content)
},
_createDateController: function(date){
return this.container.lookupFactory('controller:date').create({date: date})
},
})
export default DatesController
var DateController = Ember.Controller.extend({
needs: ['dates', 'planbook'],
planbookDate: function(){
var id = this.get('controllers.planbook.content.id') + ":" + this.get('date')
return this.store.modelFor('planbookDate').find(id)
}.property('content.date', 'controllers.planbook')
})
export default DateController
var PlanbookDate = Ember.Model.extend({
routine: Ember.belongsTo('routine', {key: 'routineId'}),
})
export default PlanbookDate;
var Routine = Ember.Model.extend({
parts: Ember.hasMany('part', {embedded: true, key: 'parts'}),
})
export default Routine;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.