I am trying to figure out what the correct Ember.js way to model this project would be, eg. what models, routes and controllers would be needed. I have started a jsBin to work from.
My requirements can be safely reduced down to:
Items & their Options
- Items have a collection of options
- Options have their own properties
- Items have other properties (beside the options) that the dashboard will use
Dashboard
- The dashboard does not have any data of it's own
- The dashboard needs to observe all Items and Options, and update an analysis of their properties
Navigation
- Virtually none
- This will appear on one 'page', but a small number of pages/popups may be added in the future
- I want to be able to save and repopulate a given state (eg, a list of selected Option ids)
Data
- The data will be loaded once with a single json call
- Application logic will be done solely clientside within Ember - no ajax for the business logic
- The only subsequent contact w/ the server will be if/when the user saves the state
So how would this be structured in Ember?
I've tried to do this once on my own, but it was my first try and I ended up with a pretty ugly setup. I would like to see how someone with Ember experience would approach this:
jsBin Mockup (link)
I've created a series of handlebar templates, but have not taken a stab at what models should exist and what controllers are needed..
Json
{
"Items" : [
{
"Item" : {
"nid" : "3",
"title" : "Hydro",
"image" : "http://bpf.vm/sites/default/files/bpf_things/hydro.jpg",
"properties" : "Baseload, Intermittent",
"values" : {
"Cost" : {
"price" : "6",
"quantity" : null
},
"Percent of Portfolio" : {
"price" : null,
"quantity" : "56"
}
},
"options" : {
"1" : {
"price" : "1512",
"quantity" : "10000"
},
"12" : {
"price" : "825",
"quantity" : "20000"
},
"11" : {
"price" : "550",
"quantity" : "50000"
}
}
}
},
{
"Item" : {
"nid" : "4",
"title" : "Nuclear",
"image" : "http://bpf.vm/sites/default/files/bpf_things/nuclear.jpg",
"id" : "",
"properties" : "Baseload, Predictable",
"values" : {
"Cost" : {
"price" : "8",
"quantity" : null
},
"Percent of Portfolio" : {
"price" : null,
"quantity" : "21"
}
},
"options" : {
"4" : {
"price" : "825",
"quantity" : "10000"
},
"13" : {
"price" : "411",
"quantity" : "15000"
}
}
}
},
{
"Item" : {
"nid" : "5",
"title" : "Natural Gas",
"image" : "http://bpf.vm/sites/default/files/bpf_things/gas.jpg",
"id" : "9",
"properties" : "Baseload, Predictable",
"values" : {
"Cost" : {
"price" : "5",
"quantity" : null
},
"Percent of Portfolio" : {
"price" : null,
"quantity" : "24"
}
},
"options" : {
"7" : {
"price" : "400",
"quantity" : "50000"
},
"10" : {
"price" : "600",
"quantity" : "100000"
}
}
}
}
]
}