Skip to content

Commit

Permalink
closes #992
Browse files Browse the repository at this point in the history
  • Loading branch information
psychobunny committed Feb 17, 2014
1 parent 7918a23 commit ed4b046
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 5 additions & 2 deletions public/src/forum/admin/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ define(function() {

listEl.on('click', 'button[data-action]', function() {
var action = this.getAttribute('data-action'),
gid = $(this).parents('li[data-gid]').attr('data-gid');
parent = $(this).parents('li[data-gid]'),
gid = parent.attr('data-gid'),
system = parseInt(parent.attr('data-system'), 10) === 1;

switch (action) {
case 'delete':
bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) {
if (confirm) {
socket.emit('admin.groups.delete', gid, function(err, data) {
console.log(err, data);
if(err) {
return app.alertError(err.message);
}
Expand Down Expand Up @@ -106,6 +107,8 @@ define(function() {

detailsModal.attr('data-gid', groupObj.gid);
detailsModal.modal('show');

$('.hide-if-system')[system ? 'hide' : 'show']();
});
break;
}
Expand Down
4 changes: 2 additions & 2 deletions public/templates/admin/groups.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="groups">
<ul id="groups-list">
<!-- BEGIN groups -->
<li data-gid="{groups.gid}">
<li data-gid="{groups.gid}" data-system="{groups.hidden}">
<div class="row">
<div class="col-lg-8">
<h2>{groups.name}</h2>
Expand Down Expand Up @@ -69,7 +69,7 @@
<div class="modal-body">
<div class="alert alert-danger hide" id="create-modal-error"></div>
<form>
<div class="form-group">
<div class="form-group hide-if-system">
<label for="group-name">Group Name</label>
<input type="text" class="form-control" id="change-group-name" placeholder="Group Name" />
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
expand: options.expand
}, next);
}, function (err, groups) {
// Remove deleted and hidden groups from this list
callback(err, groups.filter(function (group) {
if (parseInt(group.deleted, 10) === 1 || parseInt(group.hidden, 10) === 1) {
return false;
} else {
return true;
groups.forEach(function(group, g, arr) {
if (parseInt(group.deleted, 10) === 1) {
delete arr[g];
}
if (parseInt(group.hidden, 10) === 1) {
group.deletable = 0;
}
}));
});

callback(err, groups);
});
} else {
callback(null, []);
Expand Down

0 comments on commit ed4b046

Please sign in to comment.