From 79968d0814db9c650a8eddc319e0046e4f608b31 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 Jan 2010 00:14:29 +0000 Subject: [PATCH] API CHANGE: Added capability for batch actions to indicate failure through red checkboxes (from r94868) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@96824 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSBatchAction.php | 4 +++- css/cms_left.css | 3 +++ images/tickbox-fail.gif | Bin 0 -> 64 bytes javascript/CMSMain_left.js | 31 +++++++++++++++++++++++++++++-- javascript/LeftAndMain_left.js | 6 ++++++ 5 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 images/tickbox-fail.gif 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 0000000000000000000000000000000000000000..88666fe29b0439358c284ae82097dec8493d72fa GIT binary patch literal 64 zcmZ?wbhEHbasuv25SHr3K6>i literal 0 HcmV?d00001 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) {