Skip to content

Instantly share code, notes, and snippets.

@pzuraq
Created January 28, 2013 04:59
Show Gist options
  • Save pzuraq/4653186 to your computer and use it in GitHub Desktop.
Save pzuraq/4653186 to your computer and use it in GitHub Desktop.
/*global App*/
window.App = Ember.Application.create();
// Router
App.Router.map(function() {
this.resource('inventory', function(){
this.route('review');
this.resource('vehicle', { path: '/vehicle/:stock_no' }, function(){
this.route('details');
});
});
});
App.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('inventory');
}
});
App.InventoryRoute = Ember.Route.extend({
model: function() {
return App.Vehicle.find();
}
});
//Controllers
App.InventoryController = Ember.ArrayController.extend({
active: function() {
return this.content.filterProperty('active', true);
}.property('content.@each.id').cacheable()
});
App.InventoryReviewController = Ember.ArrayController.extend({
needs: ["inventory"],
inventoryBinding: 'controllers.inventory',
addVehicle: function(vehicle) {
vehicle.set('active', true);
}
});
//Models
App.Store = DS.Store.extend({
revision: 11,
adapter: 'DS.FixtureAdapter'
});
App.Vehicle = DS.Model.extend({
active: DS.attr('boolean'),
year: DS.attr('number'),
make: DS.attr('string'),
model: DS.attr('string')
});
App.Vehicle.FIXTURES = [{
id: 1001,
active: false,
year: 1970,
make: 'Ford',
model: 'Mustang'
}, {
id: 1002,
active: false,
year: 1967,
make: 'Chevrolet',
model: 'Camaro'
}, {
id: 1003,
active: false,
year: 1962,
make: 'Pontiac',
model: 'Firebird'
}, {
id: 1004,
active: false,
year: 1975,
make: 'Dodge',
model: 'Challenger'
}, {
id: 1005,
active: false,
year: 1969,
make: 'Buick',
model: 'Gran Sport'
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment