From f14ad11dd0218f4c82c48db74204add3d5d0f12d Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 20 Jan 2014 20:28:46 +0000 Subject: [PATCH] add remove user from group confirmation Added confirmation request when removing user from a group. --- public/src/forum/admin/groups.js | 20 ++++++++++++-------- public/templates/admin/groups.tpl | 1 + src/routes/admin.js | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/public/src/forum/admin/groups.js b/public/src/forum/admin/groups.js index 2a7d256364..94817826b0 100644 --- a/public/src/forum/admin/groups.js +++ b/public/src/forum/admin/groups.js @@ -2,7 +2,8 @@ define(function() { var Groups = {}; Groups.init = function() { - var createEl = document.getElementById('create'), + var yourid = templates.get('yourid'), + createEl = document.getElementById('create'), createModal = $('#create-modal'), createSubmitBtn = document.getElementById('create-modal-go'), createNameEl = $('#create-group-name'), @@ -171,13 +172,16 @@ define(function() { groupMembersEl.on('click', 'li[data-uid]', function() { var uid = this.getAttribute('data-uid'), gid = detailsModal.attr('data-gid'); - - socket.emit('admin.groups.leave', { - gid: gid, - uid: uid - }, function(err, data) { - if (!err) { - groupMembersEl.find('li[data-uid="' + uid + '"]').remove(); + bootbox.confirm('Are you sure you want to remove this user?', function(confirm) { + if (confirm){ + socket.emit('admin.groups.leave', { + gid: gid, + uid: uid + }, function(err, data) { + if (!err) { + groupMembersEl.find('li[data-uid="' + uid + '"]').remove(); + } + }); } }); }); diff --git a/public/templates/admin/groups.tpl b/public/templates/admin/groups.tpl index fa23608102..6984e97254 100644 --- a/public/templates/admin/groups.tpl +++ b/public/templates/admin/groups.tpl @@ -96,3 +96,4 @@ + \ No newline at end of file diff --git a/src/routes/admin.js b/src/routes/admin.js index 0b23680cd0..d7c1c7863f 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -429,7 +429,8 @@ var nconf = require('nconf'), expand: true }, function (err, groups) { res.json(200, { - groups: groups + groups: groups, + yourid: req.user.uid }); }); });