Using mixins on new species
This commit is contained in:
parent
76942a10d0
commit
cc85ee6f27
5 changed files with 29 additions and 49 deletions
|
@ -5,6 +5,9 @@ const { Mixin , inject: { service } } = Ember;
|
|||
export default Mixin.create({
|
||||
currentUser: service('session-account'),
|
||||
|
||||
fallbackRouteBefore: null,
|
||||
fallbackRouteAfter: null,
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('currentUser.account').then((user) => {
|
||||
|
@ -19,4 +22,15 @@ export default Mixin.create({
|
|||
this.transitionTo(this.get('fallbackRouteAfter'), model.get('id'));
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition: function(/*transition*/) {
|
||||
const controller = this.get('controller');
|
||||
const model = controller.get('model');
|
||||
|
||||
if (model.get('isNew')) {
|
||||
model.destroyRecord();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,6 +4,8 @@ import ajaxError from '../utils/ajax-error';
|
|||
const { Mixin } = Ember;
|
||||
|
||||
export default Mixin.create({
|
||||
fallbackRoute: null,
|
||||
|
||||
actions: {
|
||||
save: function() {
|
||||
const model = this.get('model');
|
||||
|
|
Reference in a new issue