armisa-models
Version:
models of armisa!
129 lines (128 loc) • 7.16 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 _CheckBoxColumnVisibilityFactory_value, _CheckBoxColumnVisibilityFactory_defaultValue;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckBoxColumnVisibilityFactory = void 0;
const chainOfResponsibility_1 = require("../chainOfResponsibility");
const ElementFactory_1 = require("../Page/ElementsOfFormFactory/ElementFactory");
const Cach_1 = require("./Cach");
class CheckBoxColumnVisibilityFactory extends ElementFactory_1.ElementFactory {
get any() {
return this;
}
get value() {
return __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_value, "f");
}
get defaultValue() {
return __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_defaultValue, "f");
}
constructor(_mainStateFactory, _fieldName, _dispose, column, caption, disabled, readonly, showHasChangeFlag, dirLeftToRight, tabIndex, initialValue, payLoadKey, responseKey) {
super(_mainStateFactory, _fieldName, _dispose, payLoadKey, responseKey);
this.column = column;
this.caption = caption;
this.disabled = disabled;
this.readonly = readonly;
this.showHasChangeFlag = showHasChangeFlag;
this.dirLeftToRight = dirLeftToRight;
this.tabIndex = tabIndex;
this.forceUpdate = () => { };
_CheckBoxColumnVisibilityFactory_value.set(this, void 0);
this.setValue = (value) => {
this.mainStateFactory.any.cach[this.factoryFieldName] = value;
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_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, _CheckBoxColumnVisibilityFactory_value, e, "f");
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, e, "f");
}
else if (typeof e === 'number') {
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_value, e > 0, "f");
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_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, _CheckBoxColumnVisibilityFactory_value, isTrue(), "f");
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_value, "f"), "f");
}
Cach_1.Cach.setValue(this, __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_value, "f"));
};
this.clearData = () => {
Cach_1.Cach.clear(this);
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_value, false, "f");
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, false, "f");
this.validation = true;
this._hasChange = false;
};
_CheckBoxColumnVisibilityFactory_defaultValue.set(this, void 0);
this.focusToElement = () => {
this.mainStateFactory.elementsOfForm.focuseToThisElement(this);
};
this.restartDefaultValue = () => {
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, this.value, "f");
this.refreshHasChange();
};
this.refreshHasChange = () => {
if (this.showHasChangeFlag) {
this._hasChange = this.defaultValue !== __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_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, _CheckBoxColumnVisibilityFactory_value, "f") === 'string' && __classPrivateFieldGet(this, _CheckBoxColumnVisibilityFactory_value, "f") !== '';
};
this.isValueNotEmpty = () => {
return !this.isValueEmpty();
};
this.valueOfSaveVisibility = false;
if (typeof initialValue === 'boolean') {
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, initialValue, "f");
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_value, initialValue, "f");
}
else {
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_defaultValue, false, "f");
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_value, false, "f");
}
if (Cach_1.Cach.isCached(this)) {
const cach = Cach_1.Cach.getCached(this);
__classPrivateFieldSet(this, _CheckBoxColumnVisibilityFactory_value, cach.value, "f");
this.validation = cach.validation;
this._hasChange = cach.hasChange;
}
}
}
exports.CheckBoxColumnVisibilityFactory = CheckBoxColumnVisibilityFactory;
_CheckBoxColumnVisibilityFactory_value = new WeakMap(), _CheckBoxColumnVisibilityFactory_defaultValue = new WeakMap();