mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 02:36:18 +08:00
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
Discourse.Group = Discourse.Model.extend({
|
|
userCountDisplay: function(){
|
|
var c = this.get('user_count');
|
|
// don't display zero its ugly
|
|
if(c > 0) {
|
|
return c;
|
|
}
|
|
}.property('user_count'),
|
|
|
|
loadUsers: function() {
|
|
var group = this;
|
|
|
|
Discourse.ajax('/admin/groups/' + this.get('id') + '/users').then(function(payload){
|
|
var users = Em.A()
|
|
payload.each(function(user){
|
|
users.addObject(Discourse.User.create(user));
|
|
});
|
|
group.set('users', users)
|
|
});
|
|
},
|
|
|
|
usernames: function() {
|
|
var users = this.get('users');
|
|
var usernames = "";
|
|
if(users) {
|
|
usernames = $.map(users, function(user){
|
|
return user.get('username');
|
|
}).join(',')
|
|
}
|
|
return usernames;
|
|
}.property('users')
|
|
|
|
});
|
|
|
|
Discourse.Group.reopenClass({
|
|
findAll: function(){
|
|
var list = Discourse.SelectableArray.create();
|
|
|
|
Discourse.ajax("/admin/groups").then(function(groups){
|
|
groups.each(function(group){
|
|
list.addObject(Discourse.Group.create(group));
|
|
});
|
|
});
|
|
|
|
return list;
|
|
},
|
|
|
|
find: function(id) {
|
|
var promise = new Em.Deferred();
|
|
|
|
setTimeout(function(){
|
|
promise.resolve(Discourse.Group.create({id: 1, name: "all mods", members: ["A","b","c"]}));
|
|
}, 1000);
|
|
|
|
return promise;
|
|
}
|
|
});
|