mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
fixed admin groups page
changed gid to groupName
This commit is contained in:
@@ -62,13 +62,13 @@ define(function() {
|
|||||||
listEl.on('click', 'button[data-action]', function() {
|
listEl.on('click', 'button[data-action]', function() {
|
||||||
var el = $(this),
|
var el = $(this),
|
||||||
action = el.attr('data-action'),
|
action = el.attr('data-action'),
|
||||||
gid = el.parents('li[data-gid]').attr('data-gid');
|
groupName = el.parents('li[data-groupname]').attr('data-groupname');
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) {
|
bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('admin.groups.delete', gid, function(err, data) {
|
socket.emit('admin.groups.delete', groupName, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ define(function() {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'members':
|
case 'members':
|
||||||
socket.emit('admin.groups.get', gid, function(err, groupObj) {
|
socket.emit('admin.groups.get', groupName, function(err, groupObj) {
|
||||||
var formEl = detailsModal.find('form'),
|
var formEl = detailsModal.find('form'),
|
||||||
nameEl = formEl.find('#change-group-name'),
|
nameEl = formEl.find('#change-group-name'),
|
||||||
descEl = formEl.find('#change-group-desc'),
|
descEl = formEl.find('#change-group-desc'),
|
||||||
@@ -100,7 +100,7 @@ define(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
detailsModal.attr('data-gid', groupObj.gid);
|
detailsModal.attr('data-groupname', groupObj.name);
|
||||||
detailsModal.modal('show');
|
detailsModal.modal('show');
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -146,7 +146,7 @@ define(function() {
|
|||||||
searchResults.on('click', 'li[data-uid]', function() {
|
searchResults.on('click', 'li[data-uid]', function() {
|
||||||
var userLabel = $(this),
|
var userLabel = $(this),
|
||||||
uid = parseInt(userLabel.attr('data-uid')),
|
uid = parseInt(userLabel.attr('data-uid')),
|
||||||
gid = detailsModal.attr('data-gid'),
|
groupName = detailsModal.attr('data-groupname'),
|
||||||
members = [];
|
members = [];
|
||||||
|
|
||||||
groupMembersEl.find('li[data-uid]').each(function() {
|
groupMembersEl.find('li[data-uid]').each(function() {
|
||||||
@@ -155,7 +155,7 @@ define(function() {
|
|||||||
|
|
||||||
if (members.indexOf(uid) === -1) {
|
if (members.indexOf(uid) === -1) {
|
||||||
socket.emit('admin.groups.join', {
|
socket.emit('admin.groups.join', {
|
||||||
gid: gid,
|
groupName: groupName,
|
||||||
uid: uid
|
uid: uid
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@@ -167,14 +167,14 @@ define(function() {
|
|||||||
|
|
||||||
groupMembersEl.on('click', 'li[data-uid]', function() {
|
groupMembersEl.on('click', 'li[data-uid]', function() {
|
||||||
var uid = $(this).attr('data-uid'),
|
var uid = $(this).attr('data-uid'),
|
||||||
gid = detailsModal.attr('data-gid');
|
groupName = detailsModal.attr('data-groupname');
|
||||||
|
|
||||||
socket.emit('admin.groups.get', gid, function(err, groupObj){
|
socket.emit('admin.groups.get', gid, function(err, groupObj){
|
||||||
if (!err){
|
if (!err){
|
||||||
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
|
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
|
||||||
if (confirm){
|
if (confirm){
|
||||||
socket.emit('admin.groups.leave', {
|
socket.emit('admin.groups.leave', {
|
||||||
gid: gid,
|
groupName: groupName,
|
||||||
uid: uid
|
uid: uid
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@@ -191,10 +191,10 @@ define(function() {
|
|||||||
var formEl = detailsModal.find('form'),
|
var formEl = detailsModal.find('form'),
|
||||||
nameEl = formEl.find('#change-group-name'),
|
nameEl = formEl.find('#change-group-name'),
|
||||||
descEl = formEl.find('#change-group-desc'),
|
descEl = formEl.find('#change-group-desc'),
|
||||||
gid = detailsModal.attr('data-gid');
|
groupName = detailsModal.attr('data-groupname');
|
||||||
|
|
||||||
socket.emit('admin.groups.update', {
|
socket.emit('admin.groups.update', {
|
||||||
gid: gid,
|
groupName: groupName,
|
||||||
values: {
|
values: {
|
||||||
name: nameEl.val(),
|
name: nameEl.val(),
|
||||||
description: descEl.val()
|
description: descEl.val()
|
||||||
|
|||||||
@@ -358,12 +358,12 @@ SocketAdmin.groups.create = function(socket, data, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.groups.delete = function(socket, gid, callback) {
|
SocketAdmin.groups.delete = function(socket, groupName, callback) {
|
||||||
groups.destroy(gid, callback);
|
groups.destroy(groupName, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.groups.get = function(socket, gid, callback) {
|
SocketAdmin.groups.get = function(socket, groupName, callback) {
|
||||||
groups.get(gid, {
|
groups.get(groupName, {
|
||||||
expand: true
|
expand: true
|
||||||
}, function(err, groupObj) {
|
}, function(err, groupObj) {
|
||||||
callback(err, groupObj || undefined);
|
callback(err, groupObj || undefined);
|
||||||
@@ -375,7 +375,7 @@ SocketAdmin.groups.join = function(socket, data, callback) {
|
|||||||
return callback(new Error('invalid data'));
|
return callback(new Error('invalid data'));
|
||||||
}
|
}
|
||||||
|
|
||||||
groups.join(data.gid, data.uid, callback);
|
groups.join(data.groupName, data.uid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.groups.leave = function(socket, data, callback) {
|
SocketAdmin.groups.leave = function(socket, data, callback) {
|
||||||
@@ -383,7 +383,7 @@ SocketAdmin.groups.leave = function(socket, data, callback) {
|
|||||||
return callback(new Error('invalid data'));
|
return callback(new Error('invalid data'));
|
||||||
}
|
}
|
||||||
|
|
||||||
groups.leave(data.gid, data.uid, callback);
|
groups.leave(data.groupName, data.uid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.groups.update = function(socket, data, callback) {
|
SocketAdmin.groups.update = function(socket, data, callback) {
|
||||||
@@ -391,7 +391,7 @@ SocketAdmin.groups.update = function(socket, data, callback) {
|
|||||||
return callback(new Error('invalid data'));
|
return callback(new Error('invalid data'));
|
||||||
}
|
}
|
||||||
|
|
||||||
groups.update(data.gid, data.values, function(err) {
|
groups.update(data.groupName, data.values, function(err) {
|
||||||
callback(err ? err.message : null);
|
callback(err ? err.message : null);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user