Ghost/ghost/admin/mixins/nprogress-save.js
Matt Enlow 0122ecd593 Fire NProgress on User, Post, and Settings save
Closes #3037
- Created `NProgressSaveMixin`, which extends the `save` method of a model
  to fire NProgress.
- Extended `UserModel`, `PostModel`, and `SettingModel` with the new
  mixin.
- NProgress can be disabled by passing an options hash to the save function with the `{disableNProgress:true}`
- Now that the ValidationEngine isn't the only thing playing with options inside of `model#save`, refactored it to pass the options down the super chain.
2014-07-13 14:19:27 -06:00

18 lines
499 B
JavaScript

var NProgressSaveMixin = Ember.Mixin.create({
save: function (options) {
if (options && options.disableNProgress) {
return this._super(options);
}
NProgress.start();
return this._super(options).then(function (value) {
NProgress.done();
return value;
}).catch(function (error) {
NProgress.done();
return Ember.RSVP.reject(error);
});
}
});
export default NProgressSaveMixin;