From a3117f9697fe3bde60befa0cbd0017ce371f61f1 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Fri, 5 Jan 2024 18:36:01 +0100 Subject: [PATCH] JNG-5395 manual operation template data override --- .../blackbelt/judo/ui/generator/react/UiActionsHelper.java | 4 +++- .../src/main/resources/actor/src/dialogs/index.tsx.hbs | 6 +++++- .../actor/src/pages/actions/GetTemplateAction.fragment.hbs | 6 ++++++ .../actor/src/pages/actions/OpenFormAction.fragment.hbs | 2 +- 4 files changed, 15 insertions(+), 3 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 15dcb2d9..8a55985f 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 @@ -206,7 +206,9 @@ public static String getServiceMethodSuffix(Action action) { public static String getDialogOpenParameters(PageDefinition pageDefinition) { List result = new ArrayList<>(); result.add("ownerData: any"); - if (pageDefinition.getContainer().isIsRelationSelector()) { + if (!pageDefinition.getContainer().isIsSelector()) { + result.add("templateDataOverride?: " + classDataName(getReferenceClassType(pageDefinition), "")); + } else if (pageDefinition.getContainer().isIsRelationSelector()) { result.add("alreadySelected: " + classDataName(getReferenceClassType(pageDefinition), "Stored") + "[]"); } return String.join(", ", result); diff --git a/judo-ui-react/src/main/resources/actor/src/dialogs/index.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/dialogs/index.tsx.hbs index 7d3d98f5..ade6f7e8 100644 --- a/judo-ui-react/src/main/resources/actor/src/dialogs/index.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/dialogs/index.tsx.hbs @@ -103,6 +103,9 @@ import { {{# unless page.container.table }}useCallback, useEffect, useRef, {{/ u {{# if page.container.isRelationSelector}} alreadySelected={alreadySelected} {{/ if }} + {{# unless page.container.isSelector }} + templateDataOverride={templateDataOverride} + {{/ unless }} onClose={async () => { await closeDialog(); resolve({ @@ -135,6 +138,7 @@ import { {{# unless page.container.table }}useCallback, useEffect, useRef, {{/ u export interface {{ pageName page }}Props { ownerData: any; {{# if page.container.isRelationSelector }}alreadySelected: {{ classDataName (getReferenceClassType page) 'Stored' }}[]{{/ if }} + {{# unless page.container.isSelector }}templateDataOverride?: {{ classDataName (getReferenceClassType page) '' }}{{/ unless }} onClose: () => Promise; {{# if (pageHasOutputTarget page) }} onSubmit: (result?: {{ classDataName (getPageOutputTarget page) 'Stored' }}) => Promise; @@ -146,7 +150,7 @@ export interface {{ pageName page }}Props { // XMIID: {{ getXMIID page }} // Name: {{ page.name }} export default function {{ pageName page }}(props: {{ pageName page }}Props) { - const { ownerData, {{# if page.container.isRelationSelector }}alreadySelected, {{/ if }}onClose, onSubmit } = props; + const { ownerData, {{# if page.container.isRelationSelector }}alreadySelected, {{/ if }}{{# unless page.container.isSelector }}templateDataOverride, {{/ unless }}onClose, onSubmit } = props; {{# unless (containerIsEmptyDashboard page.container) }} // Services diff --git a/judo-ui-react/src/main/resources/actor/src/pages/actions/GetTemplateAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/actions/GetTemplateAction.fragment.hbs index 876673ff..226556a9 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/actions/GetTemplateAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/actions/GetTemplateAction.fragment.hbs @@ -9,6 +9,12 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promi if (customActions?.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}) { await customActions.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}(ownerData, result, storeDiff); } + if (templateDataOverride) { + setData((prevData) => ({ ...prevData, ...templateDataOverride })); + payloadDiff.current = { + ...(templateDataOverride as Record), + }; + } return result; } catch (error) { handleError(error); diff --git a/judo-ui-react/src/main/resources/actor/src/pages/actions/OpenFormAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/actions/OpenFormAction.fragment.hbs index 764884e8..a6cb7f80 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/actions/OpenFormAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/actions/OpenFormAction.fragment.hbs @@ -1,4 +1,4 @@ -const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if action.actionDefinition.targetType }}target: {{ classDataName action.actionDefinition.targetType 'Stored' }}{{/ if}}) => { +const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if action.actionDefinition.targetType }}target: {{ classDataName action.actionDefinition.targetType 'Stored' }}, templateDataOverride?: {{ classDataName action.actionDefinition.targetType '' }}{{/ if}}) => { const { result, data: returnedData } = await open{{ pageName action.targetPageDefinition }}({{# if action.actionDefinition.targetType }}target{{ else }}data{{/ if }}); {{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }} {{# if page.container.view }}