Discourse Macro Helpers + Minor Fix to Admin User View

This commit is contained in:
Robin Ward
2013-07-11 19:35:52 -04:00
parent 89152116c6
commit 5eaae063f0
13 changed files with 136 additions and 69 deletions

View File

@@ -78,9 +78,7 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
@property hasSelection
**/
hasSelection: function() {
return this.get('selectedCount') > 0;
}.property('selectedCount'),
hasSelection: Em.computed.gt('selectedCount', 0),
/**
Refresh the current list of users.

View File

@@ -98,19 +98,14 @@ Discourse.AdminUser = Discourse.User.extend({
this.set('trustLevel.id', this.get('originalTrustLevel'));
},
isBanned: (function() {
return this.get('is_banned') === true;
}).property('is_banned'),
isBanned: Em.computed.equal('is_banned', true),
canBan: Em.computed.not('staff'),
canBan: (function() {
return !this.get('admin') && !this.get('moderator');
}).property('admin', 'moderator'),
banDuration: (function() {
banDuration: function() {
var banned_at = moment(this.banned_at);
var banned_till = moment(this.banned_till);
return banned_at.format('L') + " - " + banned_till.format('L');
}).property('banned_till', 'banned_at'),
}.property('banned_till', 'banned_at'),
ban: function() {
var duration = parseInt(window.prompt(I18n.t('admin.user.ban_duration')), 10);

View File

@@ -16,11 +16,6 @@ Discourse.AdminUserRoute = Discourse.Route.extend(Discourse.ModelReady, {
return Discourse.AdminUser.find(Em.get(params, 'username').toLowerCase());
},
setupController: function(controller, model) {
controller.set('model', model);
model.setOriginalTrustLevel();
},
renderTemplate: function() {
this.render({into: 'admin/templates/admin'});
},
@@ -28,6 +23,7 @@ Discourse.AdminUserRoute = Discourse.Route.extend(Discourse.ModelReady, {
modelReady: function(controller, adminUser) {
adminUser.loadDetails();
controller.set('model', adminUser);
adminUser.setOriginalTrustLevel();
}
});