mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
38 lines
849 B
JavaScript
38 lines
849 B
JavaScript
|
import Ember from 'ember';
|
||
|
|
||
|
export default Ember.Route.extend({
|
||
|
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');
|
||
|
}
|
||
|
}
|
||
|
});
|