UNPKG

armisa-models

Version:
61 lines (60 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TouchingControl = void 0; class TouchedControlClass { constructor(propertyName, disabled, touched) { this.propertyName = propertyName; this.disabled = disabled; this.touched = touched; } } class TouchingControl { constructor(pageData) { this.pageData = pageData; this.controls = []; this.disabledControl = (propertyName) => { const control = this.controls.find((i) => i.propertyName === propertyName); if (control) { control.disabled = true; } }; this.removeAllControls = () => { this.controls = []; }; } addControl(propName) { const control = this.controls.find((i) => i.propertyName === propName); if (control) { control.disabled = false; return; } const newData = new TouchedControlClass(propName, false, false); this.controls.push(newData); } setAllTouched() { this.controls.forEach((i) => (i.touched = true)); } setTouched(propertyName) { const control = this.controls.find((i) => i.propertyName === propertyName); if (control) { control.touched = true; } } clearTouched(propertyName) { const control = this.controls.find((i) => i.propertyName === propertyName); if (control) { control.touched = false; } } resetAllTouched() { this.controls.forEach((i) => (i.touched = false)); } isTouched(propertyName) { const control = this.controls.find((i) => i.propertyName === propertyName); if (control) { return control.touched; } return false; } } exports.TouchingControl = TouchingControl;