Fix container to track child changes for initial newsletter

This commit is contained in:
Tautvidas Sipavičius
2015-10-02 14:36:43 +03:00
parent 85f160b60b
commit c61849481a

View File

@@ -18,6 +18,21 @@ define([
base = BaseBlock, base = BaseBlock,
BlockCollection; BlockCollection;
BlockCollection = Backbone.Collection.extend({
model: base.BlockModel,
initialize: function() {
this.on('add change remove', function() { App.getChannel().trigger('autoSave'); });
},
parse: function(response) {
var self = this;
return _.map(response, function(block) {
var Type = App.getBlockTypeModel(block.type);
// TODO: If type has no registered model, use a backup one
return new Type(block, {parse: true});
});
},
});
Module.ContainerBlockModel = base.BlockModel.extend({ Module.ContainerBlockModel = base.BlockModel.extend({
relations: { relations: {
blocks: BlockCollection, blocks: BlockCollection,
@@ -52,21 +67,6 @@ define([
}, },
}); });
BlockCollection = Backbone.Collection.extend({
model: base.BlockModel,
initialize: function() {
this.on('add change remove', function() { App.getChannel().trigger('autoSave'); });
},
parse: function(response) {
var self = this;
return _.map(response, function(block) {
var Type = App.getBlockTypeModel(block.type);
// TODO: If type has no registered model, use a backup one
return new Type(block, {parse: true});
});
},
});
Module.ContainerBlockView = Marionette.CompositeView.extend({ Module.ContainerBlockView = Marionette.CompositeView.extend({
regionClass: Marionette.Region, regionClass: Marionette.Region,
className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block', className: 'mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block',