editor: Store and load blockDefaults in newsletter data
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
define([
|
||||
'newsletter_editor/App',
|
||||
'backbone.supermodel'
|
||||
], function (App, SuperModel) { // eslint-disable-line func-names
|
||||
'backbone.supermodel',
|
||||
'underscore'
|
||||
], function (App, SuperModel, _) { // eslint-disable-line func-names
|
||||
var Module = {};
|
||||
|
||||
Module.ConfigModel = SuperModel.extend({
|
||||
@ -25,11 +26,17 @@ define([
|
||||
|
||||
App.on('before:start', function (BeforeStartApp, options) { // eslint-disable-line func-names
|
||||
var Application = BeforeStartApp;
|
||||
var config = _.clone(options.config);
|
||||
// Expose config methods globally
|
||||
Application.getConfig = Module.getConfig;
|
||||
Application.setConfig = Module.setConfig;
|
||||
|
||||
Application.setConfig(options.config);
|
||||
config.blockDefaults = _.extend(
|
||||
config.blockDefaults,
|
||||
options.newsletter.body.blockDefaults || {}
|
||||
);
|
||||
|
||||
Application.setConfig(config);
|
||||
});
|
||||
|
||||
return Module;
|
||||
|
@ -46,7 +46,8 @@ define([
|
||||
Module.getBody = function getBody() {
|
||||
return {
|
||||
content: App._contentContainer.toJSON(),
|
||||
globalStyles: App.getGlobalStyles().toJSON()
|
||||
globalStyles: App.getGlobalStyles().toJSON(),
|
||||
blockDefaults: _.omit(App.getConfig().toJSON().blockDefaults, 'text', 'image')
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -89,6 +89,9 @@ define([
|
||||
var newsletterFields = {
|
||||
subject: 'test newsletter subject'
|
||||
};
|
||||
var blockDefaults = {
|
||||
button: {}
|
||||
};
|
||||
EditorApplication._contentContainer = {
|
||||
toJSON: function () {
|
||||
return dataField;
|
||||
@ -108,11 +111,13 @@ define([
|
||||
}
|
||||
};
|
||||
};
|
||||
EditorApplication.getConfig().set('blockDefaults', blockDefaults);
|
||||
json = ContentComponent.toJSON();
|
||||
expect(json).to.deep.equal(_.extend({
|
||||
body: {
|
||||
content: dataField,
|
||||
globalStyles: stylesField
|
||||
globalStyles: stylesField,
|
||||
blockDefaults: blockDefaults
|
||||
}
|
||||
}, newsletterFields));
|
||||
});
|
||||
|
Reference in New Issue
Block a user