mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
561 B
26 lines
561 B
import { Collection } from 'backbone';
|
|
import Page from './Page';
|
|
|
|
export default Collection.extend({
|
|
model: Page,
|
|
|
|
initialize(models, 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 = {}) {
|
|
const { config } = this;
|
|
return Collection.prototype.add.call(this, m, { ...o, config });
|
|
}
|
|
});
|
|
|