mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
elofgren: BUGFIX: Fix gsoc trac ticket: #54 For newly created Newsletter drafts, Content of Newsletter Sent is not what is shown on screen (Save button has to be clicked)
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@41999 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8e583e2a4d
commit
2c012f3c4e
@ -98,7 +98,7 @@ class NewsletterAdmin extends LeftAndMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a draft or sent newsletter is clicked on the left menu
|
* Called when a draft or sent newsletter is clicked on the left menu and when a new one is added
|
||||||
*/
|
*/
|
||||||
public function shownewsletter($params) {
|
public function shownewsletter($params) {
|
||||||
return $this->showWithEditForm( $params, $this->getNewsletterEditForm( $params['ID'] ) );
|
return $this->showWithEditForm( $params, $this->getNewsletterEditForm( $params['ID'] ) );
|
||||||
@ -458,6 +458,7 @@ class NewsletterAdmin extends LeftAndMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function save($urlParams, $form) {
|
public function save($urlParams, $form) {
|
||||||
|
// Both the Newsletter type and the Newsletter draft call save() when "Save" button is clicked
|
||||||
if( isset($_REQUEST['Type']) && $_REQUEST['Type'] == 'Newsletter' )
|
if( isset($_REQUEST['Type']) && $_REQUEST['Type'] == 'Newsletter' )
|
||||||
return $this->savenewsletter( $urlParams, $form );
|
return $this->savenewsletter( $urlParams, $form );
|
||||||
|
|
||||||
@ -594,24 +595,27 @@ JS;
|
|||||||
$this->returnItemToUser($p);
|
$this->returnItemToUser($p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addtype( $params ) {
|
/**
|
||||||
switch( $_REQUEST['PageType'] ) {
|
* Called by AJAX to create a new newsletter type
|
||||||
case 'type':
|
*
|
||||||
$form = $this->getNewsletterTypeEditForm( $this->newNewsletterType() );
|
*/
|
||||||
break;
|
public function addtype( $params ) {
|
||||||
default:
|
$form = $this->getNewsletterTypeEditForm( $this->newNewsletterType() );
|
||||||
$form = $this->getNewsletterEditForm( $this->newDraft( $_REQUEST['ParentID'] ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->showWithEditForm( $_REQUEST, $form );
|
return $this->showWithEditForm( $_REQUEST, $form );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adddraft( $data, $form ) {
|
|
||||||
$this->save( $data, $form );
|
|
||||||
$draftID = $this->newDraft( $_REQUEST['ID'] );
|
|
||||||
return $this->getNewsletterEditForm( $draftID );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by AJAX to create a new newsletter draft
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function adddraft( $data) {
|
||||||
|
$draftID = $this->newDraft( $_REQUEST['ParentID'] );
|
||||||
|
// Needed for shownewsletter() to work
|
||||||
|
$_REQUEST['ID'] = $draftID;
|
||||||
|
return $this->shownewsletter($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new newsletter type
|
* Create a new newsletter type
|
||||||
*/
|
*/
|
||||||
|
@ -285,8 +285,8 @@ AddForm.prototype = {
|
|||||||
type = 'type';
|
type = 'type';
|
||||||
selectIDPrefix = 'mailtype_';
|
selectIDPrefix = 'mailtype_';
|
||||||
}
|
}
|
||||||
|
// Call either addtype or adddraft
|
||||||
var request = new Ajax.Request( this.action + '?ajax=1&PageType=' + type + '&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 ) {
|
||||||
@ -299,7 +299,9 @@ AddForm.prototype = {
|
|||||||
} 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
|
||||||
|
$('Form_EditForm').save();
|
||||||
|
|
||||||
statusMessage('Added new ' + type);
|
statusMessage('Added new ' + type);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -237,6 +237,7 @@ Behaviour.register({
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// @TODO: See if this is used anymore
|
||||||
send: function() {
|
send: function() {
|
||||||
if( $('SendTypeList').checked )
|
if( $('SendTypeList').checked )
|
||||||
return this.send_to_list();
|
return this.send_to_list();
|
||||||
@ -510,24 +511,8 @@ RecipientImportField.prototype = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 'add one' link action. Adds a new draft to the site tree and loads it up to edit.
|
* Handle 'add one' link action. Adds a new draft to the site tree and loads it up to edit.
|
||||||
* Adapted from NewsletterAdmin_left.js
|
|
||||||
*/
|
*/
|
||||||
function addNewDraft(parentID) {
|
function addNewDraft(parentID) {
|
||||||
var type = 'draft';
|
$('add_type').value = 'draft';
|
||||||
var request = new Ajax.Request( 'admin/newsletter/addtype?ajax=1&PageType=' + type + '&ParentID=' + parentID, {
|
$('addtype_options').onsubmit();
|
||||||
method: 'get',
|
|
||||||
asynchronous: true,
|
|
||||||
onSuccess : function( response ) {
|
|
||||||
$('Form_EditForm').loadNewPage(response.responseText);
|
|
||||||
|
|
||||||
// create a new node and add it to the site tree
|
|
||||||
$('sitetree').addDraftNode('New draft newsletter', parentID, $('Form_EditForm_ID').value );
|
|
||||||
|
|
||||||
statusMessage('Added new ' + type);
|
|
||||||
},
|
|
||||||
onFailure : function(response) {
|
|
||||||
alert(response.responseText);
|
|
||||||
statusMessage('Could not add new ' + type );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ ul.tree li.MailType span.Sent a {
|
|||||||
<li class="action" id="deletedrafts"><button>Delete...</button></li>
|
<li class="action" id="deletedrafts"><button>Delete...</button></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
<form class="actionparams" id="addtype_options" style="display: none" action="admin/newsletter/addtype">
|
<form class="actionparams" id="addtype_options" style="display: none" action="admin/newsletter/add">
|
||||||
<input type="hidden" name="ParentID" value="" />
|
<input type="hidden" name="ParentID" value="" />
|
||||||
<select name="PageType" id="add_type">
|
<select name="PageType" id="add_type">
|
||||||
<option value="type">Add new type</option>
|
<option value="type">Add new type</option>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user