UNPKG

armisa-models

Version:
63 lines (62 loc) 2.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChangingControl = void 0; class ChangeValuesClass { constructor(propertyName, disabled) { this.propertyName = propertyName; this.disabled = disabled; } } class ChangingControl { constructor(pageData) { this.pageData = pageData; this.controls = []; this.addControl = (propName) => { const control = this.controls.find((i) => i.propertyName === propName); if (control) { control.disabled = false; return; } if (this.pageData.selfState && this.pageData.selfState[propName] !== undefined && this.pageData.selfState[propName].hasChange) { const newData = new ChangeValuesClass(propName, false); this.controls.push(newData); } }; this.disabledControl = (propertyName) => { const control = this.controls.find((i) => i.propertyName === propertyName); if (control) { control.disabled = true; } }; this.removeAllControls = () => { this.controls = []; }; this.refreshChangeState = (propertyName) => { if (this.pageData.selfState && this.pageData.selfState[propertyName] !== undefined) { const value = this.pageData.selfState[propertyName]; if (value.showHasChangeFlag) { if (value.hasChange) { this.addControl(propertyName); } else { this.controls = this.controls.filter((i) => i.propertyName !== propertyName); } this.pageData.updateHasChange(); } } }; this.resetAllChange = () => { this.controls.forEach((control) => this.pageData.selfState[control.propertyName].restartDefaultValue()); this.controls = []; this.pageData.updateHasChange(); }; this.resetAllChangeNew = () => { this.controls = []; this.pageData.updateHasChange(); }; } } exports.ChangingControl = ChangingControl;