UNPKG

amisa-forms

Version:
153 lines (152 loc) 7.68 kB
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 __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 _FormFactory_mainStateManager, _FormFactory_elementsManager, _FormFactory_tabbingManager, _FormFactory_payloadsManager; import { Argument } from "../Argument"; import { ElementsManager } from "./ElementsManager"; import { PayloadsManager } from "./PayloadsManager"; import { TabbingManager } from "./TabbingManager"; export class FormFactory { constructor(mainStateManager) { this.forceUpdate = () => { }; _FormFactory_mainStateManager.set(this, void 0); _FormFactory_elementsManager.set(this, void 0); _FormFactory_tabbingManager.set(this, void 0); _FormFactory_payloadsManager.set(this, void 0); this.addElement = (element) => { __classPrivateFieldGet(this, _FormFactory_elementsManager, "f").addElement(element); __classPrivateFieldGet(this, _FormFactory_tabbingManager, "f").addElement(element); }; this.removeElement = (element) => { delete this.any[element.factoryFieldName]; __classPrivateFieldGet(this, _FormFactory_elementsManager, "f").removeElement(element); __classPrivateFieldGet(this, _FormFactory_tabbingManager, "f").removeElement(element); }; this.focuseToThisElement = (factory) => { if (typeof factory.tabIndex === 'number' && factory.element) { __classPrivateFieldGet(this, _FormFactory_tabbingManager, "f").elementTabbing.focusToElementByHTMLElement(factory.element); } }; this.addResponseElement = (element) => { if (this.responses === undefined) { this.responses = []; } this.responses.push(element); }; this.deserializedResponse = (data) => { if (this.responses && this.responses.length > 0) { this.responses.forEach((element) => { element.deseriallize(data.getProp(element.responseKey)); }); } }; this.otherPayLoad = []; this.addOtherPayLoadKey = (object, payLoadKey, fieldName) => { if (typeof payLoadKey === 'string' && !this.otherPayLoad.find(i => i.payLoadKey === payLoadKey)) { this.otherPayLoad.push({ object, payLoadKey, fieldName }); } }; this.addPayloadElement = (element) => { if (typeof element.payLoadKey === 'string') { if (this.payLoad === undefined) { this.payLoad = []; } this.payLoad.push(element); } }; this.showPopup = (children, element, onClosedPopup) => { if (this.popup) { return; } }; this.closePopup = () => { this.popup?.close(); this.popup = undefined; }; this.showModal = (children, onClosedModal, argument, customPayload, finedInRows, ExtraStackMenuComponent, typeOfForm, cssClasses) => { if (this.childModal) { return; } let argumentClass; if (typeof argument === 'number') { argumentClass = Argument.Id(argument, finedInRows); } else if (typeof argument === 'string') { argumentClass = Argument.Code(argument, finedInRows); } else if (typeof argument === 'object') { argumentClass = Argument.Object(argument, finedInRows); } else { argumentClass = Argument.Object({}, false); } argumentClass.typeOfForm = typeOfForm; argumentClass.ExtraStackMenuComponent = ExtraStackMenuComponent; argumentClass.customPayload = customPayload; // this.mainStateManager.showModal(this.mainStateFactory, children, false, onClosedModal, argumentClass, cssClasses); }; this.closeModal = () => { this.childModal?.close(); this.childModal = undefined; }; this.showFullScreenWaittingSpinner = (onClosedModal) => { this.mainStateManager.showFullScreenWaittingSpinner(this, onClosedModal); }; this.closeFullScreenWaittingSpinner = () => { this.childModal?.close(); }; this.showSomeThingWentWrong = (onClosedModal) => { }; this.showErrorMessageBox = (error, onClosedModal) => { }; this.showInvalidArgumentMessageBox = (description, onClosedModal) => { }; this.showSuccessFullMessageBox = (caption, text, description, onClosedModal) => { }; this.showAreYouSureDeleteMessageBox = (onClickDelete, caption, text, description) => { }; this.showThereAreSomeErrorYouCanNot = (countOfError, onClosedModal) => { }; this.showThereIsNotAnyChangeForSave = (onClosedModal) => { }; this.close = () => { // if (this.subPageItem) { // this.subPageItem.close(); // } else if (this.childModal) { // this.childModal.mainStateFactory.any.dispose && this.childModal.mainStateFactory.any.dispose(); // this.childModal.close(); // } else if (this.subPageFactory && this.subPageFactory.subPages.length === 0) { // this.mainStateFactory.any.dispose && this.mainStateFactory.any.dispose(); // this.mainStateManager.history && this.mainStateManager.history.push('/home'); }; __classPrivateFieldSet(this, _FormFactory_mainStateManager, mainStateManager, "f"); __classPrivateFieldSet(this, _FormFactory_payloadsManager, new PayloadsManager(this), "f"); __classPrivateFieldSet(this, _FormFactory_elementsManager, new ElementsManager(this), "f"); __classPrivateFieldSet(this, _FormFactory_tabbingManager, new TabbingManager(this), "f"); } get any() { return this; } get mainStateManager() { return __classPrivateFieldGet(this, _FormFactory_mainStateManager, "f"); } get elementsManager() { return __classPrivateFieldGet(this, _FormFactory_elementsManager, "f"); } get tabbingManager() { return __classPrivateFieldGet(this, _FormFactory_tabbingManager, "f"); } get payloadsManager() { return __classPrivateFieldGet(this, _FormFactory_payloadsManager, "f"); } } _FormFactory_mainStateManager = new WeakMap(), _FormFactory_elementsManager = new WeakMap(), _FormFactory_tabbingManager = new WeakMap(), _FormFactory_payloadsManager = new WeakMap();