mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
dd50cca97a
Closes #3511, Closes #3512, Closes #3526 - show* methods now close existing passive notifications by default. They also now take an optional options object where existing parameters such as "delayed" and "defaultErrorText" can be passed in as well as the new "doNotClosePassive" flag. - Removed all explicit calls to notifications.closePassive except for the few places where it makes sense to call it separately.
52 lines
No EOL
1.6 KiB
JavaScript
52 lines
No EOL
1.6 KiB
JavaScript
var TransferOwnerController = Ember.Controller.extend({
|
|
actions: {
|
|
confirmAccept: function () {
|
|
var user = this.get('model'),
|
|
url = this.get('ghostPaths.url').api('users', 'owner'),
|
|
self = this;
|
|
|
|
self.get('popover').closePopovers();
|
|
|
|
ic.ajax.request(url, {
|
|
type: 'PUT',
|
|
data: {
|
|
owner: [{
|
|
'id': user.get('id')
|
|
}]
|
|
}
|
|
}).then(function (response) {
|
|
// manually update the roles for the users that just changed roles
|
|
// because store.pushPayload is not working with embedded relations
|
|
if (response && Ember.isArray(response.users)) {
|
|
response.users.forEach(function (userJSON) {
|
|
var user = self.store.getById('user', userJSON.id),
|
|
role = self.store.getById('role', userJSON.roles[0].id);
|
|
|
|
user.set('role', role);
|
|
});
|
|
}
|
|
|
|
self.notifications.showSuccess('Ownership successfully transferred to ' + user.get('name'));
|
|
}).catch(function (error) {
|
|
self.notifications.showAPIError(error);
|
|
});
|
|
},
|
|
|
|
confirmReject: function () {
|
|
return false;
|
|
}
|
|
},
|
|
|
|
confirm: {
|
|
accept: {
|
|
text: 'YEP - I\'M SURE',
|
|
buttonClass: 'button-delete'
|
|
},
|
|
reject: {
|
|
text: 'CANCEL',
|
|
buttonClass: 'button'
|
|
}
|
|
}
|
|
});
|
|
|
|
export default TransferOwnerController; |