2016-06-30 13:21:47 +03:00
|
|
|
import Route from 'ember-route';
|
2016-06-11 19:52:36 +03:00
|
|
|
|
|
|
|
export default Route.extend({
|
2016-04-15 17:45:50 +03:00
|
|
|
model() {
|
|
|
|
return this.get('store').createRecord('subscriber');
|
|
|
|
},
|
|
|
|
|
|
|
|
deactivate() {
|
|
|
|
let subscriber = this.controller.get('model');
|
|
|
|
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
if (subscriber.get('isNew')) {
|
|
|
|
this.rollbackModel();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
rollbackModel() {
|
|
|
|
let subscriber = this.controller.get('model');
|
|
|
|
subscriber.rollbackAttributes();
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
save() {
|
|
|
|
let subscriber = this.controller.get('model');
|
|
|
|
return subscriber.save().then((saved) => {
|
|
|
|
this.send('addSubscriber', saved);
|
|
|
|
return saved;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
cancel() {
|
|
|
|
this.rollbackModel();
|
|
|
|
this.transitionTo('subscribers');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|