ENHANCEMENT Moved batch forms in CMSMain and AssetAdmin from hardcoded templates to SilverStripe forms. Enhances styling capabilities, unifies HTML syntax, better support for unobtrusive scripting, validation and field additions.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@69744 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-01-06 02:18:33 +00:00
parent dc9914ff2d
commit 266acd409d
7 changed files with 88 additions and 35 deletions

View File

@ -32,6 +32,7 @@ class AssetAdmin extends LeftAndMain {
'addfolder',
'deletefolder',
'deletemarked',
'DeleteItemsForm',
'deleteUnusedThumbnails',
'doUpload',
'getfile',
@ -541,6 +542,28 @@ JS;
}
}
/**
* @return Form
*/
function DeleteItemsForm() {
$form = new Form(
$this,
'DeleteItemsForm',
new FieldSet(
new LiteralField('SelectedPagesNote',
sprintf('<p>%s</p>', _t('AssetAdmin_left.ss.SELECTTODEL','Select the folders that you want to delete and then click the button below'))
),
new HiddenField('csvIDs')
),
new FieldSet(
new FormAction('deletefolder', _t('AssetAdmin_left.ss.DELFOLDERS','Delete the selected folders'))
)
);
$form->addExtraClass('actionparams');
return $form;
}
/**
* Delete a folder
*/

View File

