Skip to content

Instantly share code, notes, and snippets.

@pzuraq
Created January 28, 2013 01:16
Show Gist options
  • Save pzuraq/4651955 to your computer and use it in GitHub Desktop.
Save pzuraq/4651955 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.InventoryReviewRoute = Ember.Route.extend({
model: function() {
return App.Vehicle.find();
}
});
//Controllers
App.InventoryController = Ember.ArrayController.extend({
sortProperties: ['id']
});
App.InventoryReviewController = Ember.ArrayController.extend({
addActiveVehicle: function(vehicle) {
inventory.vehicles.createRecord({
food: food,
cents: food.get('cents')
});
}
});
//Models
App.Store = DS.Store.extend({
revision: 11,
adapter: 'DS.FixtureAdapter'
});
App.Vehicle = DS.Model.extend({
year: DS.attr('number'),
make: DS.attr('string'),
model: DS.attr('string')
});
App.Inventory = DS.Model.extend({
vehicles: DS.hasMany('App.Vehicle')
});
App.Vehicle.FIXTURES = [{
id: 1001,
year: 1970,
make: 'Ford',
model: 'Mustang'
}, {
id: 1002,
year: 1967,
make: 'Chevrolet',
model: 'Camaro'
}, {
id: 1003,
year: 1962,
make: 'Pontiac',
model: 'Firebird'
}, {
id: 1004,
year: 1975,
make: 'Dodge',
model: 'Challenger'
}, {
id: 1005,
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