Hook up newsletter editor saving
This commit is contained in:
@ -45,10 +45,10 @@ define([
|
||||
|
||||
Module.toJSON = function() {
|
||||
return _.extend({
|
||||
body: {
|
||||
body: JSON.stringify({
|
||||
content: App._contentContainer.toJSON(),
|
||||
globalStyles: App.getGlobalStyles().toJSON(),
|
||||
},
|
||||
}),
|
||||
}, App.getNewsletter().toJSON());
|
||||
};
|
||||
|
||||
@ -69,7 +69,8 @@ define([
|
||||
|
||||
App.on('start', function(options) {
|
||||
// TODO: Other newsletter information will be needed as well.
|
||||
App._contentContainer = new (this.getBlockTypeModel('container'))(options.newsletter.body.content, {parse: true});
|
||||
var body = JSON.parse(options.newsletter.body);
|
||||
App._contentContainer = new (this.getBlockTypeModel('container'))(body.content, {parse: true});
|
||||
App._contentContainerView = new (this.getBlockTypeView('container'))({
|
||||
model: App._contentContainer,
|
||||
renderOptions: { depth: 0 },
|
||||
|
@ -1,9 +1,9 @@
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/wordpress',
|
||||
'mailpoet',
|
||||
'backbone',
|
||||
'backbone.marionette'
|
||||
], function(App, Wordpress, Backbone, Marionette) {
|
||||
], function(App, MailPoet, Backbone, Marionette) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@ -17,7 +17,11 @@ define([
|
||||
var json = App.toJSON();
|
||||
|
||||
// save newsletter
|
||||
Wordpress.saveNewsletter(json).done(function(response) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'save',
|
||||
data: json,
|
||||
}).done(function(response) {
|
||||
if(response.success !== undefined && response.success === true) {
|
||||
// TODO: Handle translations
|
||||
//MailPoet.Notice.success("<?php _e('Newsletter has been saved.'); ?>");
|
||||
@ -32,9 +36,9 @@ define([
|
||||
}
|
||||
}
|
||||
App.getChannel().trigger('afterEditorSave', json, response);
|
||||
}).fail(function() {
|
||||
}).fail(function(response) {
|
||||
// TODO: Handle saving errors
|
||||
App.getChannel().trigger('afterEditorSave', {}, error);
|
||||
App.getChannel().trigger('afterEditorSave', {}, response);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -72,7 +72,8 @@ define([
|
||||
|
||||
App.getAvailableStyles = Module.getAvailableStyles;
|
||||
|
||||
this.setGlobalStyles(options.newsletter.body.globalStyles);
|
||||
var body = JSON.parse(options.newsletter.body);
|
||||
this.setGlobalStyles(body.globalStyles);
|
||||
});
|
||||
|
||||
App.on('start', function(options) {
|
||||
|
Reference in New Issue
Block a user