diff --git a/plone/app/discussion/browser/controlpanel.py b/plone/app/discussion/browser/controlpanel.py index 73086e1..e968367 100644 --- a/plone/app/discussion/browser/controlpanel.py +++ b/plone/app/discussion/browser/controlpanel.py @@ -184,11 +184,8 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper): 'comment_one_state_workflow' in workflow_chain comment_review_workflow_enabled = \ 'comment_review_workflow' in workflow_chain - comment_multiple_state_review_workflow = \ - 'comment_multiple_state_review_workflow' in workflow_chain if one_state_workflow_enabled \ - or comment_review_workflow_enabled \ - or comment_multiple_state_review_workflow: + or comment_review_workflow_enabled: return return True diff --git a/plone/app/discussion/browser/javascripts/moderation.js b/plone/app/discussion/browser/javascripts/moderation.js index 1016fda..5275b45 100644 --- a/plone/app/discussion/browser/javascripts/moderation.js +++ b/plone/app/discussion/browser/javascripts/moderation.js @@ -80,124 +80,60 @@ require(["jquery", "pat-registry"], function($, registry) { success: function(msg) { if (moderate) { let url = location.href; - $("#review-comments").load(url + " #review-comments", function() { - init(); - $(".pat-plone-modal").patPloneModal(); - }); - }); - - - /********************************************************************** - * Bulk actions for comments (delete, publish) - **********************************************************************/ - $("input[name='form.button.BulkAction']").click(function (e) { - e.preventDefault(); - var form = $(this).closest("form"); - var target = $(form).attr('action'); - var params = $(form).serialize(); - var valArray = $('input:checkbox:checked'); - var selectField = $(form).find("[name='form.select.BulkAction']"); - - if (selectField.val() === '-1') { - // TODO: translate message - alert("You haven't selected a bulk action. Please select one."); - } else if (valArray.length === 0) { - // TODO: translate message - alert("You haven't selected any comment for this bulk action." + - "Please select at least one comment."); - } else { - $.post(target, params, function (data) { - // reset the bulkaction select - selectField.find("option[value='-1']").attr('selected', 'selected'); - // reload filtered comments - $("#review-comments").load(window.location + " #review-comments", function() { - init(); - $('.pat-plone-modal').patPloneModal(); - }); - }); - } - }); - - - /********************************************************************** - * Check or uncheck all checkboxes from the batch moderation page. - **********************************************************************/ - $("input[name='check_all']").click(function () { - if ($(this).val() === '0') { - $(this).parents("table") - .find("input:checkbox") - .prop("checked", true); - $(this).val("1"); - } else { - $(this).parents("table") - .find("input:checkbox") - .prop("checked", false); - $(this).val("0"); - } - }); - - /********************************************************************** - * select comments with review_state - **********************************************************************/ - - $("input[name='review_state']").click(function () { - // location.search = 'review_state=' + $(this).val(); - let review_state = $(this).val(); - let url = location.href; - if (location.search) { - url = location.href.replace(location.search, "?review_state=" + review_state); - } else { - url = location.href + "?review_state=" + review_state; - } - - $("#fieldset-moderate-comments").parent() - .load(url + " #fieldset-moderate-comments", function() { - init(); - $('.pat-plone-modal').patPloneModal(); - let stateObj = { review_state: review_state }; - history.pushState(stateObj, "moderate comments", url); - }); - }); - + $("#review-comments").load( + url + " #review-comments > *", + function() { + init(); + $(".pat-plone-modal").patPloneModal(); + } + ); + } else { + location.reload(); + } + }, + error: function(msg) { + alert( + "Error transmitting comment. (Error sending AJAX request:" + + target + + ")" + ); + } + }); + }); /********************************************************************** * Bulk actions for comments (delete, publish) **********************************************************************/ $("input[name='form.button.BulkAction']").click(function(e) { e.preventDefault(); - var form = $(this).parents("form"); + var form = $(this).closest("form"); var target = $(form).attr("action"); var params = $(form).serialize(); var valArray = $("input:checkbox:checked"); var selectField = $(form).find("[name='form.select.BulkAction']"); + if (selectField.val() === "-1") { - // XXX: translate message + // TODO: translate message alert("You haven't selected a bulk action. Please select one."); } else if (valArray.length === 0) { - // XXX: translate message + // TODO: translate message alert( "You haven't selected any comment for this bulk action." + "Please select at least one comment." ); } else { $.post(target, params, function(data) { - valArray.each(function() { - /* Remove all selected lines. */ - var row = $(this) - .parent() - .parent(); - row.fadeOut("normal", function() { - row.remove(); - }); - }); - // reload page if all comments have been removed - var comments = $("table#review-comments > tbody > tr"); - if (comments.length <= valArray.length) { - location.reload(); - } + // reset the bulkaction select + selectField.find("option[value='-1']").attr("selected", "selected"); + // reload filtered comments + $("#review-comments").load( + window.location + " #review-comments", + function() { + init(); + $(".pat-plone-modal").patPloneModal(); + } + ); }); - // reset the bulkaction select - selectField.find("option[value='-1']").attr("selected", "selected"); } }); @@ -220,31 +156,30 @@ require(["jquery", "pat-registry"], function($, registry) { } }); - /********************************************************************** - * Comments published: Load history for publishing date. - **********************************************************************/ - $(".last-history-entry").each(function() { - var lasthistoryentry = $(this); - $.ajax({ - url: lasthistoryentry.attr("data-href"), - success: function (data) { - lasthistoryentry.html($(data).find(".historyByLine").first()); - // format date - registry.scan(lasthistoryentry); - }, - error: function (msg) { - console.error("Error getting history."); - } - }); - }); - }; // end init + /********************************************************************** + * select comments with review_state + **********************************************************************/ - $("#review-comments").load(url + " #review-comments", function() { - init(); - $(".pat-plone-modal").patPloneModal(); - let stateObj = { review_state: review_state }; - history.pushState(stateObj, "moderate comments", url); - }); + $("input[name='review_state']").click(function() { + let review_state = $(this).val(); + let url = location.href; + if (location.search) { + url = location.href.replace( + location.search, + "?review_state=" + review_state + ); + } else { + url = location.href + "?review_state=" + review_state; + } + + $("#fieldset-moderate-comments") + .parent() + .load(url + " #fieldset-moderate-comments", function() { + init(); + $(".pat-plone-modal").patPloneModal(); + let stateObj = { review_state: review_state }; + history.pushState(stateObj, "moderate comments", url); + }); }); /********************************************************************** @@ -269,26 +204,23 @@ require(["jquery", "pat-registry"], function($, registry) { }); /********************************************************************** - * Comments approved: Load history for approved date. + * Comments published: Load history for publishing date. **********************************************************************/ $(".last-history-entry").each(function() { - var me = $(this); + var lasthistoryentry = $(this); $.ajax({ - url: me.attr("data-href"), + url: lasthistoryentry.attr("data-href"), success: function(data) { - let first_history_entry = $(data) - .find(".historyByLine") - .first(); - me.html(""); - first_history_entry.children().each(function() { - me.append($(this)); - me.append("
"); - }); + lasthistoryentry.html( + $(data) + .find(".historyByLine") + .first() + ); // format date - registry.scan(me); + registry.scan(lasthistoryentry); }, error: function(msg) { - alert("Error getting history."); + console.error("Error getting history."); } }); }); diff --git a/plone/app/discussion/browser/moderation.pt b/plone/app/discussion/browser/moderation.pt index df6d455..bb7d715 100644 --- a/plone/app/discussion/browser/moderation.pt +++ b/plone/app/discussion/browser/moderation.pt @@ -46,21 +46,12 @@ - -
-
-

- No comments -

-
-
- -
-
@@ -187,9 +178,11 @@ class="context" type="submit" value="Label" - tal:attributes="id item/id; + tal:attributes="id string:${item/id}_${transition/id}; data-transition transition/id; - value python:translationhelper.translate(transition['title'])" + value python:translationhelper.translate(transition['title']); + style python:transition['id']=='publish' and 'background-color: #5cb85c;; border-color: #4cae4c;;' or ''; + " />
diff --git a/plone/app/discussion/browser/moderation.py b/plone/app/discussion/browser/moderation.py index a8f186e..cbbd784 100644 --- a/plone/app/discussion/browser/moderation.py +++ b/plone/app/discussion/browser/moderation.py @@ -113,15 +113,15 @@ class View(BrowserView): Example: pending - [{'id': 'mark_as_spam', 'url': 'http://localhost:8083/PloneRejected/testfolder/testpage/++conversation++default/1575415863542780/content_status_modify?workflow_action=mark_as_spam', 'icon': '', 'category': 'workflow', 'transition': , 'title': 'Spam', 'link_target': None, 'visible': True, 'available': True, 'allowed': True}, + [{'id': 'mark_as_spam', 'url': 'http://localhost:8083/PloneRejected/testfolder/testpage/++conversation++default/1575415863542780/content_status_modify?workflow_action=mark_as_spam', 'icon': '', 'category': 'workflow', 'transition': , 'title': 'Spam', 'link_target': None, 'visible': True, 'available': True, 'allowed': True}, {'id': 'publish', 'url': 'http://localhost:8083/PloneRejected/testfolder/testpage/++conversation++default/1575415863542780/content_status_modify?workflow_action=publish', 'icon': '', 'category': 'workflow', - 'transition': , + 'transition': , 'title': 'Approve', 'link_target': None, 'visible': True, 'available': True, 'allowed': True}, - {'id': 'reject', 'url': 'http://localhost:8083/PloneRejected/testfolder/testpage/++conversation++default/1575415863542780/content_status_modify?workflow_action=reject', 'icon': '', 'category': 'workflow', 'transition': , 'title': 'Reject', 'link_target': None, 'visible': True, 'available': True, 'allowed': True}] + {'id': 'reject', 'url': 'http://localhost:8083/PloneRejected/testfolder/testpage/++conversation++default/1575415863542780/content_status_modify?workflow_action=reject', 'icon': '', 'category': 'workflow', 'transition': , 'title': 'Reject', 'link_target': None, 'visible': True, 'available': True, 'allowed': True}] """ if obj: diff --git a/plone/app/discussion/profiles/default/workflows.xml b/plone/app/discussion/profiles/default/workflows.xml index 820f22d..328a7ac 100644 --- a/plone/app/discussion/profiles/default/workflows.xml +++ b/plone/app/discussion/profiles/default/workflows.xml @@ -1,7 +1,6 @@ - diff --git a/plone/app/discussion/profiles/default/workflows/comment_multiple_state_review_workflow/definition.xml b/plone/app/discussion/profiles/default/workflows/comment_multiple_state_review_workflow/definition.xml deleted file mode 100644 index 95b11ac..0000000 --- a/plone/app/discussion/profiles/default/workflows/comment_multiple_state_review_workflow/definition.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - Access contents information - Modify portal content - Reply to item - View - - Submitted, pending review. - - - - - Manager - Owner - Reviewer - - - Manager - Owner - Reviewer - - - - - Manager - Owner - Reviewer - - - - Visible to everyone, non-editable. - - - - - - - Manager - - - - - - - - - - - - - - - - - - Spam comments are invisible to other users. - Spam - - Review comments - - - - Approving the comment makes it visible to other users. - Approve - - Review comments - - - - Recall - - Review comments - - - - Rejected comments are invisible to other users. - Reject - - Review comments - - - - Previous transition - - - transition/getId|nothing - - - - - - The ID of the user who performed the previous transition - - - user/getUserName - - - - - - Comment about the last transition - - - python:state_change.kwargs.get('comment', '') - - - - - - Provides access to workflow history - - - state_change/getHistory - - - Request review - Review portal content - - - - When the previous transition was performed - - - state_change/getDateTime - - - - - diff --git a/plone/app/discussion/profiles/default/workflows/comment_review_workflow/definition.xml b/plone/app/discussion/profiles/default/workflows/comment_review_workflow/definition.xml index 6936319..af19e9e 100644 --- a/plone/app/discussion/profiles/default/workflows/comment_review_workflow/definition.xml +++ b/plone/app/discussion/profiles/default/workflows/comment_review_workflow/definition.xml @@ -7,125 +7,130 @@ state_variable="review_state" initial_state="pending" i18n:attributes="title; description"> + Access contents information + Modify portal content + Reply to item + View + + Submitted, pending review. + + + + + Manager + Owner + Reviewer + + + Manager + Owner + Reviewer + + + + + Manager + Owner + Reviewer + + + + Visible to everyone, non-editable. + + + + + + + Manager + + + + + + + + + + + + + + + + + + Spam comments are invisible to other users. + Spam + + Review comments + + + + Approving the comment makes it visible to other users. + Approve + + Review comments + + + + Recall + + Review comments + + + + Rejected comments are invisible to other users. + Reject + + Review comments + + + + Previous transition + - Access contents information - Modify portal content - View - Reply to item + transition/getId|nothing + + + + + + The ID of the user who performed the previous transition + - - - - Submitted, pending review. - - - Manager - Owner - Reviewer - - - Manager - Owner - Reviewer - - - Manager - Owner - Reviewer - - - - + user/getUserName + + + + + + Comment about the last transition + - - - Visible to everyone, non-editable. - - - - - Manager - - - - - - + python:state_change.kwargs.get('comment', '') + + + + + + Provides access to workflow history + - - - Approving the comment makes it visible to other users. - - Approve - - Review comments - - + state_change/getHistory + + + Request review + Review portal content + + + + When the previous transition was performed + - - Previous transition - - transition/getId|nothing - - - - - - - - The ID of the user who performed the previous transition - - - user/getUserName - - - - - - - - Comment about the last transition - - - python:state_change.kwargs.get('comment', '') - - - - - - - - Provides access to workflow history - - - state_change/getHistory - - - Request review - Review portal content - - - - - - When the previous transition was performed - - - state_change/getDateTime - - - - - - + state_change/getDateTime + + + + + diff --git a/plone/app/discussion/tests/robot/test_moderation.robot b/plone/app/discussion/tests/robot/test_moderation.robot index bca8562..a33d1d5 100644 --- a/plone/app/discussion/tests/robot/test_moderation.robot +++ b/plone/app/discussion/tests/robot/test_moderation.robot @@ -68,7 +68,7 @@ I add a comment and delete it Wait Until Page Does Not Contain This is a comment workflow multiple enabled - Go To ${PLONE_URL}/@@content-controlpanel?type_id=Discussion%20Item&new_workflow=comment_multiple_state_review_workflow + Go To ${PLONE_URL}/@@content-controlpanel?type_id=Discussion%20Item&new_workflow=comment_review_workflow Click Button Save # Then diff --git a/plone/app/discussion/tests/test_moderation_multiple_state_view.py b/plone/app/discussion/tests/test_moderation_multiple_state_view.py index fe144a0..72b1db0 100644 --- a/plone/app/discussion/tests/test_moderation_multiple_state_view.py +++ b/plone/app/discussion/tests/test_moderation_multiple_state_view.py @@ -31,7 +31,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase): self.context = self.portal self.portal.portal_workflow.setChainForPortalTypes( ('Discussion Item',), - 'comment_multiple_state_review_workflow', + 'comment_review_workflow', ) self.wf_tool = self.portal.portal_workflow # Add a conversation with three comments diff --git a/plone/app/discussion/upgrades.py b/plone/app/discussion/upgrades.py index 2bb3c28..1d4172f 100644 --- a/plone/app/discussion/upgrades.py +++ b/plone/app/discussion/upgrades.py @@ -73,7 +73,3 @@ def upgrade_comment_workflows(context): def add_js_to_plone_legacy(context): context.runImportStepFromProfile(default_profile, 'plone.app.registry') - - -def add_multiple_state_workflow(context): - upgrade_comment_workflows_retain_current_workflow(context) diff --git a/plone/app/discussion/upgrades.zcml b/plone/app/discussion/upgrades.zcml index d64591c..02a7e54 100644 --- a/plone/app/discussion/upgrades.zcml +++ b/plone/app/discussion/upgrades.zcml @@ -62,15 +62,4 @@ /> - - - -