armisa-models
Version:
models of armisa!
59 lines (58 loc) • 2.25 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageTabingFactory = void 0;
const PageFactory_1 = require("./PageFactory");
class PageTabingFactory {
constructor(mainStateManager, forceUpdate, lazyLoadPage) {
this.mainStateManager = mainStateManager;
this.forceUpdate = forceUpdate;
this.lazyLoadPage = lazyLoadPage;
this.addNewTab = (pageKey, caption) => {
let captionFinal = '';
if (caption) {
if (typeof caption === 'string') {
captionFinal = caption;
}
else if (caption) {
captionFinal = this.mainStateManager.getCaptionNaming(caption);
}
}
const newTab = new PageFactory_1.PageFactory(this, pageKey, captionFinal, this.lazyLoadPage);
this.tabs.push(newTab);
this.tabsOrder.push(newTab);
this.activeTab = newTab;
this.forceUpdate();
};
this.selectThisTab = (tab) => {
const newTabOrder = this.tabsOrder.filter((t) => t !== tab);
newTabOrder.push(tab);
this.tabsOrder = newTabOrder;
// this.mainStateManager.focusPosition = 'tabs';
this.forceUpdate();
};
this.closeThisTab = (tab) => {
this.tabs = this.tabs.filter((t) => t !== tab);
this.tabsOrder = this.tabsOrder.filter((t) => t !== tab);
if (this.tabsOrder.length > 0) {
this.activeTab = this.tabsOrder[this.tabsOrder.length - 1];
}
else {
this.activeTab = undefined;
}
if (this.tabs.length === 0) {
// this.mainStateManager.focusPosition = 'filterMenu';
// this.mainStateManager.setFocus();
}
this.forceUpdate();
};
this.mensuringWidthSize = () => {
this.forceUpdate();
};
this.startHelpMode = () => {
this.forceUpdate();
};
this.tabs = [];
this.tabsOrder = [];
}
}
exports.PageTabingFactory = PageTabingFactory;