Browse Source

Render correctly wrapper component in renderBody

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
ea1dec8366
  1. 10
      src/canvas/view/CanvasView.js
  2. 2
      src/canvas/view/FrameView.js
  3. 6
      src/dom_components/view/ComponentsView.js

10
src/canvas/view/CanvasView.js

@ -476,13 +476,17 @@ export default Backbone.View.extend({
render() {
const { el, $el, ppfx, model, config } = this;
this.wrapper = model.get('wrapper');
const wrapper = model.get('wrapper');
$el.html(this.template());
const $frames = $el.find('[data-frames]');
this.framesArea = $frames.get(0);
this.wrapper = wrapper;
if (this.wrapper && typeof this.wrapper.render == 'function') {
model.get('frame').set('wrapper', this.wrapper);
if (wrapper && typeof wrapper.render == 'function') {
model.get('frame').set({
wrapper,
root: wrapper.getWrapper()
});
$frames.append(this.frame.render().el);
var frame = this.frame;
if (this.config.scripts.length === 0) {

2
src/canvas/view/FrameView.js

@ -235,7 +235,7 @@ export default Backbone.View.extend({
${conf.protectedCss || ''}
</style>`
);
append(body, new ComponentView({ model: root }).render().el);
append(body, new ComponentView({ model: root, config }).render().el);
append(body, new CssRulesView({ collection: styles, config }).render().el);
append(body, this.getJsContainer());
// em.trigger('loaded'); // I need to manage only the first one maybe

6
src/dom_components/view/ComponentsView.js

@ -5,6 +5,7 @@ export default Backbone.View.extend({
initialize(o) {
this.opts = o || {};
this.config = o.config || {};
this.em = this.config.em;
const coll = this.collection;
this.listenTo(coll, 'add', this.addTo);
this.listenTo(coll, 'reset', this.resetChildren);
@ -80,9 +81,10 @@ export default Backbone.View.extend({
* */
addToCollection(model, fragmentEl, index) {
if (!this.compView) this.compView = require('./ComponentView').default;
const { config, opts } = this;
const { config, opts, em } = this;
const fragment = fragmentEl || null;
const dt = opts.componentTypes;
const dt =
opts.componentTypes || (em && em.get('DomComponents').getTypes());
const type = model.get('type');
let viewObject = this.compView;

Loading…
Cancel
Save