diff --git a/pkg/new-ui/v1beta1/frontend/src/app/services/experiment-form.service.ts b/pkg/new-ui/v1beta1/frontend/src/app/services/experiment-form.service.ts index 4c78ddede50..91f876fe3c5 100644 --- a/pkg/new-ui/v1beta1/frontend/src/app/services/experiment-form.service.ts +++ b/pkg/new-ui/v1beta1/frontend/src/app/services/experiment-form.service.ts @@ -240,10 +240,15 @@ export class ExperimentFormService { return param; } - if ((param.feasibleSpace as FeasibleSpaceMinMax).step === '') { + const step = (param.feasibleSpace as FeasibleSpaceMinMax).step; + if (step === '' || step === null) { delete (param.feasibleSpace as FeasibleSpaceMinMax).step; } + for (const key in param.feasibleSpace) { + param.feasibleSpace[key] = param.feasibleSpace[key].toString(); + } + return param; } diff --git a/pkg/new-ui/v1beta1/frontend/src/app/shared/params-list/add-modal/add-modal.component.html b/pkg/new-ui/v1beta1/frontend/src/app/shared/params-list/add-modal/add-modal.component.html index 7d777378fd6..ed2ec62f93c 100644 --- a/pkg/new-ui/v1beta1/frontend/src/app/shared/params-list/add-modal/add-modal.component.html +++ b/pkg/new-ui/v1beta1/frontend/src/app/shared/params-list/add-modal/add-modal.component.html @@ -27,17 +27,17 @@

Add new parameter

Min - + Max - + Step (optional) - +
diff --git a/pkg/new-ui/v1beta1/frontend/src/app/shared/utils.ts b/pkg/new-ui/v1beta1/frontend/src/app/shared/utils.ts index fbe1dbeb055..a66208c1c1b 100644 --- a/pkg/new-ui/v1beta1/frontend/src/app/shared/utils.ts +++ b/pkg/new-ui/v1beta1/frontend/src/app/shared/utils.ts @@ -1,5 +1,13 @@ import lowerCase from 'lodash-es/lowerCase'; -import { FormControl, FormGroup, Validators, FormArray } from '@angular/forms'; +import { + FormControl, + FormGroup, + Validators, + FormArray, + ValidatorFn, + AbstractControl, + ValidationErrors, +} from '@angular/forms'; import { ParameterSpec, FeasibleSpaceMinMax, @@ -31,7 +39,7 @@ export function createFeasibleSpaceGroup( return new FormGroup({ min: new FormControl(fs.min, Validators.required), max: new FormControl(fs.max, Validators.required), - step: new FormControl(fs.step, []), + step: new FormControl(fs.step, checkIfZero()), }); } @@ -133,3 +141,12 @@ export const safeMultiplication = ( multiplicand: number, multiplier: number, ): number => Math.round(multiplicand * 10000.0 * multiplier) / 10000; + +export const checkIfZero = (): ValidatorFn => { + return (control: AbstractControl): ValidationErrors | null => { + if (control.value === null || control.value === '') return null; + + const isZero = !/[^0.]/g.test(control.value.toString()); + return isZero ? { mustNotBeZero: { value: control.value } } : null; + }; +};