armisa-models
Version:
models of armisa!
118 lines (117 loc) • 5.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tabing = void 0;
const TabData_1 = require("./TabData");
const BasePageData_1 = require("../BasePageData");
const NamingCaption_1 = require("../../NamingCaption");
class Tabing {
get tabs() {
return this._tabs;
}
get activeTab() {
return this._tabs.find((i) => i.isActive);
}
get hoveredTab() {
return this._hoveredTab;
}
set hoveredTab(value) {
this._hoveredTab = value;
}
constructor(mainStateManager) {
this.mainStateManager = mainStateManager;
this.tabsOrder = [];
this._tabs = [];
this._hoveredTab = undefined;
this.helpModeState = false;
this.toggelHelpMode = () => {
this.helpModeState = !this.helpModeState;
this.helpElementRef = undefined;
this.fixZindex();
// this.mainStateManager.Eventing.trigger('helpState');
};
this.setHelpElementRef = (element) => {
this.helpElementRef = element;
// this.mainStateManager.Eventing.trigger('helpState');
};
this.addTab = (...params) => {
const [param1, param2, param3, param4] = params;
const newTab = new TabData_1.TabPageData(this.mainStateManager);
if (param1 instanceof NamingCaption_1.CaptionNaming && typeof param2 === 'string' && param3 === undefined) {
newTab.caption = this.mainStateManager.getCaptionNaming(param1);
newTab.pageKey = param2;
}
else if ((param1 instanceof Array &&
typeof param2 === 'string' &&
param3 instanceof BasePageData_1.PropsOfPage) ||
(typeof param1 === 'string' &&
typeof param2 === 'string' &&
param3 instanceof BasePageData_1.PropsOfPage &&
param4 === undefined)) {
newTab.caption = this.mainStateManager.getCaptionNaming(param1);
newTab.pageKey = param2;
newTab.props = param3;
}
else if ((typeof param1 === 'string' &&
typeof param2 === 'string' &&
param3 instanceof BasePageData_1.PropsOfPage) ||
(typeof param1 === 'string' &&
typeof param2 === 'string' &&
param3 instanceof BasePageData_1.PropsOfPage &&
typeof param4 === 'boolean')) {
newTab.caption = param1;
newTab.pageKey = param2;
newTab.props = param3;
newTab.isMainOfStacks = param4;
}
else if (typeof param1 === 'string' && typeof param2 === 'string') {
newTab.caption = param1;
newTab.pageKey = param2;
newTab.isMainOfStacks = param3;
}
else if (typeof param1 === 'string' && typeof param2 === 'undefined') {
newTab.pageKey = param1;
// newTab.caption = this.mainStateManager.MenuIteming.getCaptionOfPage(
// param1 as IArmisaPageKey
// );
}
this._tabs.push(newTab);
this.tabsOrder.push(newTab);
// this.mainStateManager.focusPosition = 'tabs';
// this.mainStateManager.Eventing.trigger('addNewTab', newTab);
};
this.closeThisTab = (tab) => {
tab.Eventing.removeOn('form.disabled');
tab.Eventing.removeOn('form.getActive');
tab.TabbingControl.removeAllControls();
tab.ValidatingControl.removeAllControls();
tab.ChangingControl.removeAllControls();
// this.mainStateManager.Eventing.removeAllForThisPage(tab.id);
this._tabs = this._tabs.filter((t) => t !== tab);
this.tabsOrder = this.tabsOrder.filter((t) => t !== tab);
const activeTab = this.tabsOrder[this.tabsOrder.length - 1];
if (activeTab) {
activeTab.isActive = true;
}
if (this._tabs.length === 0) {
// this.mainStateManager.focusPosition = 'filterMenu';
}
// this.mainStateManager.Eventing.trigger('closeTab', activeTab);
};
this.selectThisTab = (tab) => {
const newTabOrder = this.tabsOrder.filter((t) => t !== tab);
newTabOrder.push(tab);
this.tabsOrder = newTabOrder;
// this.mainStateManager.focusPosition = 'tabs';
// this.mainStateManager.Eventing.trigger('selectTab', tab);
};
this.fixZindex = () => {
if (this.helpModeState) {
document.querySelector('.layout-sidebar-start').classList.add('z-index');
}
else {
document.querySelector('.layout-sidebar-start').classList.remove('z-index');
}
};
}
}
exports.Tabing = Tabing;