mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
more group progress, UI getting there, controller mostly done
changed it so notify moderators goes to the moderators group allow admins to grant self moderation and revoke self moderation
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
Discourse.AdminGroupsController = Ember.ArrayController.extend({
|
||||
Discourse.AdminGroupsController = Ember.Controller.extend({
|
||||
itemController: 'adminGroup',
|
||||
|
||||
edit: function(group){
|
||||
this.get('model').select(group);
|
||||
group.loadUsers();
|
||||
group.load();
|
||||
},
|
||||
|
||||
refreshAutoGroups: function(){
|
||||
@@ -14,9 +14,31 @@ Discourse.AdminGroupsController = Ember.ArrayController.extend({
|
||||
controller.set('model', Discourse.Group.findAll());
|
||||
controller.set('refreshingAutoGroups',false);
|
||||
});
|
||||
},
|
||||
|
||||
newGroup: function(){
|
||||
var group = Discourse.Group.create();
|
||||
group.set("loaded", true);
|
||||
var model = this.get("model");
|
||||
model.addObject(group);
|
||||
model.select(group);
|
||||
},
|
||||
|
||||
save: function(group){
|
||||
if(!group.get("id")){
|
||||
group.create();
|
||||
} else {
|
||||
group.save();
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function(group){
|
||||
var list = this.get("model");
|
||||
if(group.get("id")){
|
||||
group.destroy().then(function(){
|
||||
list.removeObject(group);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.AdminGroupController = Ember.Controller.extend({
|
||||
|
||||
});
|
||||
|
||||
@@ -26,7 +26,8 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||
if (a.message) {
|
||||
return r.push({
|
||||
user: _this.userLookup[a.user_id],
|
||||
message: a.message
|
||||
message: a.message,
|
||||
permalink: a.permalink
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Discourse.Group = Discourse.Model.extend({
|
||||
loaded: false,
|
||||
|
||||
userCountDisplay: function(){
|
||||
var c = this.get('user_count');
|
||||
// don't display zero its ugly
|
||||
@@ -7,16 +9,19 @@ Discourse.Group = Discourse.Model.extend({
|
||||
}
|
||||
}.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));
|
||||
load: function() {
|
||||
var id = this.get('id');
|
||||
if(id && !this.get('loaded')) {
|
||||
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)
|
||||
group.set('loaded', true)
|
||||
});
|
||||
group.set('users', users)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
usernames: function() {
|
||||
@@ -28,7 +33,32 @@ Discourse.Group = Discourse.Model.extend({
|
||||
}).join(',')
|
||||
}
|
||||
return usernames;
|
||||
}.property('users')
|
||||
}.property('users'),
|
||||
|
||||
destroy: function(){
|
||||
var group = this;
|
||||
group.set('disableSave', true);
|
||||
|
||||
return Discourse.ajax("/admin/groups/" + this.get("id"), {type: "DELETE"})
|
||||
.then(function(){
|
||||
group.set('disableSave', false);
|
||||
});
|
||||
},
|
||||
|
||||
create: function(){
|
||||
var group = this;
|
||||
group.set('disableSave', true);
|
||||
|
||||
return Discourse.ajax("/admin/groups", {type: "POST", data: {
|
||||
group: {
|
||||
name: this.get('name'),
|
||||
usernames: this.get('usernames')
|
||||
}
|
||||
}}).then(function(r){
|
||||
group.set('disableSave', false);
|
||||
group.set('id', r.id);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class='message'>
|
||||
<div>{{#linkTo 'adminUser' user}}{{avatar user imageSize="small"}}{{/linkTo}} {{message}}</div>
|
||||
<div>{{#linkTo 'adminUser' user}}{{avatar user imageSize="small"}}{{/linkTo}} {{message}} <a href="{{unbound permalink}}">{{i18n admin.flags.view_message}}</a></div>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- work in progress, please ignore -->
|
||||
<div class='row'>
|
||||
<div class='row groups'>
|
||||
<div class='content-list span6'>
|
||||
<h3>{{i18n admin.groups.edit}}</h3>
|
||||
<ul>
|
||||
@@ -9,19 +9,35 @@
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
<div>
|
||||
<button {{bindAttr disabled="refreshingAutoGroups"}} {{action "refreshAutoGroups"}}>Refresh Automatic Groups</button>
|
||||
<div class='controls'>
|
||||
<button class='btn' {{bindAttr disabled="refreshingAutoGroups"}} {{action "refreshAutoGroups"}}>Refresh</button>
|
||||
<button class='btn' {{action newGroup}}>New</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='content-editor'>
|
||||
{{#if model.active}}
|
||||
{{#with model.active}}
|
||||
<h3>{{name}}</h3>
|
||||
{{view Discourse.UserSelector id="private-message-users" class="span8" placeholderKey="admin.groups.selector_placeholder" tabindex="1" usernamesBinding="usernames"}}
|
||||
<button {{bindAttr disabled="allowSave"}}>Save</button>
|
||||
{{#if model.active.loaded}}
|
||||
{{#with model.active}}
|
||||
{{#if automatic}}
|
||||
<h3>{{name}}</h3>
|
||||
{{else}}
|
||||
{{view Discourse.TextField valueBinding="name" placeholderKey="admin.groups.name_placeholder"}}
|
||||
{{/if}}
|
||||
|
||||
{{/with}}
|
||||
{{view Discourse.UserSelector id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" usernamesBinding="usernames"}}
|
||||
<div class='controls'>
|
||||
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
||||
{{#unless automatic}}
|
||||
{{#if id}}
|
||||
<a {{action destroy this}} class='delete-link'>{{i18n admin.customize.delete}}</a>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
{{/with}}
|
||||
{{else}}
|
||||
<div class='spinner'>{{i18n loading}}</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
nothing here yet
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user