From 212e93e5cd2cbc76a20c3b336ee9b24248f03f02 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Wed, 12 Jun 2024 19:00:47 +0200 Subject: [PATCH] JNG-5767 handle missing single association --- .../blackbelt/judo/ui/generator/react/UiActionsHelper.java | 4 ++-- .../actor/src/components/widgets/AssociationButton.tsx.hbs | 6 +++--- .../actor/src/pages/actions/PreFetchAction.fragment.hbs | 2 +- .../actor/src/pages/actions/RefreshAction.fragment.hbs | 2 +- pom.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java index 5b23ae31..c64b7f6b 100644 --- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java +++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java @@ -99,7 +99,7 @@ public static String getContainerOwnActionReturnType(ActionDefinition actionDefi // {{ classDataName container.dataElement 'Stored' }}{{# if container.table }}[]{{/ if }} return "JudoRestResponse<" + classDataName((ClassType) container.getDataElement(), "Stored") + (container.isTable() ? "[]" : "") + ">"; } else if (actionDefinition.getIsPreFetchAction()) { - return "JudoRestResponse<" + classDataName(actionDefinition.getTargetType(), "Stored") + ">"; + return "JudoRestResponse<" + classDataName(actionDefinition.getTargetType(), "Stored") + " | null>"; } else if (actionDefinition.getIsGetTemplateAction()) { return "JudoRestResponse<" + classDataName(actionDefinition.getTargetType(), "") + ">"; } @@ -207,7 +207,7 @@ public static String linkActionDefinitionResponseType(Link link, ActionDefinitio } else if (actionDefinition.getIsOpenSelectorAction()) { return classDataName(((ReferenceType) link.getDataElement()).getTarget(), "Stored") + " | undefined"; } else if (actionDefinition.getIsRefreshAction()) { - return "JudoRestResponse<" + classDataName(((ReferenceType) link.getDataElement()).getTarget(), "Stored") + ">"; + return "JudoRestResponse<" + classDataName(((ReferenceType) link.getDataElement()).getTarget(), "Stored") + " | null>"; } return "void"; } diff --git a/judo-ui-react/src/main/resources/actor/src/components/widgets/AssociationButton.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/components/widgets/AssociationButton.tsx.hbs index ef44afe3..1a758f2c 100644 --- a/judo-ui-react/src/main/resources/actor/src/components/widgets/AssociationButton.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/components/widgets/AssociationButton.tsx.hbs @@ -16,7 +16,7 @@ export interface AssociationBaseProps { export interface AssociationButtonProps extends AssociationBaseProps { refreshCounter: number; - fetchCall?: () => Promise>>; + fetchCall?: () => Promise | null>>; navigateAction?: (target?: JudoIdentifiable | any) => Promise; children?: ReactNode; } @@ -31,7 +31,7 @@ export function AssociationButton({ children, }: AssociationButtonProps) { const { t } = useTranslation(); - const [data, setData] = useState | undefined>(); + const [data, setData] = useState | null>(null); const [isLoading, setIsLoading] = useState(false); useEffect(() => { @@ -44,7 +44,7 @@ export function AssociationButton({ setData(res); } catch (e) { - setData(undefined); + setData(null); console.error(e); } finally { setIsLoading(false); diff --git a/judo-ui-react/src/main/resources/actor/src/pages/actions/PreFetchAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/actions/PreFetchAction.fragment.hbs index c41bc5a9..4b33255f 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/actions/PreFetchAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/actions/PreFetchAction.fragment.hbs @@ -1,4 +1,4 @@ -const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promise> => { +const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promise> => { return {{ getServiceImplForPage page }}.get{{ firstToUpper action.targetDataElement.name }}({{# if (pageHasSignedId page) }}{{# if page.openInDialog }}data{{ else }}{ __signedIdentifier: signedIdentifier } as any{{/ if }}{{ else }}data{{/ if }}, { _mask: '{}', }); diff --git a/judo-ui-react/src/main/resources/actor/src/pages/actions/RefreshAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/actions/RefreshAction.fragment.hbs index c8021c58..f9202b33 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/actions/RefreshAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/actions/RefreshAction.fragment.hbs @@ -1,5 +1,5 @@ {{# if action.targetDataElement }} -const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCustomizer: {{ classDataName action.targetDataElement.target 'QueryCustomizer' }}): Promise> => { +const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCustomizer: {{ classDataName action.targetDataElement.target 'QueryCustomizer' }}): Promise> => { const result = await {{ getServiceImplForPage page }}.{{# if action.targetDataElement.isCollection }}list{{ else }}get{{/ if }}{{ firstToUpper action.targetDataElement.name }}({{{ refreshActionDataParameter action }}}, queryCustomizer{{# with (getTableParentForActionDefinition action.actionDefinition) as |table| }}{{# if table.showTotalCount }}, { [X_JUDO_COUNT_RECORDS]: 'true' }{{/ if }}{{/ with }}); {{# if page.container.view }} {{# if (isRefreshPageInitializer action page) }} diff --git a/pom.xml b/pom.xml index a1bb76c1..7f63a95f 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 1.1.0.20240604_105835_a46ed24f_develop 1.0.0.20231009_184136_321053b3_develop - 1.0.0.20240610_201205_f6f4ea61_feature_JNG_5742_eager_relations + 1.0.0.20240612_165732_227581db_bugfix_JNG_5767_handle_missing_single_association 3.0.0-M7