From 8508c0f8b73ff8363f571873270bdd7235fb2920 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Thu, 26 Oct 2023 17:08:52 +0200 Subject: [PATCH] JNG-4838 add singleton access page --- .../v2/actions/RefreshAction.fragment.hbs | 17 +++++++++++++- .../actor/src/pages/v2/index.tsx.hbs | 23 ++++++++++++++++++- pom.xml | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/RefreshAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/RefreshAction.fragment.hbs index f1c34112..973d823e 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/RefreshAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/RefreshAction.fragment.hbs @@ -5,7 +5,22 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCus {{# if page.container.table }} return {{ getServiceImplForPage page }}.list({{# if (pageHasSignedId page) }}{{# if page.openInDialog }}data{{ else }}{ __signedIdentifier: signedIdentifier } as JudoIdentifiable{{/ if }}{{ else }}undefined{{/ if }}, queryCustomizer); {{ else }} - const result = await {{ getServiceImplForPage page }}.refresh({{# if (pageHasSignedId page) }}{{# if page.openInDialog }}targetData{{ else }}{ __signedIdentifier: signedIdentifier } as JudoIdentifiable{{/ if }}{{ else }}undefined{{/ if }}, pageQueryCustomizer); + const result = await {{ getServiceImplForPage page }}.refresh( + {{# if (pageHasSignedId page) }} + {{# if page.openInDialog }} + targetData + {{ else }} + { __signedIdentifier: signedIdentifier } as JudoIdentifiable + {{/ if }} + {{ else }} + {{# if (isSingleAccessPage page) }} + singletonHost.current + {{ else }} + undefined + {{/ if }} + {{/ if }}, + pageQueryCustomizer + ); setData(result); diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/index.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/index.tsx.hbs index da77e692..b0bc6e54 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/index.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/index.tsx.hbs @@ -78,6 +78,9 @@ export default function {{ pageName page }}() { const [validation, setValidation] = useState>(new Map()); // Ref section + {{# if (isSingleAccessPage page) }} + const singletonHost = useRef<{ __signedIdentifier: string }>({} as unknown as { __signedIdentifier: string }); + {{/ if }} const payloadDiff = useRef>({} as unknown as Record); // Callback section @@ -123,6 +126,13 @@ export default function {{ pageName page }}() { {{# each page.actions as |action| }} {{> (getActionTemplate action) }} {{/ each }} + {{# if (isSingleAccessPage page) }} + const getSingletonPayload = async (): Promise> => { + return await {{ getServiceImplForPage page }}.refreshFor{{ firstToUpper page.dataElement.name }}({ + _mask: '{}', + }); + } + {{/ if }} const actions: {{ containerComponentName page.container }}PageActions = { {{# each page.actions as |action| }} @@ -133,7 +143,18 @@ export default function {{ pageName page }}() { // Effect section {{# if (pageShouldInitialize page) }} useEffect(() => { - actions.{{ simpleActionDefinitionName page.container.onInit }}!({{# if page.container.view }}pageQueryCustomizer{{/ if }}); + (async () => { + {{# if (isSingleAccessPage page) }} + const res = await getSingletonPayload(); + if (res?.__signedIdentifier) { + singletonHost.current = res; + } else { + navigate('*'); + return; + } + {{/ if }} + await actions.{{ simpleActionDefinitionName page.container.onInit }}!({{# if page.container.view }}pageQueryCustomizer{{/ if }}); + })(); }, []); {{/ if }} {{/ unless }} diff --git a/pom.xml b/pom.xml index 98b38073..99b0066a 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 1.1.0.20231024_175354_d92dd516_feature_JNG_4838_SeparatePageContainerAndDefinition 1.0.0.20230826_230139_c0dd2610_develop - 1.0.0.20231020_233253_3788a60f_feature_JNG_4838_SeparatePageContainerAndDefinition + 1.0.0.20231026_150611_b39a761b_feature_JNG_4838_SeparatePageContainerAndDefinition 3.0.0-M7