From a00dea41e387051be16e634102741b8c0fbe2244 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 29 Jun 2009 15:09:41 +0000 Subject: [PATCH] differentiate between delete and publish AJAX calls. svn path=/plone.app.discussion/trunk/; revision=27725 --- .../browser/javascripts/moderation.js | 50 ++++-- plone/app/discussion/browser/moderation.pt | 148 +++++++++--------- plone/app/discussion/browser/moderation.py | 28 ++-- 3 files changed, 126 insertions(+), 100 deletions(-) diff --git a/plone/app/discussion/browser/javascripts/moderation.js b/plone/app/discussion/browser/javascripts/moderation.js index 70c1e3a..dc89a83 100644 --- a/plone/app/discussion/browser/javascripts/moderation.js +++ b/plone/app/discussion/browser/javascripts/moderation.js @@ -16,6 +16,7 @@ jq(document).ready(function() { } }); + /***************************************************************** * Comment actions (delete, publish) *****************************************************************/ @@ -25,31 +26,56 @@ jq(document).ready(function() { var params = jq(this).serialize(); var cell = jq(this).parent().get(0); var row = jq(cell).parent().get(0); + var currentFilter = jq(this).find("[name='form.button.Filter']").attr("value"); + var currentAction = jq(this).attr("class"); jq.post(target, params, function(data) { - jq(row).fadeOut("normal", function() { - jq(this).remove(); - }); + if (currentAction == 'background-form workflow_action' && currentFilter == '') { + alert("NotImplementedError: AJAX switch workflow state") + } + else { + jq(row).fadeOut("normal", function(){ + jq(this).remove(); + }); + } }); }); /***************************************************************** - * Bulk actions + * Bulk actions (delete, publish) *****************************************************************/ jq('form.bulkactions').submit(function(e) { e.preventDefault(); var target = jq(this).attr('action'); var params = jq(this).serialize(); var valArray = jq('input:checkbox:checked'); - jq.post(target, params, function(data) { - valArray.each(function () { - row = jq(this).parent().parent(); - row.fadeOut("normal", function() { - row.remove(); - }); + var currentFilter = jq(this).find("[name='form.button.Filter']").attr("value"); + var currentAction = jq(this).find("[name='form.select.BulkAction']").val(); + if (valArray.length) { + jq.post(target, params, function(data) { + valArray.each(function () { + // if bulkaction is delete, or the current filter is + // pending (because then publish also removes the comment), + // remove all selected comments. + if (currentAction == 'delete' || currentFilter == 'pending') { + row = jq(this).parent().parent(); + row.fadeOut("normal", function() { + row.remove(); + }); + } + // if bulkaction is publish and there is no current filter, + // change the workflow action + if (currentAction == 'publish') { + alert("NotImplementedError: AJAX switch workflow state") + } + }); }); - }); + } else { + // The user has submitted a bulk action, but no comment + // was selected. + // Todo: nicer and translated message + alert("You haven't selected anything for this bulk action."); + } }); - }); \ No newline at end of file diff --git a/plone/app/discussion/browser/moderation.pt b/plone/app/discussion/browser/moderation.pt index 1af1bb1..d6cec28 100644 --- a/plone/app/discussion/browser/moderation.pt +++ b/plone/app/discussion/browser/moderation.pt @@ -13,7 +13,7 @@ filter view/filter|nothing;">

- Review comments + Moderate comments