Adding helper for invite status

closes #3309, refs #3229

- adds different message depending on status
- doesn't delete the new user if the problem was an email error
- filters the 2 lists based on all statuses
This commit is contained in:
Hannah Wolfe 2014-07-19 01:58:27 +01:00
parent 9ad9e6e645
commit d3491c53b9
5 changed files with 22 additions and 6 deletions

View File

@ -37,7 +37,12 @@ var InviteNewUserController = Ember.Controller.extend({
self.notifications.showSuccess(notificationText, false); self.notifications.showSuccess(notificationText, false);
}).catch(function (errors) { }).catch(function (errors) {
if (errors[0].message.indexOf('Email Error:') === -1) {
newUser.deleteRecord(); newUser.deleteRecord();
} else {
newUser.set('status', 'invited-pending');
}
self.notifications.closePassive(); self.notifications.closePassive();
self.notifications.showErrors(errors); self.notifications.showErrors(errors);
}); });

View File

@ -1,9 +1,9 @@
var UsersIndexController = Ember.ArrayController.extend({ var UsersIndexController = Ember.ArrayController.extend({
users: Ember.computed.alias('model'), users: Ember.computed.alias('model'),
activeUsers: Ember.computed.filterBy('users', 'status', 'active'), activeUsers: Ember.computed.filterBy('users', 'active', true).property('users'),
invitedUsers: Ember.computed.filterBy('users', 'status', 'invited') invitedUsers: Ember.computed.filterBy('users', 'invited', true).property('users')
}); });
export default UsersIndexController; export default UsersIndexController;

View File

@ -63,6 +63,7 @@ var SettingsUserController = Ember.ObjectController.extend({
var self = this; var self = this;
this.get('model').resendInvite().then(function () { this.get('model').resendInvite().then(function () {
self.get('model').set('status', 'invited');
var notificationText = 'Invitation resent! (' + self.get('email') + ')'; var notificationText = 'Invitation resent! (' + self.get('email') + ')';
self.notifications.showSuccess(notificationText, false); self.notifications.showSuccess(notificationText, false);
}).catch(function (error) { }).catch(function (error) {

View File

@ -64,8 +64,14 @@ var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
return validationErrors; return validationErrors;
}.property('password', 'newPassword', 'ne2Password'), }.property('password', 'newPassword', 'ne2Password'),
isPasswordValid: Ember.computed.empty('passwordValidationErrors.[]') isPasswordValid: Ember.computed.empty('passwordValidationErrors.[]'),
active: function () {
return _.contains(['active', 'warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'], this.get('status'));
}.property('status'),
invited: function () {
return _.contains(['invited', 'invited-pending'], this.get('status'));
}.property('status'),
pending: Ember.computed.equal('status', 'invited-pending').property('status')
}); });
export default User; export default User;

View File

@ -19,7 +19,11 @@
<div class="object-list-item-body"> <div class="object-list-item-body">
<span class="name">{{email}}</span><br> <span class="name">{{email}}</span><br>
{{#if pending}}
<span class="red">Invitation not sent - please try again</span>
{{else}}
<span class="description">Invitation sent: {{created_at}}</span> <span class="description">Invitation sent: {{created_at}}</span>
{{/if}}
</div> </div>
<aside class="object-list-item-aside"> <aside class="object-list-item-aside">
<a class="object-list-action" href="#" {{action "revoke"}}>Revoke</a> <a class="object-list-action" href="#" {{action "revoke"}}>Revoke</a>