Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 995x 204x 204x 258x 791x 737x | import { PropertyInfoRead, PropertyValueRead } from "../../../../../api/apiStore.gen";
type ValueInfo = {
displayPath: string;
propertyInfo: PropertyInfoRead
propertyValue: PropertyValueRead
}
type PropertyValueMap = {
[key: string]: PropertyValueMap
} | PropertyValueRead
function _getValues(path: string, dict: PropertyValueMap, propertyInfo: PropertyInfoRead): ValueInfo[] {
// recursively iterate through the object to get the values
// this is used to populate the list of expressions
if (dict.id == undefined) {
dict = dict as PropertyValueMap;
// Recursively go further up until we get to the property value
return Object.keys(dict).flatMap((key) => {
return _getValues(path + " " + key, dict[key], propertyInfo);
});
} else {
// we have got to a property value
return [{
displayPath: path,
propertyInfo: propertyInfo,
propertyValue: dict as PropertyValueRead
}];
}
}
export function getValuesList(prop: PropertyInfoRead): ValueInfo[] {
// the "values" field is a dictionary of dictionaries,
// indexed by as many indexes as there are, until
// you get to the final values. e.g
// values: {
// "inlet_1": {
// "benzene": {
// "id": 1,
// "value": "value1"
// }
// }
// }
return _getValues(prop.displayName,prop.values, prop)
}
|