From 731cf06e606ac7d1df98f3fed8a58c29bfbb7fb1 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Wed, 20 Aug 2025 16:13:13 -0600 Subject: [PATCH] change to the form so that if a device has individual calibrations it can still use the mode stuff --- src/component/ComponentForm.tsx | 168 +++++++++++++++++--------------- 1 file changed, 89 insertions(+), 79 deletions(-) diff --git a/src/component/ComponentForm.tsx b/src/component/ComponentForm.tsx index 08d6117..99568da 100644 --- a/src/component/ComponentForm.tsx +++ b/src/component/ComponentForm.tsx @@ -699,6 +699,86 @@ export default function ComponentForm(props: Props) { ); }; + const componentMode = () => { + const { component, coefficient, offset } = form; + return ( + + + + + } + label="Mode" + labelPlacement="top" + className={classes.switchControl} + disabled={!canEdit} + /> + + + + {compMode.mode.entryA && ( + + {compMode.mode.entryA === "select" && + compMode.mode.dictionaryA.map((elem: any) => { + if (!elem.restricted || (elem.restricted && user.hasAdmin())) { + return ( + + {elem.key} + + ); + } + return undefined; //TODO-CS: Time permitting re-think the structure of this function so that I don't have to return undefined + })} + + )} + + + {compMode.mode.entryB && ( + + {compMode.mode.entryB === "select" && + compMode.mode.dictionaryB.map((elem: any) => ( + + {elem.key} + + ))} + + )} + + + ) + } + const describeSource = (measurementType: quack.MeasurementType): MeasurementDescriber => { const { component } = form; return describeMeasurement(measurementType, component.type(), component.subType()); @@ -1046,87 +1126,17 @@ export default function ComponentForm(props: Props) { } - {!compMode ? ( - device.featureSupported("individualCalibrations") ? ( - individualCalibration() - ) : ( - blanketCalibration() - ) - ) : ( + {device.featureSupported("individualCalibrations") ? ( - - - - } - label="Mode" - labelPlacement="top" - className={classes.switchControl} - disabled={!canEdit} - /> - - - - {compMode.mode.entryA && ( - - {compMode.mode.entryA === "select" && - compMode.mode.dictionaryA.map((elem: any) => { - if (!elem.restricted || (elem.restricted && user.hasAdmin())) { - return ( - - {elem.key} - - ); - } - return undefined; //TODO-CS: Time permitting re-think the structure of this function so that I don't have to return undefined - })} - - )} - - - {compMode.mode.entryB && ( - - {compMode.mode.entryB === "select" && - compMode.mode.dictionaryB.map((elem: any) => ( - - {elem.key} - - ))} - - )} - + {compMode && componentMode()} + {individualCalibration()} + ) : ( + !compMode ? ( + blanketCalibration() + ):( + componentMode() + ) )}