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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 12127x 12127x 12127x 12127x 12127x 1091x 12127x 12478x 210x 2x | import { PropertyInfoRead } from "../../../../../../api/apiStore.gen";
import type { RuleFinding } from "../../../Diagnostics/useRuleValidation";
import { VariableWithUnit } from "./VariableWithUnit";
export interface IndexedVariableWithUnitProps {
property: PropertyInfoRead;
objectId?: number;
onUpdateUnit: (unit: string) => void;
withMSSConnection?: boolean; // should be applied if multi steady state applies
onUpdateValue: (value: string, id: number) => void;
deletePropertyFunction?: (property_val_key: string) => void;
ruleFindings?: RuleFinding[];
}
export function IndexedVariableWithUnit(props: IndexedVariableWithUnitProps) {
const values = props.property.values; // if values is passed, just process the subset of all values
if (values.id === undefined) {
// console.error("No id found for property", props.property,"with values", values , "and indexes", props.indexes,"which means there probably is not the same depth of indexes as values, or some other logic issue.")
}
const individualNames = props.property.values?.[0]?.indexedSets.length != 0;
const name = individualNames ? props.property.displayName : null;
const sortedValues = [...values].sort((v1, v2) =>
v1?.indexedSetNames?.join("").localeCompare(v2?.indexedSetNames?.join("")),
);
return (
<div>
{name}
{sortedValues.map((value) => {
return (
<VariableWithUnit
key={value.id}
property={props.property}
displayName={
individualNames
? value.indexedSetNames.join(" ")
: props.property.displayName +
" " +
value.indexedSetNames.join(" ")
}
objectId={props.objectId}
value={value}
onUpdateValue={(val) => {
props.onUpdateValue(val, value.id);
}}
onUpdateUnit={props.onUpdateUnit}
withMSSConnection={props.withMSSConnection}
// All indexed rows share the same property key, so they share
// the same property-level findings list.
ruleFindings={props.ruleFindings}
// Prevent the delete button from showing up if the deletePropertyFunction is not passed
deletePropertyFunction={
props.deletePropertyFunction
? () => {
props.deletePropertyFunction?.(value.indexedSets.join(" "));
}
: undefined
}
/>
);
})}
</div>
);
}
|