armisa-models
Version:
models of armisa!
240 lines (239 loc) • 13.1 kB
JavaScript
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _MainStateManager_authFactory, _MainStateManager_baseUrl, _MainStateManager_projectKey, _MainStateManager_pathManager, _MainStateManager_userInfo, _MainStateManager_settingInfo, _MainStateManager_fiscalYearsInfo, _MainStateManager_subSystemsInfo, _MainStateManager_tokenInfo;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainStateManager = void 0;
const Clipboard_1 = require("./Clipboard");
const SettingInfo_1 = require("./AmisaAuth/Models/SettingInfo");
const ModalFactory_1 = require("./ComponentFactory/ModalFactory");
const AuthFactory_1 = require("./AmisaAuth/AuthFactory");
const PopupFactory_1 = require("./ComponentFactory/PopupFactory");
const LazyLoadFactory_1 = require("./LazyLoadFactory");
const PageLoadByKey_1 = require("./PageLoadByKey");
const SendByLetterFactory_1 = require("./ComponentFactory/SendByLetterFactory");
const UserInfo_1 = require("./AmisaAuth/Models/UserInfo/UserInfo");
const FiscalYearsInfo_1 = require("./AmisaAuth/Models/FiscalYearsInfo/FiscalYearsInfo");
const SubSystemsInfo_1 = require("./AmisaAuth/Models/SubSystemsInfo/SubSystemsInfo");
const TokenInfo_1 = require("./AmisaAuth/Models/StorageManager/TokenInfo");
class MainStateManager {
constructor() {
this.domDirection = 'rtl';
this.domIsDark = false;
_MainStateManager_authFactory.set(this, void 0);
_MainStateManager_baseUrl.set(this, void 0);
_MainStateManager_projectKey.set(this, void 0);
_MainStateManager_pathManager.set(this, void 0);
_MainStateManager_userInfo.set(this, void 0);
_MainStateManager_settingInfo.set(this, void 0);
_MainStateManager_fiscalYearsInfo.set(this, void 0);
_MainStateManager_subSystemsInfo.set(this, void 0);
_MainStateManager_tokenInfo.set(this, void 0);
/* @internal */
this.initializeServices = (baseUrl, projectKey, pathManager) => {
__classPrivateFieldSet(this, _MainStateManager_baseUrl, baseUrl, "f");
__classPrivateFieldSet(this, _MainStateManager_projectKey, projectKey, "f");
__classPrivateFieldSet(this, _MainStateManager_pathManager, pathManager, "f");
__classPrivateFieldSet(this, _MainStateManager_userInfo, new UserInfo_1.UserInfo(this), "f");
__classPrivateFieldSet(this, _MainStateManager_tokenInfo, new TokenInfo_1.TokenInfo(this), "f");
__classPrivateFieldSet(this, _MainStateManager_settingInfo, new SettingInfo_1.SettingInfo(this), "f");
__classPrivateFieldSet(this, _MainStateManager_fiscalYearsInfo, new FiscalYearsInfo_1.FiscalYearsInfo(this), "f");
__classPrivateFieldSet(this, _MainStateManager_subSystemsInfo, new SubSystemsInfo_1.SubSystemsInfo(this), "f");
__classPrivateFieldSet(this, _MainStateManager_authFactory, new AuthFactory_1.AuthFactory(this), "f");
};
this.lazyLoadFactory = new LazyLoadFactory_1.LazyLoadFactory(this);
this.pageLoadKeyFactory = new PageLoadByKey_1.PageLoadByKey(this);
this.Clipboarding = new Clipboard_1.Clipboarding(this);
this.forceUpdate = () => { };
this.forceUpdateToShowFullScreenWaittingSpinner = (_mainState, _onClosedModal) => { };
this.forceUpdateToShowSomeThingWentWrong = (_mainState, _onClosedModal) => { };
this.forceUpdateToShowError = (_mainState, _erro, _onClosedModal) => { };
this.forceUpdateToShowThereAreSomeErrorYouCanNot = (_mainState, _countOfError, _onClosedModal) => { };
this.forceUpdateToShowInvalidArgument = (_mainState, _description, _onClosedModal) => { };
this.forceUpdateToShowSuccessFull = (_mainState, _caption, _text, _description, _onClosedModal) => { };
this.forceUpdateToShowAreYouSureDelete = (_mainState, _onDeleteClick, _caption, _text, _description) => { };
this.forceUpdateToShowThereIsNotAnyChangeForSave = (_mainState, _onClosedModal) => { };
this.forceUpdateToShowAttachedFiles = (_mainState, _argument, _axiosData, _caption, _onClosedModal) => { };
this.showSendByLetterForm = (type, object) => {
if (!this.sendByLetterForm) {
this.sendByLetterForm = new SendByLetterFactory_1.SendByLetterFactory(this);
}
this.sendByLetterForm.addForm(type, object);
this.forceUpdate();
};
this.closeSendByLetterForm = () => {
this.sendByLetterForm?.dispose();
delete this.sendByLetterForm;
this.forceUpdate();
};
this.popups = [];
this.showPopup = (mainState, children, e, onClosedPopup) => {
const popupFactory = new PopupFactory_1.PopupFactory(mainState, children, e, onClosedPopup);
mainState.elementsOfForm.popup = popupFactory;
this.popups.push(popupFactory);
this.forceUpdate();
};
this.closePopup = (mainFactory) => {
this.popups = this.popups.filter(i => i !== mainFactory);
mainFactory.popupRoot.removeChild(mainFactory.mainDivElement);
mainFactory.popupRoot.removeChild(mainFactory.backdropDivElement);
this.forceUpdate();
};
this.modals = [];
this.showModal = (mainState, children, isWaitingModal, onClosedModal, argumentClass, cssClasses) => {
const modalFactory = new ModalFactory_1.ModalFactory(mainState, children, isWaitingModal, onClosedModal, argumentClass, cssClasses);
mainState.elementsOfForm.childModal = modalFactory;
this.modals.push(modalFactory);
this.forceUpdate();
};
this.showFullScreenWaittingSpinner = (mainState, onClosedModal) => {
this.forceUpdateToShowFullScreenWaittingSpinner(mainState, onClosedModal);
};
this.showErrorMessageBox = (mainState, error, onClosedModal) => {
this.forceUpdateToShowError(mainState, error, onClosedModal);
};
this.showThereAreSomeErrorYouCanNot = (mainState, countOfError, onClosedModal) => {
this.forceUpdateToShowThereAreSomeErrorYouCanNot(mainState, countOfError, onClosedModal);
};
this.showSomeThingWentWrong = (mainState, onClosedModal) => {
this.forceUpdateToShowSomeThingWentWrong(mainState, onClosedModal);
};
this.showInvalidArgumentMessageBox = (mainState, description, onClosedModal) => {
this.forceUpdateToShowInvalidArgument(mainState, description, onClosedModal);
};
this.showSuccessFullMessageBox = (mainState, caption, text, description, onClosedModal) => {
this.forceUpdateToShowSuccessFull(mainState, caption, text, description, onClosedModal);
};
this.showAreYouSureDeleteMessageBox = (mainState, onClickDelete, caption, text, description) => {
this.forceUpdateToShowAreYouSureDelete(mainState, onClickDelete, caption, text, description);
};
this.showThereIsNotAnyChangeForSave = (mainState, onClosedModal) => {
this.forceUpdateToShowThereIsNotAnyChangeForSave(mainState, onClosedModal);
};
this.showAttachedFiles = (mainState, argument, axiosData, caption, onClosedModal) => {
this.forceUpdateToShowAttachedFiles(mainState, argument, axiosData, caption, onClosedModal);
};
this.closeModal = (mainFactory) => {
this.modals = this.modals.filter(i => i !== mainFactory);
mainFactory.modalRoot.removeChild(mainFactory.mainDivElement);
mainFactory.modalRoot.removeChild(mainFactory.backdropDivElement);
this.forceUpdate();
};
this.push = (path) => {
if (this.history) {
const push = this.history?.push;
if (typeof push === 'function') {
push(path);
}
else {
console.error('push is not a function on history');
}
}
};
this.signOut = () => {
const authFactory = this.any['intializeAuthFactory_temp'];
if (authFactory) {
const signOut = authFactory.signOut;
if (typeof signOut === 'function') {
signOut();
}
else {
console.error(`signOut in not function on signout`, signOut);
}
}
else {
console.error(`authFactory is undefined on signout`, authFactory);
}
};
// generateTheme = () => {
// const option = this.Usering.userOptions.find(item => item.key === 'theme');
// if (option) {
// this._themeMode = 'dark';
// }
// }
this._themeMode = 'light';
this.windowWidth = 0;
this.delayLayoutShowForMain = undefined;
this.progressInitialize = false;
this.progressBarLoading = 0;
this.classEffect = '';
this.classEffectFooter = '';
}
get any() {
return this;
}
get authFactory() {
return __classPrivateFieldGet(this, _MainStateManager_authFactory, "f");
}
get baseUrl() {
return __classPrivateFieldGet(this, _MainStateManager_baseUrl, "f");
}
get projectKey() {
return __classPrivateFieldGet(this, _MainStateManager_projectKey, "f");
}
get pathManager() {
return __classPrivateFieldGet(this, _MainStateManager_pathManager, "f");
}
get userInfo() {
return __classPrivateFieldGet(this, _MainStateManager_userInfo, "f");
}
get settingInfo() {
return __classPrivateFieldGet(this, _MainStateManager_settingInfo, "f");
}
get fiscalYearsInfo() {
return __classPrivateFieldGet(this, _MainStateManager_fiscalYearsInfo, "f");
}
get subSystemsInfo() {
return __classPrivateFieldGet(this, _MainStateManager_subSystemsInfo, "f");
}
get tokenInfo() {
return __classPrivateFieldGet(this, _MainStateManager_tokenInfo, "f");
}
get themeMode() {
return this._themeMode;
}
setWindowWidth(windowWidth) {
this.windowWidth = windowWidth;
}
setOpacityDisplay(opacityDisplay) {
this.classEffect = opacityDisplay ? 'opacity-display-show' : 'opacity-display-hide';
this.classEffectFooter = opacityDisplay ? 'opacity-display-show-footer' : 'opacity-display-hide-footer';
}
getCaptionNaming(caption) {
if (!caption) {
return 'nothing';
}
if (typeof caption === 'string') {
return caption;
}
if (caption instanceof Array) {
if (caption.length === 2) {
return caption[1];
}
}
// if (caption instanceof CaptionNaming) {
// return (caption as any)[this.Languaging.languageSuffix];
// }
// if (typeof caption === 'object') {
// if (this.Languaging.languageSuffix in caption) {
// return (caption as any)[this.Languaging.languageSuffix];
// } else if ('FA' in caption) {
// return (caption as any)['FA'];
// } else if ('EN' in caption) {
// return (caption as any)['EN'];
// }
// }
return 'nothing';
}
}
exports.MainStateManager = MainStateManager;
_MainStateManager_authFactory = new WeakMap(), _MainStateManager_baseUrl = new WeakMap(), _MainStateManager_projectKey = new WeakMap(), _MainStateManager_pathManager = new WeakMap(), _MainStateManager_userInfo = new WeakMap(), _MainStateManager_settingInfo = new WeakMap(), _MainStateManager_fiscalYearsInfo = new WeakMap(), _MainStateManager_subSystemsInfo = new WeakMap(), _MainStateManager_tokenInfo = new WeakMap();