mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
|
var InviteNewUserController = Ember.Controller.extend({
|
||
|
|
||
|
confirm: {
|
||
|
accept: {
|
||
|
text: 'send invitation now'
|
||
|
},
|
||
|
reject: {
|
||
|
buttonClass: 'hidden'
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// @TODO: replace with roles from server - see issue #3196
|
||
|
roles: [
|
||
|
{
|
||
|
id: 3,
|
||
|
name: 'Author'
|
||
|
}
|
||
|
],
|
||
|
|
||
|
actions: {
|
||
|
confirmAccept: function () {
|
||
|
var email = this.get('email'),
|
||
|
role_id = this.get('role'),
|
||
|
self = this,
|
||
|
newUser;
|
||
|
|
||
|
newUser = this.store.createRecord('user', {
|
||
|
'email': email,
|
||
|
'role': role_id
|
||
|
});
|
||
|
|
||
|
newUser.save().then(function () {
|
||
|
var notificationText = 'Invitation sent! (' + email + ')';
|
||
|
|
||
|
self.notifications.showSuccess(notificationText, false);
|
||
|
}).fail(function (error) {
|
||
|
self.notifications.closePassive();
|
||
|
self.notifications.showAPIError(error);
|
||
|
});
|
||
|
|
||
|
this.set('email', null);
|
||
|
this.set('role', null);
|
||
|
|
||
|
},
|
||
|
|
||
|
confirmReject: function () {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
export default InviteNewUserController;
|