MINOR Adapted CMS batch actions form to work outside of tabset context

This commit is contained in:
Ingo Schommer 2011-04-22 23:34:01 +12:00
parent b08fc52da4
commit 2c6e0c277b
5 changed files with 50 additions and 44 deletions

View File

@ -935,22 +935,13 @@ class LeftAndMain extends Controller {
*/ */
function BatchActionsForm() { function BatchActionsForm() {
$actions = $this->batchactions()->batchActionList(); $actions = $this->batchactions()->batchActionList();
$actionsMap = array(); $actionsMap = array('-1' => _t('LeftAndMain.DropdownBatchActionsDefault', 'Actions'));
foreach($actions as $action) $actionsMap[$action->Link] = $action->Title; foreach($actions as $action) $actionsMap[$action->Link] = $action->Title;
$form = new Form( $form = new Form(
$this, $this,
'BatchActionsForm', 'BatchActionsForm',
new FieldSet( new FieldSet(
new LiteralField(
'Intro',
sprintf('<p><small>%s</small></p>',
_t(
'CMSMain_left.ss.SELECTPAGESACTIONS',
'Select the pages that you want to change &amp; then click an action:'
)
)
),
new HiddenField('csvIDs'), new HiddenField('csvIDs'),
new DropdownField( new DropdownField(
'Action', 'Action',

View File

@ -44,16 +44,12 @@
self.serializeFromTree(); self.serializeFromTree();
}); });
// if tab which contains this form is shown, make the tree selectable $('.cms-tree-tools :input[name=view-mode]').bind('click', function(e) {
$('#TreeActions').bind('tabsselect', function(e, ui) { if($(e.target).val() == 'multiselect') {
// if we are selecting another tab, or the panel is visible (meaning about to be closed),
// disable tree selection and reset any values. Otherwise enable it.
if($(ui.panel).attr('id') != 'TreeActions-batchactions' || $(ui.panel).is(':visible')) {
// @TODO: this is unneccessarily fired also when switching between two other tabs
tree.removeClass('multiple');
} else {
tree.addClass('multiple'); tree.addClass('multiple');
self.serializeFromTree(); self.serializeFromTree();
} else {
tree.removeClass('multiple');
} }
}); });
@ -295,6 +291,11 @@
*/ */
$('#Form_BatchActionsForm select[name=Action]').entwine({ $('#Form_BatchActionsForm select[name=Action]').entwine({
onmatch: function() {
this.trigger('change');
this._super();
},
/** /**
* Function: onchange * Function: onchange
* *
@ -302,7 +303,13 @@
* (Event) e * (Event) e
*/ */
onchange: function(e) { onchange: function(e) {
$(e.target.form).entwine('ss').refreshSelected(); var form = $(e.target.form), btn = form.find(':submit');
if($(e.target).val() == -1) {
btn.attr('disabled', 'disabled');
} else {
btn.removeAttr('disabled');
form.entwine('ss').refreshSelected();
}
} }
}); });

View File

@ -109,8 +109,8 @@
}) })
.bind('before.jstree', function(e, data) { .bind('before.jstree', function(e, data) {
if(data.func == 'start_drag') { if(data.func == 'start_drag') {
// Only allow drag'n'drop if it has been specifically enabled, or the tree is in search mode // Don't allow drag'n'drop if multi-select is enabled'
if(!$('input[id=sortitems]').is(':checked') || self.data('searchparams')) { if(!self.hasClass('draggable') || self.hasClass('multiselect')) {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
return false; return false;
} }
@ -298,4 +298,15 @@
} }
}); });
$('.cms-tree-tools :input[name=view-mode]').entwine({
onmatch: function() {
// set active by default
this.trigger('click');
this._super();
},
onclick: function(e) {
$('.cms-tree').toggleClass('draggable', $(e.target).val() == 'draggable');
}
});
}(jQuery)); }(jQuery));

View File

@ -124,27 +124,6 @@
} }
}); });
/**
* Class: #TreeActions
*
* Container for tree actions like "create", "search", etc.
*/
$('#TreeActions').entwine({
/**
* Constructor: onmatch
*
* Setup "create", "search", "batch actions" layers above tree.
* All tab contents are closed by default.
*/
onmatch: function() {
this.tabs({
collapsible: true,
selected: parseInt(jQuery.cookie('ui-tabs-TreeActions'), 10) || null,
cookie: { expires: 30, path: '/', name: 'ui-tabs-TreeActions' }
});
}
});
/** /**
* Class: a#EditMemberProfile * Class: a#EditMemberProfile
* *

View File

@ -31,7 +31,12 @@
width: auto; width: auto;
} }
} }
}
.field.nolabel {
.middleColumn {
margin-left: 0;
}
} }
input, textarea { input, textarea {
@ -76,4 +81,17 @@
text-align: right; text-align: right;
} }
} }
.cms-content-tools {
.field {
label {
float: none;
width: auto;
}
.middleColumn {
margin-left: 0;
}
}
}
} }