Commit 8f34026e authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

getInferredValuesList(): add extendTo option, fix bug when in LISTE mode

parent 1c07939c
......@@ -477,10 +477,11 @@ export class ParamDefinition implements INamedIterableValues, IObservable {
/**
* Returns values as a number list, for LISTE and MINMAX modes;
* in MINMAX mode, infers the list from min/max/step values
* @param extendTo if given, will extend the values list to this number of values
*/
public getInferredValuesList() {
public getInferredValuesList(extendTo?: number) {
this.checkValueMode([ParamValueMode.LISTE, ParamValueMode.MINMAX, ParamValueMode.LINK]);
return this.paramValues.getInferredValuesList(false, undefined, true);
return this.paramValues.getInferredValuesList(false, extendTo, true);
}
/**
......
......@@ -116,11 +116,15 @@ export class ParamValues implements IterableValues {
*/
public getInferredValuesList(reverse: boolean = false, extendTo?: number, addLastStep: boolean = false) {
if ([ ParamValueMode.MINMAX, ParamValueMode.LISTE ].includes(this.valueMode)) {
// protection against infinite loops
if (
this.step !== undefined && this.step > 0
&& this.min !== undefined && this.min !== null
&& this.max !== undefined && this.max !== null
(this.valueMode === ParamValueMode.LISTE)
|| (
this.valueMode === ParamValueMode.MINMAX
// protection against infinite loops
&& this.step !== undefined && this.step > 0
&& this.min !== undefined && this.min !== null
&& this.max !== undefined && this.max !== null
)
) {
const it = this.initValuesIterator(reverse, extendTo, addLastStep);
const values: number[] = [];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment