UNPKG

armisa-models

Version:
43 lines (37 loc) 1.43 kB
import { IArmisaPageKey } from "../ArmisaImportPage"; import { MainStateManager } from "../MainStateManager"; import { IMainStateFactory } from "../Types"; import { PageFactory } from "./PageFactory"; export class SubPageFactory { public mainStateManager: MainStateManager; ///@ts-ignore public mainStateFactory: IMainStateFactory; public id: string; public Component: React.LazyExoticComponent<React.ComponentType<any>>; public isDeleted: boolean; #hasChange: boolean; public get hasChange(): boolean { return this.#hasChange; } public get isActiveSubPage(): boolean { return this.pageFactory.activeSubPage === this; } constructor( public pageFactory: PageFactory, public pageKey: string, public caption: string, lazyLoadPage: (pageKey: IArmisaPageKey) => React.LazyExoticComponent<React.ComponentType<any>> ) { this.id = Math.random().toString() + '-' + new Date().getMilliseconds().toString(); this.mainStateManager = this.pageFactory.mainStateManager; this.Component = lazyLoadPage(this.pageKey as IArmisaPageKey); this.#hasChange = false; this.isDeleted = false; } public close = () => { this.pageFactory.closeThisSubPage(this); } public select = () => { this.pageFactory.selectThisSubPage(this); } }