armisa-models
Version:
models of armisa!
141 lines (140 loc) • 6.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Modaling = void 0;
const BasePageData_1 = require("../BasePageData");
const ModalData_1 = require("./ModalData");
const ModalPopup_1 = require("./ModalPopup");
const TabData_1 = require("../Tab/TabData");
class Modaling {
get activeModal() {
return this._modalsAndPopups.find((i) => i.isActive);
}
get modals() {
return this._modalsAndPopups;
}
constructor(mainStateManager) {
this.mainStateManager = mainStateManager;
this.modalsAndPopupOrder = [];
this._modalsAndPopups = [];
this.isShowModalWating = false;
this.helpModeState = false;
this.toggelHelpMode = () => {
this.helpModeState = !this.helpModeState;
this.helpElementRef = undefined;
// this.mainStateManager.Eventing.trigger('helpState');
};
this.setHelpElementRef = (element) => {
this.helpElementRef = element;
// this.mainStateManager.Eventing.trigger('helpState');
};
this.showWaitingModal = (parentPage) => {
this.isShowModalWating = true;
// this.mainStateManager.focusPosition = 'modals';
// this.mainStateManager.Eventing.trigger('showWaitingModal', parentPage);
};
this.closeWaitingModal = (parentPage) => {
if (this.isShowModalWating) {
this.isShowModalWating = false;
const currentPage = parentPage;
if (currentPage instanceof ModalData_1.ModalPageData) {
// this.mainStateManager.focusPosition = 'modals';
}
else if (currentPage instanceof TabData_1.TabPageData) {
// this.mainStateManager.focusPosition = 'tabs';
}
else {
// this.mainStateManager.focusPosition = 'filterMenu';
}
// this.mainStateManager.Eventing.trigger('closeWaitingModal', parentPage);
}
};
this.addModalPage = (...params) => {
const [param1, param2, param3, param4] = params;
if (param1 instanceof ModalData_1.ModalPageData) {
param1.widthPecent = param2;
param1.heightPecent = param3;
param1.UpdateWidthAndHeightSize();
this._modalsAndPopups.push(param1);
this.modalsAndPopupOrder.push(param1);
// this.mainStateManager.focusPosition = 'modals';
// this.mainStateManager.Eventing.trigger('addNewModalPage', param1.parent, param1);
}
else if (typeof param1 === 'string') {
const pageData = new TabData_1.TabPageData(this.mainStateManager);
const modalPage = new ModalData_1.ModalPageData(this.mainStateManager, pageData);
modalPage.pageKey = param1;
if (param2 instanceof BasePageData_1.PropsOfPage) {
modalPage.props = param2;
modalPage.widthPecent = param3;
modalPage.heightPecent = param4;
}
else {
modalPage.widthPecent = param2;
modalPage.heightPecent = param3;
modalPage.props = param4;
}
modalPage.UpdateWidthAndHeightSize();
this.addModalPage(modalPage);
}
};
this.closeThisModal = (modalPageData) => {
modalPageData.Eventing.removeOn('form.disabled');
modalPageData.Eventing.removeOn('form.getActive');
// this.mainStateManager.Eventing.removeAllForThisPage(modalPageData.id);
this._modalsAndPopups = this._modalsAndPopups.filter((t) => t !== modalPageData);
this.modalsAndPopupOrder = this.modalsAndPopupOrder.filter((t) => t !== modalPageData);
const currentPage = modalPageData.parent;
if (currentPage instanceof ModalData_1.ModalPageData) {
currentPage.modal = undefined;
// this.mainStateManager.focusPosition = 'modals';
}
else if (currentPage instanceof TabData_1.TabPageData) {
currentPage.modal = undefined;
// this.mainStateManager.focusPosition = 'tabs';
}
else {
// this.mainStateManager.focusPosition = 'filterMenu';
}
// this.mainStateManager.Eventing.trigger('closeModal', currentPage);
};
this.closeThisPopup = (popupPageData) => {
popupPageData.Eventing.removeOn('form.disabled');
popupPageData.Eventing.removeOn('form.getActive');
// this.mainStateManager.Eventing.removeAllForThisPage(popupPageData.id);
this._modalsAndPopups = this._modalsAndPopups.filter((t) => t !== popupPageData);
this.modalsAndPopupOrder = this.modalsAndPopupOrder.filter((t) => t !== popupPageData);
const currentPage = popupPageData.parent;
if (currentPage instanceof ModalPopup_1.PopupPageData) {
currentPage.popup = undefined;
// this.mainStateManager.focusPosition = 'popup';
}
else if (currentPage instanceof TabData_1.TabPageData) {
currentPage.popup = undefined;
// this.mainStateManager.focusPosition = 'tabs';
}
else {
// this.mainStateManager.focusPosition = 'filterMenu';
}
// this.mainStateManager.Eventing.trigger('closePopup', currentPage);
};
}
addModal(modalPageData) {
this._modalsAndPopups.push(modalPageData);
this.modalsAndPopupOrder.push(modalPageData);
// this.mainStateManager.focusPosition = 'modals';
// this.mainStateManager.Eventing.trigger('addNewModal', modalPageData.parent, modalPageData);
}
addPopup(popupPageData) {
this._modalsAndPopups.push(popupPageData);
this.modalsAndPopupOrder.push(popupPageData);
// this.mainStateManager.focusPosition = 'popup';
// this.mainStateManager.Eventing.trigger('addNewPopup', popupPageData.parent, popupPageData);
}
addPopupPage(popupPageData) {
this._modalsAndPopups.push(popupPageData);
this.modalsAndPopupOrder.push(popupPageData);
// this.mainStateManager.focusPosition = 'popup';
// this.mainStateManager.Eventing.trigger('addNewPopupPage', popupPageData.parent, popupPageData);
}
}
exports.Modaling = Modaling;