mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +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) {
|
||||
return $this->showWithEditForm( $params, $this->getNewsletterEditForm( $params['ID'] ) );
|
||||
@ -458,6 +458,7 @@ class NewsletterAdmin extends LeftAndMain {
|
||||
}
|
||||
|
||||
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' )
|
||||
return $this->savenewsletter( $urlParams, $form );
|
||||
|
||||
@ -594,24 +595,27 @@ JS;
|
||||
$this->returnItemToUser($p);
|
||||
}
|
||||
|
||||
public function addtype( $params ) {
|
||||
switch( $_REQUEST['PageType'] ) {
|
||||
case 'type':
|
||||
$form = $this->getNewsletterTypeEditForm( $this->newNewsletterType() );
|
||||
break;
|
||||
default:
|
||||
$form = $this->getNewsletterEditForm( $this->newDraft( $_REQUEST['ParentID'] ) );
|
||||
}
|
||||
/**
|
||||
* Called by AJAX to create a new newsletter type
|
||||
*
|
||||
*/
|
||||
public function addtype( $params ) {
|
||||
$form = $this->getNewsletterTypeEditForm( $this->newNewsletterType() );
|
||||
|
||||
return $this->showWithEditForm( $_REQUEST, $form );
|
||||
}
|
||||
|
||||
public function adddraft( $data, $form ) {
|
||||
$this->save( $data, $form );
|
||||
$draftID = $this->newDraft( $_REQUEST['ID'] );
|
||||
return $this->getNewsletterEditForm( $draftID );
|
||||
}
|
||||
return $this->showWithEditForm( $_REQUEST, $form );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -285,8 +285,8 @@ AddForm.prototype = {
|
||||
type = 'type';
|
||||
selectIDPrefix = 'mailtype_';
|
||||
}
|
||||
|
||||
var request = new Ajax.Request( this.action + '?ajax=1&PageType=' + type + '&ParentID=' + parentID, {
|
||||
// Call either addtype or adddraft
|
||||
var request = new Ajax.Request( this.action + type + '?ajax=1' + '&ParentID=' + parentID, {
|
||||
method: 'get',
|
||||
asynchronous: true,
|
||||
onSuccess : function( response ) {
|
||||
@ -299,7 +299,9 @@ AddForm.prototype = {
|
||||
} else {
|
||||
$('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );
|
||||
}
|
||||
|
||||
// Save it so that change detection will work
|
||||
$('Form_EditForm').save();
|
||||
|
||||
statusMessage('Added new ' + type);
|
||||
},
|
||||
|
||||
|
@ -237,6 +237,7 @@ Behaviour.register({
|
||||
return false;
|
||||
},
|
||||
|
||||
// @TODO: See if this is used anymore
|
||||
send: function() {
|
||||
if( $('SendTypeList').checked )
|
||||
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.
|
||||
* Adapted from NewsletterAdmin_left.js
|
||||
*/
|
||||
function addNewDraft(parentID) {
|
||||
var type = 'draft';
|
||||
var request = new Ajax.Request( 'admin/newsletter/addtype?ajax=1&PageType=' + type + '&ParentID=' + parentID, {
|
||||
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 );
|
||||
}
|
||||
});
|
||||
$('add_type').value = 'draft';
|
||||
$('addtype_options').onsubmit();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ ul.tree li.MailType span.Sent a {
|
||||
<li class="action" id="deletedrafts"><button>Delete...</button></li>
|
||||
</ul>
|
||||
<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="" />
|
||||
<select name="PageType" id="add_type">
|
||||
<option value="type">Add new type</option>
|
||||
|
Loading…
x
Reference in New Issue
Block a user