Move newsletter content attributes into data
object
This commit is contained in:
@ -11,7 +11,7 @@ define([
|
|||||||
// Does not hold newsletter content nor newsletter styles, those are
|
// Does not hold newsletter content nor newsletter styles, those are
|
||||||
// handled by other components.
|
// handled by other components.
|
||||||
Module.NewsletterModel = SuperModel.extend({
|
Module.NewsletterModel = SuperModel.extend({
|
||||||
stale: ['content', 'globalStyles'],
|
stale: ['data'],
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.on('change', function() {
|
this.on('change', function() {
|
||||||
App.getChannel().trigger('autoSave');
|
App.getChannel().trigger('autoSave');
|
||||||
@ -45,8 +45,10 @@ define([
|
|||||||
|
|
||||||
Module.toJSON = function() {
|
Module.toJSON = function() {
|
||||||
return _.extend({
|
return _.extend({
|
||||||
content: App._contentContainer.toJSON(),
|
data: {
|
||||||
globalStyles: App.getGlobalStyles().toJSON(),
|
content: App._contentContainer.toJSON(),
|
||||||
|
globalStyles: App.getGlobalStyles().toJSON(),
|
||||||
|
},
|
||||||
}, App.getNewsletter().toJSON());
|
}, App.getNewsletter().toJSON());
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,12 +64,12 @@ define([
|
|||||||
App.toJSON = Module.toJSON;
|
App.toJSON = Module.toJSON;
|
||||||
App.getNewsletter = Module.getNewsletter;
|
App.getNewsletter = Module.getNewsletter;
|
||||||
|
|
||||||
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['content', 'globalStyles']));
|
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['data']));
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function(options) {
|
App.on('start', function(options) {
|
||||||
// TODO: Other newsletter information will be needed as well.
|
// TODO: Other newsletter information will be needed as well.
|
||||||
App._contentContainer = new (this.getBlockTypeModel('container'))(options.newsletter.content, {parse: true});
|
App._contentContainer = new (this.getBlockTypeModel('container'))(options.newsletter.data.content, {parse: true});
|
||||||
App._contentContainerView = new (this.getBlockTypeView('container'))({
|
App._contentContainerView = new (this.getBlockTypeView('container'))({
|
||||||
model: App._contentContainer,
|
model: App._contentContainer,
|
||||||
renderOptions: { depth: 0 },
|
renderOptions: { depth: 0 },
|
||||||
|
@ -72,7 +72,7 @@ define([
|
|||||||
|
|
||||||
App.getAvailableStyles = Module.getAvailableStyles;
|
App.getAvailableStyles = Module.getAvailableStyles;
|
||||||
|
|
||||||
this.setGlobalStyles(options.newsletter.globalStyles);
|
this.setGlobalStyles(options.newsletter.data.globalStyles);
|
||||||
});
|
});
|
||||||
|
|
||||||
App.on('start', function(options) {
|
App.on('start', function(options) {
|
||||||
|
@ -9,13 +9,15 @@ define([
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
model = new (ContentComponent.NewsletterModel)({
|
model = new (ContentComponent.NewsletterModel)({
|
||||||
globalStyles: {
|
data: {
|
||||||
style1: 'style1Value',
|
globalStyles: {
|
||||||
style2: 'style2Value',
|
style1: 'style1Value',
|
||||||
},
|
style2: 'style2Value',
|
||||||
content: {
|
},
|
||||||
data1: 'data1Value',
|
content: {
|
||||||
data2: 'data2Value',
|
data1: 'data1Value',
|
||||||
|
data2: 'data2Value',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
someField: 'someValue'
|
someField: 'someValue'
|
||||||
});
|
});
|
||||||
@ -30,7 +32,7 @@ define([
|
|||||||
mock.verify();
|
mock.verify();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not include styles and data attributes in its JSON', function() {
|
it('does not include styles and content attributes in its JSON', function() {
|
||||||
var json = model.toJSON();
|
var json = model.toJSON();
|
||||||
expect(json).to.deep.equal({someField: 'someValue'});
|
expect(json).to.deep.equal({someField: 'someValue'});
|
||||||
});
|
});
|
||||||
@ -79,8 +81,10 @@ define([
|
|||||||
};
|
};
|
||||||
var json = ContentComponent.toJSON();
|
var json = ContentComponent.toJSON();
|
||||||
expect(json).to.deep.equal(_.extend({
|
expect(json).to.deep.equal(_.extend({
|
||||||
content: dataField,
|
data: {
|
||||||
globalStyles: stylesField
|
content: dataField,
|
||||||
|
globalStyles: stylesField
|
||||||
|
},
|
||||||
}, newsletterFields));
|
}, newsletterFields));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user