mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
elofgren: BUGFIX: If there are no Newsletter types, and 'Add new draft' is chosen, create a Newsletter type to prevent errors. This makes either drop-down option work.
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42060 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e63c16fcff
commit
a1fcfa6271
@ -689,9 +689,19 @@ JS;
|
||||
private function newDraft( $parentID ) {
|
||||
if(!$parentID || !is_numeric( $parentID)) {
|
||||
$parent = DataObject::get_one("NewsletterType");
|
||||
$parentID = $parent->ID;
|
||||
if ($parent) {
|
||||
$parentID = $parent->ID;
|
||||
} else {
|
||||
// BUGFIX: It could be that no Newsletter types have been created, if so add one to prevent errors.
|
||||
$parentID = $this->newNewsletterType();
|
||||
}
|
||||
}
|
||||
if( $parentID && is_numeric( $parentID ) ) {
|
||||
$parent = DataObject::get_by_id("NewsletterType", $parentID);
|
||||
// BUGFIX: It could be that no Newsletter types have been created, if so add one to prevent errors.
|
||||
if(!$parent) {
|
||||
$parentID = $this->newNewsletterType();
|
||||
}
|
||||
$newsletter = new Newsletter();
|
||||
$newsletter->Status = 'Draft';
|
||||
$newsletter->Title = $newsletter->Subject = 'New draft newsletter';
|
||||
|
@ -46,6 +46,14 @@ SiteTree.prototype = {
|
||||
},
|
||||
|
||||
addDraftNode: function( title, parentID, draftID ) {
|
||||
var st = $('sitetree');
|
||||
// BUGFIX: If there is nothing in the left tree we need to add a Newsletter type first to prevent errors
|
||||
if(typeof st.lastTreeNode() == 'undefined') {
|
||||
$('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );
|
||||
}
|
||||
// BUGFIX: If no selection is made in the left tree, and a draft is added, parentID won't be set,
|
||||
// so we need to use the value from the Draft edit form.
|
||||
parentID = $('Form_EditForm_ParentID').value;
|
||||
var draftNode = this.createTreeNode( 'draft_' + parentID + '_' + draftID, title, 'Draft', parentID );
|
||||
this.getTreeNodeByIdx('drafts_' + parentID).appendTreeNode( draftNode );
|
||||
this.changeCurrentTo( draftNode );
|
||||
@ -300,9 +308,6 @@ AddForm.prototype = {
|
||||
|
||||
// create a new node and add it to the site tree
|
||||
if( type == 'draft' ) {
|
||||
// BUGFIX: If no selection is made in the left tree, and a draft is added, parentID won't be set,
|
||||
// so we need to use the value from the Draft edit form.
|
||||
parentID = $('Form_EditForm_ParentID').value;
|
||||
$('sitetree').addDraftNode('New draft newsletter', parentID, $('Form_EditForm_ID').value );
|
||||
} else {
|
||||
$('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );
|
||||
|
Loading…
Reference in New Issue
Block a user