/* * This file belongs to Hoist, an application development toolkit * developed by Extremely Heavy Industries (www.xh.io | info@xh.io) * * Copyright © 2026 Extremely Heavy Industries Inc. */ import type {DashViewModel} from '@xh/hoist/desktop/cmp/dash/DashViewModel'; import {bindable, makeObservable, observable} from '@xh/hoist/mobx'; import {HoistModel, managed, RefreshContextModel} from '@xh/hoist/core'; /** * Base Model for {@link DashCanvasModel} and {@link DashContainerModel}. */ export abstract class DashModel extends HoistModel { //--------------------------- // Core State //--------------------------- viewSpecs: VSPEC[] = []; @observable.ref state: VSTATE[]; @managed @observable.ref viewModels: VMODEL[] = []; @managed readonly refreshContextModel: RefreshContextModel; //----------------------------- // Settable State //------------------------------ @bindable layoutLocked: boolean; @bindable contentLocked: boolean; @bindable renameLocked: boolean; //------------------------------ // Immutable public properties //------------------------------ emptyText: string; addViewButtonText: string; extraMenuItems: any[]; abstract get isEmpty(): boolean; //------------------------ // Implementation properties //------------------------ protected restoreState: any; constructor() { super(); makeObservable(this); this.refreshContextModel = new RefreshContextModel(); } /** Deterministically generate a unique view id for a view based on the provided viewSpecId */ protected genViewId( viewSpecId: string, existingIds: Set = new Set(this.viewModels.map(vm => vm.id)) ): string { let idx = 0, ret = `${viewSpecId}_0`; while (existingIds.has(ret)) { idx++; ret = `${viewSpecId}_${idx}`; } return ret; } }