2014-07-23 05:41:31 -05:00
|
|
|
var TransferOwnerController = Ember.Controller.extend({
|
|
|
|
actions: {
|
|
|
|
confirmAccept: function () {
|
|
|
|
var user = this.get('model'),
|
|
|
|
self = this;
|
|
|
|
|
2014-07-26 00:12:37 -05:00
|
|
|
self.get('popover').closePopovers();
|
|
|
|
|
2014-07-23 05:41:31 -05:00
|
|
|
// 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);
|
2014-07-26 00:12:37 -05:00
|
|
|
|
|
|
|
return user.saveOnly('roles');
|
|
|
|
}).then(function () {
|
2014-07-23 05:41:31 -05:00
|
|
|
self.notifications.closePassive();
|
2014-07-26 00:12:37 -05:00
|
|
|
self.notifications.showSuccess('Ownership successfully transferred to ' + user.get('name'));
|
2014-07-23 05:41:31 -05:00
|
|
|
}).catch(function (errors) {
|
|
|
|
self.notifications.closePassive();
|
2014-07-26 00:12:37 -05:00
|
|
|
|
|
|
|
errors = Ember.isArray(errors) ? errors : Ember.A([errors]);
|
2014-07-23 05:41:31 -05:00
|
|
|
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;
|