Merge pull request #3326 from ErisDS/issue-3309

Adding helper for invite status
This commit is contained in:
Hannah Wolfe 2014-07-20 19:11:05 +01:00
commit c2f0fd54da
6 changed files with 23 additions and 7 deletions

View File

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

View File

@ -1,9 +1,9 @@
var UsersIndexController = Ember.ArrayController.extend({
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;

View File

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

View File

@ -64,8 +64,14 @@ var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
return validationErrors;
}.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;

View File

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

View File

@ -234,7 +234,7 @@ users = {
return when.reject(new errors.ValidationError(error.message));
});
});
},
}
};