diff --git a/public/language/en-GB/admin/manage/post-queue.json b/public/language/en-GB/admin/manage/post-queue.json index f748fb0ee2..4de24c991b 100644 --- a/public/language/en-GB/admin/manage/post-queue.json +++ b/public/language/en-GB/admin/manage/post-queue.json @@ -6,5 +6,6 @@ "title": "Title", "content": "Content", "posted": "Posted", - "reply-to": "Reply to \"%1\"" + "reply-to": "Reply to \"%1\"", + "content-editable": "You can click on individual content to edit before posting." } \ No newline at end of file diff --git a/public/src/admin/manage/post-queue.js b/public/src/admin/manage/post-queue.js index 2bb9931dec..9413a839e2 100644 --- a/public/src/admin/manage/post-queue.js +++ b/public/src/admin/manage/post-queue.js @@ -5,6 +5,8 @@ define('admin/manage/post-queue', function () { var PostQueue = {}; PostQueue.init = function () { + $('[data-toggle="tooltip"]').tooltip(); + $('.posts-list').on('click', '[data-action]', function () { var parent = $(this).parents('[data-id]'); var action = $(this).attr('data-action'); @@ -19,6 +21,18 @@ define('admin/manage/post-queue', function () { }); return false; }); + + $('.posts-list').on('input', '[data-id]', function () { + var el = $(this); + socket.emit('posts.editQueuedContent', { + id: el.attr('data-id'), + content: el.find('.post-content').html(), + }, function (err) { + if (err) { + return app.alertError(err); + } + }); + }); }; return PostQueue; diff --git a/src/posts/queue.js b/src/posts/queue.js index 4cdedeca03..5419a28d98 100644 --- a/src/posts/queue.js +++ b/src/posts/queue.js @@ -70,6 +70,8 @@ module.exports = function (Posts) { }, function (next) { next(null, { + id: id, + type: type, queued: true, message: '[[success:post-queued]]', }); @@ -178,4 +180,27 @@ module.exports = function (Posts) { }, ], callback); } + + Posts.editQueuedContent = function (uid, id, content, callback) { + async.waterfall([ + function (next) { + user.isAdminOrGlobalMod(uid, next); + }, + function (isAdminOrGlobalMod, next) { + if (!isAdminOrGlobalMod) { + return callback(new Error('[[error:no-privileges]]')); + } + db.getObject('post:queue:' + id, next); + }, + function (data, next) { + try { + data.data = JSON.parse(data.data); + } catch (err) { + return next(err); + } + data.data.content = content; + db.setObjectField('post:queue:' + id, 'data', JSON.stringify(data.data), next); + }, + ], callback); + }; }; diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index a5462ef5bb..3cad4b6db0 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -175,6 +175,12 @@ SocketPosts.accept = function (socket, data, callback) { SocketPosts.reject = function (socket, data, callback) { acceptOrReject(posts.removeFromQueue, socket, data, callback); }; +SocketPosts.editQueuedContent = function (socket, data, callback) { + if (!data || !data.id || !data.content) { + return callback(new Error('[[error:invalid-data]]')); + } + posts.editQueuedContent(socket.uid, data.id, data.content, callback); +}; function acceptOrReject(method, socket, data, callback) { async.waterfall([ diff --git a/src/views/admin/manage/post-queue.tpl b/src/views/admin/manage/post-queue.tpl index 001479aa58..5e46db2a36 100644 --- a/src/views/admin/manage/post-queue.tpl +++ b/src/views/admin/manage/post-queue.tpl @@ -18,7 +18,7 @@