Ghost/core/client/controllers/modals/invite-new-user.js
Maurice Williams 972831c733 Implementation of "invite a new user" modal
Closes #3079
- new controller and template for invite-new-user-modal
- actually triggers email invite via POST /ghost/api/v0.1/users/
- setting default language value (on the client) when creating a user
- only available role is "Author" - pending 3196
- updates to UsersIndexController to allow dynamic property calculation and template rending
2014-07-06 16:18:51 -04:00

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;