UNPKG

armisa-models

Version:
51 lines (50 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PasswordBoxFactory = void 0; const chainOfResponsibility_1 = require("../chainOfResponsibility"); const enums_1 = require("../enums"); const ElementFactory_1 = require("../Page/ElementsOfFormFactory/ElementFactory"); const Cach_1 = require("./Cach"); class PasswordBoxFactory extends ElementFactory_1.ElementFactory { constructor(mainStateFactory, fieldName, _dispose, caption, placeHolder, tabIndex, payLoadKey, responseKey) { super(mainStateFactory, fieldName, _dispose, payLoadKey, responseKey); this.caption = caption; this.placeHolder = placeHolder; this.tabIndex = tabIndex; this.forceUpdate = () => { }; this.value = null; this.setValue = (value) => { this.value = value; Cach_1.Cach.setValue(this, value); this.forceUpdate(); }; this.clearData = () => { Cach_1.Cach.clear(this); }; this.deseriallize = () => { }; this.refreshHasChange = () => { }; this.restartDefaultValue = () => { }; this.validate = () => { var validationChain = new chainOfResponsibility_1.ValidationChain(); validationChain.validators.add(this.validateRequired); this.validation = validationChain.validate(); }; this.validateRequired = (eventArgs) => { if (!this.value) { eventArgs.error = 'پسورد وارد نشده است'; eventArgs.state = enums_1.EnumValidateState.empty; eventArgs.cancel = true; } }; if (Cach_1.Cach.isCached(this)) { const cach = Cach_1.Cach.getCached(this); this.value = cach.value; this.validation = cach.validation; this._hasChange = cach.hasChange; } } } exports.PasswordBoxFactory = PasswordBoxFactory;