From 442bb837847a24be773965a4e5c2a06a61155bac Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 8 Feb 2022 13:35:49 +0200 Subject: [PATCH] UI: Fix timewindow panel form validation - disable aggregation limit check when aggregation is not none. --- .../time/timewindow-panel.component.html | 2 +- .../time/timewindow-panel.component.ts | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html index 21011736e9..1bb893d219 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html +++ b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html @@ -130,7 +130,7 @@ -
+
{ + this.updateValidators(); + }); + } + + private checkLimit(limit?: number): number { + if (!limit || limit < this.minDatapointsLimit()) { + return this.minDatapointsLimit(); + } else if (limit > this.maxDatapointsLimit()) { + return this.maxDatapointsLimit(); + } + return limit; + } + + private updateValidators() { + const aggType = this.timewindowForm.get('aggregation.type').value; + if (aggType !== AggregationType.NONE) { + this.timewindowForm.get('aggregation.limit').clearValidators(); + } else { + this.timewindowForm.get('aggregation.limit').setValidators([Validators.min(this.minDatapointsLimit()), + Validators.max(this.maxDatapointsLimit())]); + } + this.timewindowForm.get('aggregation.limit').updateValueAndValidity({emitEvent: false}); } update() {