0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/client/controllers/modals/transfer-owner.js
Jason Williams d59edf1806 Add a mixin for saving a subset of a model.
Closes #3403
- Add SelectiveSaveMixin so that a DS.Model can save one or more
  properties at a time while preserving other outstanding changes.
2014-07-27 21:04:35 +00:00

46 lines
No EOL
1.4 KiB
JavaScript

var TransferOwnerController = Ember.Controller.extend({
actions: {
confirmAccept: function () {
var user = this.get('model'),
self = this;
self.get('popover').closePopovers();
// Get owner role
this.store.find('role').then(function (result) {
return result.findBy('name', 'Owner');
}).then(function (ownerRole) {
// remove roles and assign owner role
user.get('roles').clear();
user.get('roles').pushObject(ownerRole);
return user.saveOnly('roles');
}).then(function () {
self.notifications.closePassive();
self.notifications.showSuccess('Ownership successfully transferred to ' + user.get('name'));
}).catch(function (errors) {
self.notifications.closePassive();
errors = Ember.isArray(errors) ? errors : Ember.A([errors]);
self.notifications.showErrors(errors);
});
},
confirmReject: function () {
return false;
}
},
confirm: {
accept: {
text: 'YEP - I\'M SURE',
buttonClass: 'button-delete'
},
reject: {
text: 'CANCEL',
buttonClass: 'button'
}
}
});
export default TransferOwnerController;