|
1 | 1 | (function() { |
2 | 2 |
|
| 3 | + /** |
| 4 | + This controller supports the interface for listing users in the admin section. |
| 5 | +
|
| 6 | + @class AdminUsersListController |
| 7 | + @extends Ember.ArrayController |
| 8 | + @namespace Discourse |
| 9 | + @module Discourse |
| 10 | + **/ |
3 | 11 | window.Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Presence, { |
4 | 12 | username: null, |
5 | 13 | query: null, |
|
8 | 16 |
|
9 | 17 | selectAllChanged: (function() { |
10 | 18 | var _this = this; |
11 | | - return this.get('content').each(function(user) { |
12 | | - return user.set('selected', _this.get('selectAll')); |
| 19 | + this.get('content').each(function(user) { |
| 20 | + user.set('selected', _this.get('selectAll')); |
13 | 21 | }); |
14 | 22 | }).observes('selectAll'), |
15 | 23 |
|
16 | 24 | filterUsers: Discourse.debounce(function() { |
17 | | - return this.refreshUsers(); |
| 25 | + this.refreshUsers(); |
18 | 26 | }, 250).observes('username'), |
19 | 27 |
|
20 | 28 | orderChanged: (function() { |
21 | | - return this.refreshUsers(); |
| 29 | + this.refreshUsers(); |
22 | 30 | }).observes('query'), |
23 | 31 |
|
24 | 32 | showApproval: (function() { |
25 | | - if (!Discourse.SiteSettings.must_approve_users) { |
26 | | - return false; |
27 | | - } |
28 | | - if (this.get('query') === 'new') { |
29 | | - return true; |
30 | | - } |
31 | | - if (this.get('query') === 'pending') { |
32 | | - return true; |
33 | | - } |
| 33 | + if (!Discourse.SiteSettings.must_approve_users) return false; |
| 34 | + if (this.get('query') === 'new') return true; |
| 35 | + if (this.get('query') === 'pending') return true; |
34 | 36 | }).property('query'), |
35 | 37 |
|
36 | 38 | selectedCount: (function() { |
37 | | - if (this.blank('content')) { |
38 | | - return 0; |
39 | | - } |
| 39 | + if (this.blank('content')) return 0; |
40 | 40 | return this.get('content').filterProperty('selected').length; |
41 | 41 | }).property('content.@each.selected'), |
42 | 42 |
|
|
45 | 45 | }).property('selectedCount'), |
46 | 46 |
|
47 | 47 | refreshUsers: function() { |
48 | | - return this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username'))); |
| 48 | + this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username'))); |
49 | 49 | }, |
50 | 50 |
|
51 | 51 | show: function(term) { |
52 | 52 | if (this.get('query') === term) { |
53 | | - return this.refreshUsers(); |
54 | | - } else { |
55 | | - return this.set('query', term); |
| 53 | + this.refreshUsers(); |
| 54 | + return; |
56 | 55 | } |
| 56 | + |
| 57 | + this.set('query', term); |
57 | 58 | }, |
58 | 59 |
|
59 | 60 | approveUsers: function() { |
60 | | - return Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected')); |
| 61 | + Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected')); |
61 | 62 | } |
62 | 63 |
|
63 | 64 | }); |
|
0 commit comments