Browse Source

Clear wrapper on frame remove

pull/3411/head
Artur Arseniev 6 years ago
parent
commit
5daf63bfc9
  1. 4
      src/canvas/model/Frame.js
  2. 11
      src/canvas/model/Frames.js
  3. 5
      src/dom_components/model/Component.js
  4. 4
      src/pages/model/Page.js
  5. 11
      src/pages/model/Pages.js

4
src/canvas/model/Frame.js

@ -48,6 +48,10 @@ export default Model.extend({
!props.height && this.set(keyAutoH, 1); !props.height && this.set(keyAutoH, 1);
}, },
onRemove() {
this.getComponent().remove({ root: 1 });
},
changesUp: debounce(function(opt = {}) { changesUp: debounce(function(opt = {}) {
if (opt.temporary || opt.noCount || opt.avoidStore) { if (opt.temporary || opt.noCount || opt.avoidStore) {
return; return;

11
src/canvas/model/Frames.js

@ -8,6 +8,17 @@ export default Collection.extend({
initialize(models, config = {}) { initialize(models, config = {}) {
bindAll(this, 'itemLoaded'); bindAll(this, 'itemLoaded');
this.config = config; this.config = config;
this.on('reset', this.onReset);
this.on('remove', this.onRemove);
},
onReset(m, opts = {}) {
const prev = opts.previousModels || [];
prev.map(p => this.onRemove(p));
},
onRemove(removed) {
removed && removed.onRemove();
}, },
itemLoaded() { itemLoaded() {

5
src/dom_components/model/Component.js

@ -1576,7 +1576,10 @@ const Component = Backbone.Model.extend(Styleable).extend(
remove(opts = {}) { remove(opts = {}) {
const { em } = this; const { em } = this;
const coll = this.collection; const coll = this.collection;
const remove = () => coll && coll.remove(this, opts); const remove = () => {
coll && coll.remove(this, opts);
opts.root && this.components('');
};
const rmOpts = { ...opts }; const rmOpts = { ...opts };
[this, em].map(i => [this, em].map(i =>
i.trigger('component:remove:before', this, remove, rmOpts) i.trigger('component:remove:before', this, remove, rmOpts)

4
src/pages/model/Page.js

@ -17,6 +17,10 @@ export default Model.extend({
um && um.add(frames); um && um.add(frames);
}, },
onRemove() {
this.get('frames').reset();
},
getFrames() { getFrames() {
return this.get('frames'); return this.get('frames');
}, },

11
src/pages/model/Pages.js

@ -6,6 +6,17 @@ export default Collection.extend({
initialize(models, config = {}) { initialize(models, config = {}) {
this.config = config; this.config = config;
this.on('reset', this.onReset);
this.on('remove', this.onRemove);
},
onReset(m, opts = {}) {
const prev = opts.previousModels || [];
prev.map(p => this.onRemove(p));
},
onRemove(removed) {
removed && removed.onRemove();
}, },
add(m, o = {}) { add(m, o = {}) {

Loading…
Cancel
Save