@ -36,6 +36,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'delete',
'deletefromlive',
'deleteitems',
'DeleteItemsForm',
'dialog',
'duplicate',
'duplicatewithchildren',
@ -45,6 +46,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'getversion',
'publishall',
'publishitems',
'PublishItemsForm',
'restorepage',
'revert',
'rollback',
@ -1091,6 +1093,25 @@ HTML;
return FormResponse::respond();
}
/**
* @return Form
*/
public function PublishItemsForm() {
$form = new Form(
$this,
'PublishItemsForm',
new FieldSet(
new HiddenField('csvIDs'),
new CheckboxField('ShowDrafts', _t('CMSMain_left.ss.SHOWONLYCHANGED','Show only changed pages'))
),
new FieldSet(
new FormAction('publishitems', _t('CMSMain_left.ss.PUBLISHCONFIRM','Publish the selected pages'))
)
);
$form->addExtraClass('actionparams');
return $form;
}
/**
* Delete a number of items.
@ -1183,6 +1204,27 @@ HTML;
return FormResponse::respond();
}
/**
* @return Form
*/
function DeleteItemsForm() {
$form = new Form(
$this,
'DeleteItemsForm',
new FieldSet(
new LiteralField('SelectedPagesNote',
sprintf('<p>%s</p>', _t('CMSMain_left.ss.SELECTPAGESACTIONS','Select the pages that you want to change &amp; then click an action:'))
),
new HiddenField('csvIDs')
),
new FieldSet(
new FormAction('deleteitems', _t('CMSMain_left.ss.DELETECONFIRM','Delete the selected pages'))
)
);
$form->addExtraClass('actionparams');
return $form;
}
function buildbrokenlinks() {
if($this->urlParams['ID']) {

View File

@ -21,7 +21,7 @@
width: 5%;
}
#deletepage_options p {
#Form_DeleteItemsForm p {
margin: 4px 0;
font-size: 11px;
color: #666;
@ -192,6 +192,10 @@ ul.tree span.a span.modified,
margin-right: 2px;
}
#treepanes form .field {
margin: 0;
}
.listpane p {
margin: 3px 3px 7px 3px;
font-size: 10px;

View File

@ -11,7 +11,7 @@ SiteTreeHandlers.controller_url = 'admin/assets';
var _HANDLER_FORMS = {
addpage : 'addpage_options',
deletepage : 'deletepage_options',
deletepage : 'Form_DeleteItemsForm',
sortitems : 'sortitems_options'
};
@ -330,7 +330,7 @@ deletefolder = {
button_onclick : function() {
if(treeactions.toggleSelection(this)) {
deletefolder.o1 = $('sitetree').observeMethod('SelectionChanged', deletefolder.treeSelectionChanged);
deletefolder.o2 = $('deletepage_options').observeMethod('Close', deletefolder.popupClosed);
deletefolder.o2 = $('Form_DeleteItemsForm').observeMethod('Close', deletefolder.popupClosed);
addClass($('sitetree'),'multiselect');
@ -367,7 +367,7 @@ deletefolder = {
popupClosed : function() {
removeClass($('sitetree'),'multiselect');
$('sitetree').stopObserving(deletefolder.o1);
$('deletepage_options').stopObserving(deletefolder.o2);
$('Form_DeleteItemsForm').stopObserving(deletefolder.o2);
for(var idx in deletefolder.selectedNodes) {
if(deletefolder.selectedNodes[idx]) {
@ -391,11 +391,11 @@ deletefolder = {
}
if(csvIDs) {
$('deletepage_options').elements.csvIDs.value = csvIDs;
$('Form_DeleteItemsForm').elements.csvIDs.value = csvIDs;
statusMessage('deleting pages');
Ajax.SubmitForm('deletepage_options', null, {
Ajax.SubmitForm('Form_DeleteItemsForm', null, {
onSuccess : deletefolder.submit_success,
onFailure : function(response) {
errorMessage('Error deleting pages', response);
@ -464,11 +464,12 @@ Behaviour.register({
*/
appendLoader(function () {
// Set up delete page
Observable.applyTo($('deletepage_options'));
Observable.applyTo($('Form_DeleteItemsForm'));
if($('deletepage')) {
$('deletepage').onclick = deletefolder.button_onclick;
$('deletepage').getElementsByTagName('button')[0].onclick = function() { return false; };
$('deletepage_options').onsubmit = deletefolder.form_submit;
$('Form_DeleteItemsForm').onsubmit = deletefolder.form_submit;
Element.hide('Form_DeleteItemsForm');
}
new CheckBoxRange($('Form_EditForm'), 'Files[]');

View File

@ -290,7 +290,7 @@ batchActionGlobals = {
* Publish selected pages action
*/
publishpage = Class.create();
publishpage.applyTo('#publishpage_options');
publishpage.applyTo('#Form_PublishItemsForm');
publishpage.prototype = {
onsubmit : function() {
csvIDs = batchActionGlobals.getCsvIds();
@ -300,11 +300,11 @@ publishpage.prototype = {
statusMessage(ss.i18n._t('CMSMAIN.PUBLISHINGPAGES'));
// Put an AJAXY loading icon on the button
$('action_publish_selected').className = 'loading';
$('Form_PublishItemsForm_action_publishitems').className = 'loading';
Ajax.SubmitForm(this, null, {
onSuccess : function(response) {
Ajax.Evaluator(response);
$('action_publish_selected').className = '';
$('Form_PublishItemsForm_action_publishitems').className = '';
treeactions.closeSelection($('batchactions'));
},
onFailure : function(response) {
@ -324,7 +324,7 @@ publishpage.prototype = {
* Delete selected pages action
*/
deletepage = Class.create();
deletepage.applyTo('#deletepage_options');
deletepage.applyTo('#Form_DeleteItemsForm');
deletepage.prototype = {
onsubmit : function() {
csvIDs = batchActionGlobals.getCsvIds();
@ -352,11 +352,11 @@ deletepage.prototype = {
batchActionGlobals.newNodes = new Array();
// Put an AJAXY loading icon on the button
$('action_delete_selected').className = 'loading';
$('Form_DeleteItemsForm_action_deleteitems').className = 'loading';
Ajax.SubmitForm(this, null, {
onSuccess : function(response) {
Ajax.Evaluator(response);
$('action_delete_selected').className = '';
$('Form_DeleteItemsForm_action_deleteitems').className = '';
treeactions.closeSelection($('batchactions'));
},
onFailure : function(response) {

View File

@ -12,13 +12,7 @@
</div>
</form>
<form class="actionparams" id="deletepage_options" style="display: none" action="admin/assets/deletefolder">
<p><% _t('SELECTTODEL','Select the folders that you want to delete and then click the button below') %></p>
<div>
<input type="hidden" name="csvIDs" />
<input type="submit" value="<% _t('DELFOLDERS','Delete the selected folders') %>" />
</div>
</form>
$DeleteItemsForm
<form class="actionparams" id="sortitems_options" style="display: none">
<p id="sortitems_message" style="margin: 0"><% _t('TOREORG','To reorganise your folders, drag them around as desired.') %></p>

View File

@ -57,20 +57,9 @@
</div>
</form>
<div id="batchactionsforms" style="display: none">
<form class="actionparams" style="border:0" id="deletepage_options" action="admin/deleteitems">
<p><% _t('SELECTPAGESACTIONS','Select the pages that you want to change &amp; then click an action:') %></p>
<div>
<input type="hidden" name="csvIDs" />
<input type="submit" id="action_delete_selected" class="action delete" value="<% _t('DELETECONFIRM','Delete the selected pages') %>" />
</div>
</form>
<form class="actionparams" style="border:0" id="publishpage_options" action="admin/publishitems">
<div>
<input type="hidden" name="csvIDs" />
<input type="checkbox" id="publishpage_show_drafts" /> <label for="publishpage_show_drafts"><% _t('SHOWONLYCHANGED','Show only changed pages') %></label>
<input type="submit" id="action_publish_selected" class="action" value="<% _t('PUBLISHCONFIRM','Publish the selected pages') %>" />
</div>
</form>
$DeleteItemsForm
$PublishItemsForm
</div>
<% control DuplicatePagesOptionsForm %>
<form class="actionparams" id="duplicate_options" style="display: none" action="admin/duplicateSiteTree">