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

Loading…
Cancel
Save