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
This commit is contained in:
Sam Minnee 2010-01-13 00:14:29 +00:00
parent 27907e4ced
commit 79968d0814
5 changed files with 41 additions and 3 deletions

View File

@ -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);

View File

@ -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 {

BIN
images/tickbox-fail.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 B

View File

@ -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);

View File

@ -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) {