Skip to content

Commit

Permalink
Fix text resource bindings for summary2 (#2624)
Browse files Browse the repository at this point in the history
* fix missing keys warning

* fix dynamic TRB for summary2
  • Loading branch information
Magnusrm authored Oct 23, 2024
1 parent e25af39 commit 86cc5a5
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 27 deletions.
35 changes: 30 additions & 5 deletions src/layout/Address/AddressSummary/AddressSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export function AddressSummary({ componentNode }: AddressSummaryProps) {
<div className={classes.addressSummaryComponent}>
<div>
<SingleValueSummary
title={<Lang id={title || 'address_component.address'} />}
title={
<Lang
id={title || 'address_component.address'}
node={componentNode}
/>
}
displayData={address}
componentNode={componentNode}
/>
Expand All @@ -42,7 +47,12 @@ export function AddressSummary({ componentNode }: AddressSummaryProps) {
{!simplified && (
<div>
<SingleValueSummary
title={<Lang id={careOfTitle || 'address_component.care_of'} />}
title={
<Lang
id={careOfTitle || 'address_component.care_of'}
node={componentNode}
/>
}
displayData={careOf}
componentNode={componentNode}
hideEditButton={true}
Expand All @@ -57,7 +67,12 @@ export function AddressSummary({ componentNode }: AddressSummaryProps) {
<div className={classes.addressSummaryComponentZipCode}>
<div className={classes.addressComponentZipCode}>
<SingleValueSummary
title={<Lang id={zipCodeTitle || 'address_component.zip_code'} />}
title={
<Lang
id={zipCodeTitle || 'address_component.zip_code'}
node={componentNode}
/>
}
displayData={zipCode}
componentNode={componentNode}
hideEditButton={true}
Expand All @@ -70,7 +85,12 @@ export function AddressSummary({ componentNode }: AddressSummaryProps) {

<div className={classes.addressSummaryComponentPostplace}>
<SingleValueSummary
title={<Lang id={postPlaceTitle || 'address_component.post_place'} />}
title={
<Lang
id={postPlaceTitle || 'address_component.post_place'}
node={componentNode}
/>
}
displayData={postPlace}
componentNode={componentNode}
hideEditButton={true}
Expand All @@ -83,7 +103,12 @@ export function AddressSummary({ componentNode }: AddressSummaryProps) {
{!simplified && (
<div>
<SingleValueSummary
title={<Lang id={houseNumberTitle || 'address_component.house_number'} />}
title={
<Lang
id={houseNumberTitle || 'address_component.house_number'}
node={componentNode}
/>
}
displayData={houseNumber}
componentNode={componentNode}
hideEditButton={true}
Expand Down
7 changes: 6 additions & 1 deletion src/layout/Checkboxes/CheckboxesSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export function CheckboxesSummary({

return (
<MultipleValueSummary
title={<Lang id={title} />}
title={
<Lang
id={title}
node={componentNode}
/>
}
componentNode={componentNode}
isCompact={isCompact}
showAsList={showAsList}
Expand Down
9 changes: 8 additions & 1 deletion src/layout/Datepicker/DatepickerSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export const DatepickerSummary = ({ componentNode, isCompact, emptyFieldText }:

return (
<SingleValueSummary
title={title && <Lang id={title} />}
title={
title && (
<Lang
id={title}
node={componentNode}
/>
)
}
displayData={displayData}
errors={errors}
componentNode={componentNode}
Expand Down
9 changes: 8 additions & 1 deletion src/layout/Dropdown/DropdownSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export const DropdownSummary = ({ componentNode, isCompact, emptyFieldText }: Dr

return (
<SingleValueSummary
title={title && <Lang id={title} />}
title={
title && (
<Lang
id={title}
node={componentNode}
/>
)
}
displayData={displayData}
errors={errors}
componentNode={componentNode}
Expand Down
5 changes: 4 additions & 1 deletion src/layout/Grid/GridSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export const GridSummary = ({ componentNode }: GridSummaryProps) => {
size='xs'
level={4}
>
<Lang id={title} />
<Lang
id={title}
node={componentNode}
/>
</Heading>
</caption>
)}
Expand Down
5 changes: 4 additions & 1 deletion src/layout/Group/GroupSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export const GroupSummary = ({ componentNode, hierarchyLevel = 0, summaryOverrid
size={isNestedGroup ? 'xsmall' : 'small'}
level={headingLevel}
>
<Lang id={summaryTitle ?? title} />
<Lang
id={summaryTitle ?? title}
node={componentNode}
/>
</Heading>
<Grid
container
Expand Down
12 changes: 10 additions & 2 deletions src/layout/Header/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ export const HeaderComponent = ({ node }: IHeaderProps) => {
id={id}
{...getHeaderProps(size)}
>
<Lang id={textResourceBindings?.title} />
<Lang
id={textResourceBindings?.title}
node={node}
/>
</Heading>
</Grid>
{textResourceBindings?.help && (
<Grid item={true}>
<HelpTextContainer
helpText={<Lang id={textResourceBindings.help} />}
helpText={
<Lang
id={textResourceBindings.help}
node={node}
/>
}
title={langAsString(textResourceBindings?.title)}
/>
</Grid>
Expand Down
9 changes: 8 additions & 1 deletion src/layout/Input/InputSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export const InputSummary = ({ componentNode, isCompact, emptyFieldText }: Input

return (
<SingleValueSummary
title={title && <Lang id={title} />}
title={
title && (
<Lang
id={title}
node={componentNode}
/>
)
}
displayData={displayData}
errors={errors}
componentNode={componentNode}
Expand Down
12 changes: 10 additions & 2 deletions src/layout/Likert/Summary2/LikertSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export function LikertSummary({ componentNode, emptyFieldText, isCompact }: Like
if (!rows.length || rows.length <= 0) {
return (
<SingleValueSummary
title={title}
title={
<Lang
id={title}
node={componentNode}
/>
}
componentNode={componentNode}
errors={errors}
hideEditButton={readOnly}
Expand All @@ -46,7 +51,10 @@ export function LikertSummary({ componentNode, emptyFieldText, isCompact }: Like
size='xs'
level={4}
>
<Lang id={title} />
<Lang
id={title}
node={componentNode}
/>
</Heading>
</div>
{rows.map((row) => (
Expand Down
9 changes: 8 additions & 1 deletion src/layout/List/ListSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export const ListSummary = ({ componentNode, isCompact, emptyFieldText }: ListCo

return (
<SingleValueSummary
title={title && <Lang id={title} />}
title={
title && (
<Lang
id={title}
node={componentNode}
/>
)
}
displayData={displayData}
errors={errors}
componentNode={componentNode}
Expand Down
7 changes: 6 additions & 1 deletion src/layout/Map/Summary2/MapSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export function MapSummary({ componentNode, emptyFieldText, isCompact }: MapSumm
if (markerBinding && !markerLocationIsValid) {
return (
<SingleValueSummary
title={title}
title={
<Lang
id={title}
node={componentNode}
/>
}
componentNode={componentNode}
errors={errors}
hideEditButton={readOnly}
Expand Down
7 changes: 6 additions & 1 deletion src/layout/MultipleSelect/MultipleSelectSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export function MultipleSelectSummary({

return (
<MultipleValueSummary
title={<Lang id={title} />}
title={
<Lang
id={title}
node={componentNode}
/>
}
componentNode={componentNode}
showAsList={showAsList}
isCompact={isCompact}
Expand Down
17 changes: 14 additions & 3 deletions src/layout/Paragraph/ParagraphComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,27 @@ export function ParagraphComponent({ node }: IParagraphProps) {
<Paragraph asChild={!hasInlineContent}>
{!hasInlineContent ? (
<div>
<Lang id={textResourceBindings?.title} />
<Lang
id={textResourceBindings?.title}
node={node}
/>
</div>
) : (
<Lang id={textResourceBindings?.title} />
<Lang
id={textResourceBindings?.title}
node={node}
/>
)}
</Paragraph>
</div>
{textResourceBindings?.help && (
<HelpTextContainer
helpText={<Lang id={textResourceBindings?.help} />}
helpText={
<Lang
id={textResourceBindings?.help}
node={node}
/>
}
title={elementAsString(text)}
/>
)}
Expand Down
9 changes: 8 additions & 1 deletion src/layout/RadioButtons/RadioButtonsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ export const RadioButtonsSummary = ({ componentNode, isCompact, emptyFieldText }
const title = useNodeItem(componentNode, (i) => i.textResourceBindings?.title);
return (
<SingleValueSummary
title={title && <Lang id={title} />}
title={
title && (
<Lang
id={title}
node={componentNode}
/>
)
}
displayData={displayData}
errors={errors}
componentNode={componentNode}
Expand Down
9 changes: 6 additions & 3 deletions src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ export const RepeatingGroupSummary = ({
size='xs'
level={4}
>
<Lang id={title} />
<Lang
id={title}
node={componentNode}
/>
</Heading>
<div className={cn(classes.contentWrapper, { [classes.nestedContentWrapper]: isNested })}>
{rows.map((row, index) => (
<>
<React.Fragment key={row?.uuid}>
{index != 0 && <hr className={classes.rowDivider} />}
<Grid
key={row?.uuid}
Expand All @@ -72,7 +75,7 @@ export const RepeatingGroupSummary = ({
/>
))}
</Grid>
</>
</React.Fragment>
))}
</div>
{errors?.map(({ message }) => (
Expand Down
5 changes: 4 additions & 1 deletion src/layout/Tabs/TabsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export const TabsSummary = ({ componentNode }: TabsSummaryProps) => {
size='xs'
level={4}
>
<Lang id={tab.title} />
<Lang
id={tab.title}
node={componentNode}
/>
</Heading>
<Grid
container
Expand Down
9 changes: 8 additions & 1 deletion src/layout/TextArea/TextAreaSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export const TextAreaSummary = ({ componentNode, isCompact, emptyFieldText }: Te

return (
<SingleValueSummary
title={title && <Lang id={title} />}
title={
title && (
<Lang
id={title}
node={componentNode}
/>
)
}
displayData={displayData}
errors={errors}
componentNode={componentNode}
Expand Down

0 comments on commit 86cc5a5

Please sign in to comment.