From ade509939f1924b0b272e3b55a1e7f2dbc68804d Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 10 Jan 2023 17:22:34 +0400 Subject: [PATCH] Move SectorView to TS --- .../view/{SectorView.js => SectorView.ts} | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) rename src/style_manager/view/{SectorView.js => SectorView.ts} (80%) diff --git a/src/style_manager/view/SectorView.js b/src/style_manager/view/SectorView.ts similarity index 80% rename from src/style_manager/view/SectorView.js rename to src/style_manager/view/SectorView.ts index 1c777bb65..8b0d6cef0 100644 --- a/src/style_manager/view/SectorView.js +++ b/src/style_manager/view/SectorView.ts @@ -1,9 +1,20 @@ import { View } from '../../common'; +import EditorModel from '../../editor/model/Editor'; import html from '../../utils/html'; +import Sector from '../model/Sector'; import PropertiesView from './PropertiesView'; -export default class SectorView extends View { - template({ pfx, label }) { +type Config = { + em: EditorModel; + stylePrefix?: string; +}; + +export default class SectorView extends View { + em: EditorModel; + config: Config; + pfx: string; + + template({ pfx, label }: { pfx?: string; label: string }) { const icons = this.em?.getConfig().icons; const iconCaret = icons?.caret || ''; const clsPfx = `${pfx}sector-`; @@ -22,7 +33,9 @@ export default class SectorView extends View { }; } - initialize(o) { + constructor(o: { config: Config }) { + // @ts-ignore + super(o); const config = o.config || {}; const { model } = this; const { em } = config; @@ -47,7 +60,7 @@ export default class SectorView extends View { getPropertiesEl() { const { $el, pfx } = this; - return $el.find(`.${pfx}properties`).get(0); + return $el.find(`.${pfx}properties`).get(0)!; } toggle() { @@ -60,6 +73,7 @@ export default class SectorView extends View { const objs = model.get('properties'); if (objs) { + // @ts-ignore const view = new PropertiesView({ collection: objs, config }); this.$el.append(view.render().el); }