CE-878: updated to allow sublabel to be displayed under label

This commit is contained in:
Tim Chamberlain
2024-02-29 14:47:00 -06:00
parent 5f3957e897
commit 809f01e43e

View File

@ -242,7 +242,7 @@ export class Dropdown extends LabelComponent
{ {
if (this.options[i].id == id) if (this.options[i].id == id)
{ {
defaultValue = this.options[i] defaultValue = this.options[i];
args.dropdownData[args.componentIndex] = defaultValue?.id; args.dropdownData[args.componentIndex] = defaultValue?.id;
} }
} }
@ -250,7 +250,7 @@ export class Dropdown extends LabelComponent
} }
catch (e) catch (e)
{ {
console.log(`Error getting default value for dropdown [${this.dropdownName}] from local storage`, e) console.log(`Error getting default value for dropdown [${this.dropdownName}] from local storage`, e);
} }
} }
@ -401,7 +401,7 @@ function Widget(props: React.PropsWithChildren<Props>): JSX.Element
// for initial render, put right-components from props into the state variable // // for initial render, put right-components from props into the state variable //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
const stateLabelComponentsRight = [] as LabelComponent[]; const stateLabelComponentsRight = [] as LabelComponent[];
// console.log(`${props.widgetMetaData.name} init'ing right-components`); // console.log(`${props.widgetMetaData.name} initiating right-components`);
if (props.labelAdditionalComponentsRight) if (props.labelAdditionalComponentsRight)
{ {
props.labelAdditionalComponentsRight.map((component) => stateLabelComponentsRight.push(component)); props.labelAdditionalComponentsRight.map((component) => stateLabelComponentsRight.push(component));
@ -606,9 +606,17 @@ function Widget(props: React.PropsWithChildren<Props>): JSX.Element
</Typography> </Typography>
); );
let sublabelElement = (
<Box height="20px">
<Typography sx={{position: "relative", top: "-18px"}} variant="caption">
{props.widgetData?.sublabel}
</Typography>
</Box>
);
if (labelToUse && labelToUse != lastSeenLabel) if (labelToUse && labelToUse != lastSeenLabel)
{ {
setLastSeenLabel(labelToUse) setLastSeenLabel(labelToUse);
setUsingLabelAsTitle(props.widgetData.isLabelPageTitle); setUsingLabelAsTitle(props.widgetData.isLabelPageTitle);
} }
@ -634,6 +642,7 @@ function Widget(props: React.PropsWithChildren<Props>): JSX.Element
{ {
needLabelBox && needLabelBox &&
<Box display="flex" justifyContent="space-between" alignItems="flex-start" sx={{width: "100%", ...props.labelBoxAdditionalSx}} minHeight={"2.5rem"}> <Box display="flex" justifyContent="space-between" alignItems="flex-start" sx={{width: "100%", ...props.labelBoxAdditionalSx}} minHeight={"2.5rem"}>
<Box display="flex" flexDirection="column">
<Box display="flex" alignItems="baseline"> <Box display="flex" alignItems="baseline">
{ {
hasPermission ? hasPermission ?
@ -685,6 +694,12 @@ function Widget(props: React.PropsWithChildren<Props>): JSX.Element
} }
{localLabelAdditionalElementsLeft} {localLabelAdditionalElementsLeft}
</Box> </Box>
<Box display="flex">
{
hasPermission && props.widgetData?.sublabel && (sublabelElement)
}
</Box>
</Box>
<Box> <Box>
{ {
hasPermission && ( hasPermission && (