UNPKG

armisa-models

Version:
124 lines (123 loc) 6.5 kB
"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 _CheckBoxFactory_value, _CheckBoxFactory_defaultValue; Object.defineProperty(exports, "__esModule", { value: true }); exports.CheckBoxFactory = void 0; const chainOfResponsibility_1 = require("../chainOfResponsibility"); const ElementFactory_1 = require("../Page/ElementsOfFormFactory/ElementFactory"); const Cach_1 = require("./Cach"); class CheckBoxFactory extends ElementFactory_1.ElementFactory { get value() { return __classPrivateFieldGet(this, _CheckBoxFactory_value, "f"); } get defaultValue() { return __classPrivateFieldGet(this, _CheckBoxFactory_defaultValue, "f"); } constructor(_mainStateFactory, _fieldName, _dispose, caption, disabled, readonly, showHasChangeFlag, dirLeftToRight, tabIndex, initialValue, payLoadKey, responseKey) { super(_mainStateFactory, _fieldName, _dispose, payLoadKey, responseKey); this.caption = caption; this.disabled = disabled; this.readonly = readonly; this.showHasChangeFlag = showHasChangeFlag; this.dirLeftToRight = dirLeftToRight; this.tabIndex = tabIndex; this.forceUpdate = () => { }; _CheckBoxFactory_value.set(this, void 0); this.setValue = (value) => { this.mainStateFactory.any.cach[this.factoryFieldName] = value; __classPrivateFieldSet(this, _CheckBoxFactory_value, value, "f"); this.refreshHasChange(); Cach_1.Cach.setValue(this, value); this.forceUpdate(); }; this.deseriallize = (e) => { this.clearData(); if (e === null) { //do nothing } else if (e === undefined) { //do nothing } else if (typeof e === 'boolean') { __classPrivateFieldSet(this, _CheckBoxFactory_value, e, "f"); __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, e, "f"); } else if (typeof e === 'number') { __classPrivateFieldSet(this, _CheckBoxFactory_value, e > 0, "f"); __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, __classPrivateFieldGet(this, _CheckBoxFactory_value, "f"), "f"); } else if (typeof e === 'string') { const isTrue = () => { if (e.toLowerCase() === 'true') { return true; } else if (e === '1') { return true; } return false; }; __classPrivateFieldSet(this, _CheckBoxFactory_value, isTrue(), "f"); __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, __classPrivateFieldGet(this, _CheckBoxFactory_value, "f"), "f"); } Cach_1.Cach.setValue(this, __classPrivateFieldGet(this, _CheckBoxFactory_value, "f")); }; this.clearData = () => { Cach_1.Cach.clear(this); __classPrivateFieldSet(this, _CheckBoxFactory_value, false, "f"); __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, false, "f"); this.validation = true; this._hasChange = false; }; _CheckBoxFactory_defaultValue.set(this, void 0); this.focusToElement = () => { this.mainStateFactory.elementsOfForm.focuseToThisElement(this); }; this.restartDefaultValue = () => { __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, this.value, "f"); this.refreshHasChange(); }; this.refreshHasChange = () => { if (this.showHasChangeFlag) { this._hasChange = this.defaultValue !== __classPrivateFieldGet(this, _CheckBoxFactory_value, "f"); } }; this.validate = () => { var validationChain = new chainOfResponsibility_1.ValidationChain(); validationChain.validators.add(this.validateNormal); this.validation = validationChain.validate(); }; this.validateNormal = (_eventArgs) => { }; this.isValueEmpty = () => { return typeof __classPrivateFieldGet(this, _CheckBoxFactory_value, "f") === 'string' && __classPrivateFieldGet(this, _CheckBoxFactory_value, "f") !== ''; }; this.isValueNotEmpty = () => { return !this.isValueEmpty(); }; if (typeof initialValue === 'boolean') { __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, initialValue, "f"); __classPrivateFieldSet(this, _CheckBoxFactory_value, initialValue, "f"); } else { __classPrivateFieldSet(this, _CheckBoxFactory_defaultValue, false, "f"); __classPrivateFieldSet(this, _CheckBoxFactory_value, false, "f"); } if (Cach_1.Cach.isCached(this)) { const cach = Cach_1.Cach.getCached(this); __classPrivateFieldSet(this, _CheckBoxFactory_value, cach.value, "f"); this.validation = cach.validation; this._hasChange = cach.hasChange; } } } exports.CheckBoxFactory = CheckBoxFactory; _CheckBoxFactory_value = new WeakMap(), _CheckBoxFactory_defaultValue = new WeakMap();