mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
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:
parent
dc9914ff2d
commit
266acd409d
@ -32,6 +32,7 @@ class AssetAdmin extends LeftAndMain {
|
|||||||
'addfolder',
|
'addfolder',
|
||||||
'deletefolder',
|
'deletefolder',
|
||||||
'deletemarked',
|
'deletemarked',
|
||||||
|
'DeleteItemsForm',
|
||||||
'deleteUnusedThumbnails',
|
'deleteUnusedThumbnails',
|
||||||
'doUpload',
|
'doUpload',
|
||||||
'getfile',
|
'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
|
* Delete a folder
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +36,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'delete',
|
'delete',
|
||||||
'deletefromlive',
|
'deletefromlive',
|
||||||
'deleteitems',
|
'deleteitems',
|
||||||
|
'DeleteItemsForm',
|
||||||
'dialog',
|
'dialog',
|
||||||
'duplicate',
|
'duplicate',
|
||||||
'duplicatewithchildren',
|
'duplicatewithchildren',
|
||||||
@ -45,6 +46,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'getversion',
|
'getversion',
|
||||||
'publishall',
|
'publishall',
|
||||||
'publishitems',
|
'publishitems',
|
||||||
|
'PublishItemsForm',
|
||||||
'restorepage',
|
'restorepage',
|
||||||
'revert',
|
'revert',
|
||||||
'rollback',
|
'rollback',
|
||||||
@ -1092,6 +1094,25 @@ HTML;
|
|||||||
return FormResponse::respond();
|
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.
|
* Delete a number of items.
|
||||||
* This code supports notification
|
* This code supports notification
|
||||||
@ -1184,6 +1205,27 @@ HTML;
|
|||||||
return FormResponse::respond();
|
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 & 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() {
|
function buildbrokenlinks() {
|
||||||
if($this->urlParams['ID']) {
|
if($this->urlParams['ID']) {
|
||||||
$newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
|
$newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
width: 5%;
|
width: 5%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#deletepage_options p {
|
#Form_DeleteItemsForm p {
|
||||||
margin: 4px 0;
|
margin: 4px 0;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: #666;
|
color: #666;
|
||||||
@ -192,6 +192,10 @@ ul.tree span.a span.modified,
|
|||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#treepanes form .field {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.listpane p {
|
.listpane p {
|
||||||
margin: 3px 3px 7px 3px;
|
margin: 3px 3px 7px 3px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
@ -11,7 +11,7 @@ SiteTreeHandlers.controller_url = 'admin/assets';
|
|||||||
|
|
||||||
var _HANDLER_FORMS = {
|
var _HANDLER_FORMS = {
|
||||||
addpage : 'addpage_options',
|
addpage : 'addpage_options',
|
||||||
deletepage : 'deletepage_options',
|
deletepage : 'Form_DeleteItemsForm',
|
||||||
sortitems : 'sortitems_options'
|
sortitems : 'sortitems_options'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ deletefolder = {
|
|||||||
button_onclick : function() {
|
button_onclick : function() {
|
||||||
if(treeactions.toggleSelection(this)) {
|
if(treeactions.toggleSelection(this)) {
|
||||||
deletefolder.o1 = $('sitetree').observeMethod('SelectionChanged', deletefolder.treeSelectionChanged);
|
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');
|
addClass($('sitetree'),'multiselect');
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ deletefolder = {
|
|||||||
popupClosed : function() {
|
popupClosed : function() {
|
||||||
removeClass($('sitetree'),'multiselect');
|
removeClass($('sitetree'),'multiselect');
|
||||||
$('sitetree').stopObserving(deletefolder.o1);
|
$('sitetree').stopObserving(deletefolder.o1);
|
||||||
$('deletepage_options').stopObserving(deletefolder.o2);
|
$('Form_DeleteItemsForm').stopObserving(deletefolder.o2);
|
||||||
|
|
||||||
for(var idx in deletefolder.selectedNodes) {
|
for(var idx in deletefolder.selectedNodes) {
|
||||||
if(deletefolder.selectedNodes[idx]) {
|
if(deletefolder.selectedNodes[idx]) {
|
||||||
@ -391,11 +391,11 @@ deletefolder = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(csvIDs) {
|
if(csvIDs) {
|
||||||
$('deletepage_options').elements.csvIDs.value = csvIDs;
|
$('Form_DeleteItemsForm').elements.csvIDs.value = csvIDs;
|
||||||
|
|
||||||
statusMessage('deleting pages');
|
statusMessage('deleting pages');
|
||||||
|
|
||||||
Ajax.SubmitForm('deletepage_options', null, {
|
Ajax.SubmitForm('Form_DeleteItemsForm', null, {
|
||||||
onSuccess : deletefolder.submit_success,
|
onSuccess : deletefolder.submit_success,
|
||||||
onFailure : function(response) {
|
onFailure : function(response) {
|
||||||
errorMessage('Error deleting pages', response);
|
errorMessage('Error deleting pages', response);
|
||||||
@ -464,11 +464,12 @@ Behaviour.register({
|
|||||||
*/
|
*/
|
||||||
appendLoader(function () {
|
appendLoader(function () {
|
||||||
// Set up delete page
|
// Set up delete page
|
||||||
Observable.applyTo($('deletepage_options'));
|
Observable.applyTo($('Form_DeleteItemsForm'));
|
||||||
if($('deletepage')) {
|
if($('deletepage')) {
|
||||||
$('deletepage').onclick = deletefolder.button_onclick;
|
$('deletepage').onclick = deletefolder.button_onclick;
|
||||||
$('deletepage').getElementsByTagName('button')[0].onclick = function() { return false; };
|
$('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[]');
|
new CheckBoxRange($('Form_EditForm'), 'Files[]');
|
||||||
|
@ -290,7 +290,7 @@ batchActionGlobals = {
|
|||||||
* Publish selected pages action
|
* Publish selected pages action
|
||||||
*/
|
*/
|
||||||
publishpage = Class.create();
|
publishpage = Class.create();
|
||||||
publishpage.applyTo('#publishpage_options');
|
publishpage.applyTo('#Form_PublishItemsForm');
|
||||||
publishpage.prototype = {
|
publishpage.prototype = {
|
||||||
onsubmit : function() {
|
onsubmit : function() {
|
||||||
csvIDs = batchActionGlobals.getCsvIds();
|
csvIDs = batchActionGlobals.getCsvIds();
|
||||||
@ -300,11 +300,11 @@ publishpage.prototype = {
|
|||||||
statusMessage(ss.i18n._t('CMSMAIN.PUBLISHINGPAGES'));
|
statusMessage(ss.i18n._t('CMSMAIN.PUBLISHINGPAGES'));
|
||||||
|
|
||||||
// Put an AJAXY loading icon on the button
|
// Put an AJAXY loading icon on the button
|
||||||
$('action_publish_selected').className = 'loading';
|
$('Form_PublishItemsForm_action_publishitems').className = 'loading';
|
||||||
Ajax.SubmitForm(this, null, {
|
Ajax.SubmitForm(this, null, {
|
||||||
onSuccess : function(response) {
|
onSuccess : function(response) {
|
||||||
Ajax.Evaluator(response);
|
Ajax.Evaluator(response);
|
||||||
$('action_publish_selected').className = '';
|
$('Form_PublishItemsForm_action_publishitems').className = '';
|
||||||
treeactions.closeSelection($('batchactions'));
|
treeactions.closeSelection($('batchactions'));
|
||||||
},
|
},
|
||||||
onFailure : function(response) {
|
onFailure : function(response) {
|
||||||
@ -324,7 +324,7 @@ publishpage.prototype = {
|
|||||||
* Delete selected pages action
|
* Delete selected pages action
|
||||||
*/
|
*/
|
||||||
deletepage = Class.create();
|
deletepage = Class.create();
|
||||||
deletepage.applyTo('#deletepage_options');
|
deletepage.applyTo('#Form_DeleteItemsForm');
|
||||||
deletepage.prototype = {
|
deletepage.prototype = {
|
||||||
onsubmit : function() {
|
onsubmit : function() {
|
||||||
csvIDs = batchActionGlobals.getCsvIds();
|
csvIDs = batchActionGlobals.getCsvIds();
|
||||||
@ -352,11 +352,11 @@ deletepage.prototype = {
|
|||||||
|
|
||||||
batchActionGlobals.newNodes = new Array();
|
batchActionGlobals.newNodes = new Array();
|
||||||
// Put an AJAXY loading icon on the button
|
// Put an AJAXY loading icon on the button
|
||||||
$('action_delete_selected').className = 'loading';
|
$('Form_DeleteItemsForm_action_deleteitems').className = 'loading';
|
||||||
Ajax.SubmitForm(this, null, {
|
Ajax.SubmitForm(this, null, {
|
||||||
onSuccess : function(response) {
|
onSuccess : function(response) {
|
||||||
Ajax.Evaluator(response);
|
Ajax.Evaluator(response);
|
||||||
$('action_delete_selected').className = '';
|
$('Form_DeleteItemsForm_action_deleteitems').className = '';
|
||||||
treeactions.closeSelection($('batchactions'));
|
treeactions.closeSelection($('batchactions'));
|
||||||
},
|
},
|
||||||
onFailure : function(response) {
|
onFailure : function(response) {
|
||||||
|
@ -12,13 +12,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form class="actionparams" id="deletepage_options" style="display: none" action="admin/assets/deletefolder">
|
$DeleteItemsForm
|
||||||
<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>
|
|
||||||
|
|
||||||
<form class="actionparams" id="sortitems_options" style="display: none">
|
<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>
|
<p id="sortitems_message" style="margin: 0"><% _t('TOREORG','To reorganise your folders, drag them around as desired.') %></p>
|
||||||
|
@ -57,20 +57,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="batchactionsforms" style="display: none">
|
<div id="batchactionsforms" style="display: none">
|
||||||
<form class="actionparams" style="border:0" id="deletepage_options" action="admin/deleteitems">
|
$DeleteItemsForm
|
||||||
<p><% _t('SELECTPAGESACTIONS','Select the pages that you want to change & then click an action:') %></p>
|
$PublishItemsForm
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
<% control DuplicatePagesOptionsForm %>
|
<% control DuplicatePagesOptionsForm %>
|
||||||
<form class="actionparams" id="duplicate_options" style="display: none" action="admin/duplicateSiteTree">
|
<form class="actionparams" id="duplicate_options" style="display: none" action="admin/duplicateSiteTree">
|
||||||
|
Loading…
Reference in New Issue
Block a user