Browse Source

Fixed validation for Digital Gauge widget maxValue when it is zero (#15893)

* Fixed validation for Digital Gauge widget maxValue when it is zero

* Fixed check
pull/15913/head
Maksym Tsymbarov 3 months ago
committed by GitHub
parent
commit
5493ac7da5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 11
      ui-ngx/src/app/modules/home/components/widget/config/basic/gauge/digital-simple-gauge-basic-config.component.ts
  2. 11
      ui-ngx/src/app/modules/home/components/widget/lib/settings/gauge/digital-gauge-widget-settings.component.ts

11
ui-ngx/src/app/modules/home/components/widget/config/basic/gauge/digital-simple-gauge-basic-config.component.ts

@ -30,7 +30,7 @@ import {
getTimewindowConfig,
setTimewindowConfig
} from '@home/components/widget/config/timewindow-config-panel.component';
import { formatValue, isDefined, isUndefined } from '@core/utils';
import { formatValue, isDefined, isDefinedAndNotNull, isNumeric, isUndefined } from '@core/utils';
import { Component } from '@angular/core';
import {
convertLevelColorsSettingsToColorProcessor,
@ -189,11 +189,10 @@ export class DigitalSimpleGaugeBasicConfigComponent extends BasicWidgetConfigCom
private maxValueValidation(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const value: string = control.value;
if (value) {
if (value < control.parent?.get('minValue').value) {
return {maxValue: true};
}
const value: number = control.value;
const minValue = control.parent?.get('minValue').value;
if (isNumeric(value) && isDefinedAndNotNull(minValue) && value < minValue) {
return {maxValue: true};
}
return null;
};

11
ui-ngx/src/app/modules/home/components/widget/lib/settings/gauge/digital-gauge-widget-settings.component.ts

@ -37,7 +37,7 @@ import {
digitalGaugeLayoutTranslations,
DigitalGaugeType
} from '@home/components/widget/lib/digital-gauge.models';
import { formatValue, isDefined } from '@core/utils';
import { formatValue, isDefined, isDefinedAndNotNull, isNumeric } from '@core/utils';
import {
ColorSettings,
ColorType,
@ -218,11 +218,10 @@ export class DigitalGaugeWidgetSettingsComponent extends WidgetSettingsComponent
private maxValueValidation(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const value: string = control.value;
if (value) {
if (value < control.parent?.get('minValue').value) {
return {maxValue: true};
}
const value: number = control.value;
const minValue = control.parent?.get('minValue').value;
if (isNumeric(value) && isDefinedAndNotNull(minValue) && value < minValue) {
return {maxValue: true};
}
return null;
};

Loading…
Cancel
Save