mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
c2d24f9022
ENHANCEMENT Using new 'X-STATUS' HTTP response header for CMS form responses, as it is more robust for submitting variable length strings than the original 'Status' header. The status is evaluated in LeftAndMain.EditForm.js API CHANGE Removed CMSMain->tellBrowserAboutPublicationChange(), LeftAndMain->returnItemToUser(), LeftAndMain->getActionUpdateJS(), LeftAndMain->addTreeNodeJS(), LeftAndMain->deleteTreeNodeJS(). Use javascript to respond to state changes API CHANGE Removed CMSForm and CMSRightForm javascript classes, superseded by LeftAndMain.EditForm.js ENHANCEMENT Removed custom change detection in LeftAndMain->save(), this should be handled by DataObject->write() ENHANCEMENT Removed switch in LeftAndMain->save() which doesnt process saving if the record hasn't been altered, to simplify the saving logic ENHANCEMENT Removed custom add/remove tree node logic in LeftAndMain->save() which was retrieving state from DataObjectLog. This was never actively used, and should be handled by custom clientside logic. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92674 467b73ca-7a2a-4603-9d3b-597d59a354a9
61 lines
1.6 KiB
JavaScript
Executable File
61 lines
1.6 KiB
JavaScript
Executable File
/**
|
|
* Handle auto-saving. Detects if changes have been made, and if so save everything on the page.
|
|
* If confirmation is true it will ask for confirmation.
|
|
*/
|
|
function autoSave(confirmation, callAfter) {
|
|
// Note: TinyMCE coupling
|
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
|
|
|
var __forms = []
|
|
if($('Form_EditForm')) __forms.push($('Form_EditForm'));
|
|
if($('Form_SubForm')) __forms.push($('Form_SubForm'));
|
|
if($('Form_MemberForm')) __forms.push($('Form_MemberForm'));
|
|
|
|
var __somethingHasChanged = false;
|
|
var __callAfter = callAfter;
|
|
|
|
__forms.each(function(form) {
|
|
if(form.isChanged && form.isChanged()) {
|
|
__somethingHasChanged = true;
|
|
}
|
|
});
|
|
|
|
if(__somethingHasChanged) {
|
|
// Note: discard and cancel options are no longer used since switching to confirm dialog.
|
|
// save is still used if confirmation = false
|
|
var options = {
|
|
save: function() {
|
|
statusMessage(ss.i18n._t('CMSMAIN.SAVING'), '', true);
|
|
var i;
|
|
for(i=0;i<__forms.length;i++) {
|
|
if(__forms[i].isChanged && __forms[i].isChanged()) {
|
|
if(i == 0) __forms[i].save(true, __callAfter);
|
|
else __forms[i].save(true);
|
|
}
|
|
}
|
|
},
|
|
discard: function() {
|
|
__forms.each(function(form) { form.resetElements(false); });
|
|
if(__callAfter) __callAfter();
|
|
},
|
|
cancel: function() {
|
|
}
|
|
}
|
|
|
|
if(confirmation ) {
|
|
if(confirm(ss.i18n._t('LeftAndMain.CONFIRMUNSAVED')))
|
|
{
|
|
// OK was pressed, call function for what was clicked on
|
|
if(__callAfter) __callAfter();
|
|
} else {
|
|
// Cancel was pressed, stay on the current page
|
|
return false;
|
|
}
|
|
} else {
|
|
options.save();
|
|
}
|
|
|
|
} else {
|
|
if(__callAfter) __callAfter();
|
|
}
|
|
} |