mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
elofgren: Fix indentation of code in AddForm::form_submit()
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42007 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ed0232eb71
commit
1daba65357
@ -254,7 +254,7 @@ AddForm.prototype = {
|
|||||||
$(_HANDLER_FORMS[this.id]).onsubmit = this.form_submit;
|
$(_HANDLER_FORMS[this.id]).onsubmit = this.form_submit;
|
||||||
},
|
},
|
||||||
|
|
||||||
form_submit : function() {
|
form_submit : function() {
|
||||||
var st = $('sitetree');
|
var st = $('sitetree');
|
||||||
if (st) {
|
if (st) {
|
||||||
if( st.selected && st.selected.length ) {
|
if( st.selected && st.selected.length ) {
|
||||||
@ -265,14 +265,14 @@ AddForm.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
var selectedNode = null;
|
var selectedNode = null;
|
||||||
}
|
}
|
||||||
var parentID = null;
|
var parentID = null;
|
||||||
|
|
||||||
while( selectedNode && !parentID ) {
|
while( selectedNode && !parentID ) {
|
||||||
if( selectedNode && selectedNode.id && selectedNode.id.match(/mailtype_([0-9a-z\-]+)$/) )
|
if( selectedNode && selectedNode.id && selectedNode.id.match(/mailtype_([0-9a-z\-]+)$/) )
|
||||||
parentID = RegExp.$1;
|
parentID = RegExp.$1;
|
||||||
else
|
else
|
||||||
selectedNode = selectedNode.parentNode;
|
selectedNode = selectedNode.parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parentID && parentID.substr(0,3) == 'new') {
|
if(parentID && parentID.substr(0,3) == 'new') {
|
||||||
alert("You have to save a page before adding children underneath it");
|
alert("You have to save a page before adding children underneath it");
|
||||||
@ -282,37 +282,37 @@ AddForm.prototype = {
|
|||||||
this.elements.ParentID.value = parentID;
|
this.elements.ParentID.value = parentID;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = 'draft';
|
var type = 'draft';
|
||||||
var selectIDPrefix = 'draft_' + parentID + '_';
|
var selectIDPrefix = 'draft_' + parentID + '_';
|
||||||
|
|
||||||
if( $('add_type').value == 'type' ) {
|
if( $('add_type').value == 'type' ) {
|
||||||
type = 'type';
|
type = 'type';
|
||||||
selectIDPrefix = 'mailtype_';
|
selectIDPrefix = 'mailtype_';
|
||||||
}
|
}
|
||||||
// Call either addtype or adddraft
|
// Call either addtype or adddraft
|
||||||
var request = new Ajax.Request( this.action + type + '?ajax=1' + '&ParentID=' + parentID, {
|
var request = new Ajax.Request( this.action + type + '?ajax=1' + '&ParentID=' + parentID, {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
asynchronous: true,
|
asynchronous: true,
|
||||||
onSuccess : function( response ) {
|
onSuccess : function( response ) {
|
||||||
|
|
||||||
$('Form_EditForm').loadNewPage(response.responseText);
|
$('Form_EditForm').loadNewPage(response.responseText);
|
||||||
|
|
||||||
// create a new node and add it to the site tree
|
// create a new node and add it to the site tree
|
||||||
if( type == 'draft' ) {
|
if( type == 'draft' ) {
|
||||||
$('sitetree').addDraftNode('New draft newsletter', parentID, $('Form_EditForm_ID').value );
|
$('sitetree').addDraftNode('New draft newsletter', parentID, $('Form_EditForm_ID').value );
|
||||||
} else {
|
} else {
|
||||||
$('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );
|
$('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );
|
||||||
}
|
}
|
||||||
// Save it so that change detection will work
|
// Save it so that change detection will work
|
||||||
$('Form_EditForm').save();
|
$('Form_EditForm').save();
|
||||||
|
|
||||||
statusMessage('Added new ' + type);
|
statusMessage('Added new ' + type);
|
||||||
},
|
},
|
||||||
|
|
||||||
onFailure : function(response) {
|
onFailure : function(response) {
|
||||||
alert(response.responseText);
|
alert(response.responseText);
|
||||||
statusMessage('Could not add new ' + type );
|
statusMessage('Could not add new ' + type );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user