diff --git a/src/util/resultelement.ts b/src/util/resultelement.ts index 3a515e6fffa15480812a2d88bfd38438883db11b..6b98dab709f677714b8f27fc23b83b435406fc53 100644 --- a/src/util/resultelement.ts +++ b/src/util/resultelement.ts @@ -47,23 +47,6 @@ export class ResultElement { * for ex. with SectionParametree */ get vCalc(): number { - /* if (this.parent && this.parent.symbol) { - if (this.parent.symbol in this._values) { - return this._values[this.parent.symbol]; - } else { - // required symbol not found; if only the empty key "" is present, - // return its value (@WARNING clodo rustine) - if (this.count() > 1) { - // throw new Error("clodo rustine failed"); - return undefined; - } else { - return this.firstValue; - } - } - } - // default retrocompatible pseudo-symbol for cases like `new ResultElement(42);` - return this._values[""]; */ - return this._values[this.vCalcSymbol]; } @@ -99,6 +82,24 @@ export class ResultElement { this._values = { ...this._values, ...values }; } + /** + * Returns an array of all the keys in the local values map, + * where vCalcSymbol is always in first position (used by + * GUI to iterate on displayable results) + */ + public get keys(): string[] { + const keys = Object.keys(this._values); + // make sure vCalc symbol is always first + if (this.vCalcSymbol) { // sometimes empty (ex: SectionParametree) + const index = keys.indexOf(this.vCalcSymbol); + if (index > -1) { + keys.splice(index, 1); + } + keys.unshift(this.vCalcSymbol); + } + return keys; + } + /** * @returns the result value associated to the given symbol, or undefined if the given * symbol was not found in the local values map