0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/controllers/modals/transfer-owner.js
Sebastian Gierlinger c43d860a3f Transfer Ownership
closes #3364 (special thanks to @jaswilli)
closes #3087
- added modal
- added controller
2014-07-23 12:41:31 +02:00

45 lines
No EOL
1.4 KiB
JavaScript

var TransferOwnerController = Ember.Controller.extend({
actions: {
confirmAccept: function () {
var user = this.get('model'),
self = this;
// 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.save({ format: false });
}).then(function (model) {
self.notifications.closePassive();
self.notifications.showSuccess('Settings successfully saved.');
return model;
}).catch(function (errors) {
self.notifications.closePassive();
self.notifications.showErrors(errors);
}).finally(function () {
self.get('popover').closePopovers();
});
},
confirmReject: function () {
return false;
}
},
confirm: {
accept: {
text: 'YEP - I\'M SURE',
buttonClass: 'button-delete'
},
reject: {
text: 'CANCEL',
buttonClass: 'button'
}
}
});
export default TransferOwnerController;