diff --git a/code/CMSBatchAction.php b/code/CMSBatchAction.php index d8b33cf7..0facc18d 100644 --- a/code/CMSBatchAction.php +++ b/code/CMSBatchAction.php @@ -44,9 +44,11 @@ abstract class CMSBatchAction extends Object { foreach($pages as $page) { // Perform the action - if (!call_user_func_array(array($page, $helperMethod), $arguments)) { + if (call_user_func_array(array($page, $helperMethod), $arguments) === false) { $failures++; + FormResponse::add("\$('sitetree').addNodeClassByIdx('$page->ID', 'failed');"); } + // Now make sure the tree title is appropriately updated $publishedRecord = DataObject::get_by_id('SiteTree', $page->ID); diff --git a/css/cms_left.css b/css/cms_left.css index 89c8b887..4935eebc 100644 --- a/css/cms_left.css +++ b/css/cms_left.css @@ -119,6 +119,9 @@ ul.tree.multiselect span.a.nodelete span.b a { ul.tree.multiselect span.a.treeloading span.b a { background-image: url(../images/tickbox-greyedout.gif) !important; } +ul.tree.multiselect span.a.failed span.b a { + background-image: url(../images/tickbox-fail.gif) !important; +} ul.tree.multiselect span.a.selected span.b span.c a { diff --git a/images/tickbox-fail.gif b/images/tickbox-fail.gif new file mode 100644 index 00000000..88666fe2 Binary files /dev/null and b/images/tickbox-fail.gif differ diff --git a/javascript/CMSMain_left.js b/javascript/CMSMain_left.js index f13d4ece..b00fe33c 100755 --- a/javascript/CMSMain_left.js +++ b/javascript/CMSMain_left.js @@ -273,6 +273,9 @@ batchactionsclass.prototype = { jQuery('#BatchActionParameters').hide(); } + // Don't show actions that have failed from the previous execution + batchActionGlobals.removeFailures(); + batchActionGlobals.refreshSelected(); }, @@ -407,7 +410,7 @@ batchActionGlobals = { }); // Post to the server to ask which pages can have this batch action applied - var applicablePagesURL = $('choose_batch_action').value + '/applicablepages?csvIDs=' + ids.join(',') + ',horse'; + var applicablePagesURL = $('choose_batch_action').value + '/applicablepages?csvIDs=' + ids.join(','); jQuery.getJSON(applicablePagesURL, function(applicableIDs) { var i; var applicableIDMap = {}; @@ -433,6 +436,27 @@ batchActionGlobals = { }); } }, + + /** + * Deselect all nodes in the tree + */ + deselectAll : function() { + batchActionGlobals.selectedNodes = {} + jQuery('#sitetree').find('li').each(function() { + this.removeNodeClass('selected'); + this.selected = false; + }); + }, + + /** + * Remove the indications of failed batch actions + */ + removeFailures : function() { + jQuery('#sitetree').find('li.failed').each(function() { + this.removeNodeClass('failed'); + }); + }, + unfilterSiteTree : function() { // Reload the site tree if it has been filtered if ($('SiteTreeIsFiltered').value == 1) { @@ -495,12 +519,15 @@ publishpage.prototype = { statusMessage(ingText); $('batchactions_go').className = 'loading'; + // Don't show actions that have failed from the previous execution + batchActionGlobals.removeFailures(); + // Submit form Ajax.SubmitForm(this, null, { onSuccess : function(response) { Ajax.Evaluator(response); $('batchactions_go').className = ''; - treeactions.closeSelection($('batchactions')); + batchActionGlobals.deselectAll(); }, onFailure : function(response) { errorMessage('Error ' + ingText, response); diff --git a/javascript/LeftAndMain_left.js b/javascript/LeftAndMain_left.js index 2d4b33ff..7289dbd2 100755 --- a/javascript/LeftAndMain_left.js +++ b/javascript/LeftAndMain_left.js @@ -132,6 +132,12 @@ TreeAPI.prototype = { aTag.innerHTML = title; }); }, + + addNodeClassByIdx : function(idx, className) { + this.performOnTreeNode(idx, function(treeNode) { + treeNode.addNodeClass(className); + }); + }, setNodeIcon: function(idx, oldClassName, newClassName) { this.performOnTreeNode(idx, function(treeNode) {