Browse Source

Move Sectors to TSs

ts-style-manager
Artur Arseniev 4 years ago
parent
commit
04deaf81cb
  1. 15
      src/style_manager/model/Sectors.ts

15
src/style_manager/model/Sectors.js → src/style_manager/model/Sectors.ts

@ -1,21 +1,28 @@
import { Collection } from '../../common'; import { Collection } from '../../common';
import EditorModel from '../../editor/model/Editor';
import Sector from './Sector'; import Sector from './Sector';
export default class Sectors extends Collection { export default class Sectors extends Collection<Sector> {
initialize(prop, opts = {}) { em!: EditorModel;
module!: any;
initialize(prop: any, opts: { em?: EditorModel; module?: any } = {}) {
const { module, em } = opts; const { module, em } = opts;
this.em = em; this.em = em!;
this.module = module; this.module = module;
this.listenTo(this, 'reset', this.onReset); this.listenTo(this, 'reset', this.onReset);
} }
// @ts-ignore
model(props, opts = {}) { model(props, opts = {}) {
// @ts-ignore
const { em } = opts.collection; const { em } = opts.collection;
return new Sector(props, { ...opts, em }); return new Sector(props, { ...opts, em });
} }
onReset(models, opts = {}) { onReset(models: any, opts: { previousModels?: Sector[] } = {}) {
const prev = opts.previousModels || []; const prev = opts.previousModels || [];
// @ts-ignore
prev.forEach(sect => sect.get('properties').reset()); prev.forEach(sect => sect.get('properties').reset());
} }
} }
Loading…
Cancel
Save