diff --git a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model
index 0d87d352..49e7a412 100644
--- a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model
+++ b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model
@@ -39,7 +39,7 @@
-
+
@@ -71,7 +71,7 @@
-
+
@@ -118,7 +118,7 @@
-
+
@@ -213,7 +213,7 @@
-
+
@@ -245,7 +245,7 @@
-
+
@@ -347,7 +347,7 @@
-
+
@@ -424,6 +424,7 @@
CREATE
VALIDATE_CREATE
REFRESH
+ EXPORT
UPDATE
VALIDATE_UPDATE
DELETE
@@ -553,6 +554,7 @@
CREATE
VALIDATE_CREATE
REFRESH
+ EXPORT
UPDATE
VALIDATE_UPDATE
DELETE
@@ -2007,6 +2009,7 @@
+
@@ -2714,6 +2717,7 @@
+
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 dd1a7f13..1112be20 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
@@ -70,6 +70,8 @@ public static String getContainerOwnActionParameters(ActionDefinition actionDefi
// queryCustomizer: {{ classDataName container.dataElement 'QueryCustomizer' }}
if (actionDefinition.getIsRefreshAction()) {
res += "queryCustomizer: " + classDataName((ClassType) container.getDataElement(), "QueryCustomizer");
+ } else if (actionDefinition.getIsCreateAction()) {
+ res += "openCreated?: boolean";
} else if (actionDefinition.getTargetType() != null) {
String targetName = classDataName(actionDefinition.getTargetType(), "Stored");
if (container.isIsRelationSelector()) {
@@ -345,6 +347,7 @@ public static String postCreateActionParams(PageDefinition page, ActionDefinitio
tokens.add("res: " + type);
tokens.add("onSubmit: (result?: " + type + ") => Promise");
tokens.add("onClose: () => Promise");
+ tokens.add("openCreated?: boolean");
return String.join(", ", tokens);
}
diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageContainerHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageContainerHelper.java
index 78039736..a613f77c 100644
--- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageContainerHelper.java
+++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageContainerHelper.java
@@ -271,4 +271,19 @@ public static List getInputsForContainer(PageContainer container) {
public static List getLinksForContainer(PageContainer container) {
return container.getLinks().stream().map(e -> ((Link) e)).sorted(Comparator.comparing(NamedElement::getFQName)).collect(Collectors.toList());
}
+
+ public static boolean containerHasCreateAction(PageContainer container) {
+ return container.getActionButtonGroup() != null && container.getActionButtonGroup().getButtons().stream()
+ .anyMatch(b -> b.getActionDefinition() instanceof CreateActionDefinition);
+ }
+
+ public static ActionDefinition getCreateActionDefinitionForCreateContainer(PageContainer container) {
+ if (container.getActionButtonGroup() != null) {
+ container.getActionButtonGroup().getButtons().stream()
+ .map(Button::getActionDefinition)
+ .filter(actionDefinition -> actionDefinition instanceof CreateActionDefinition)
+ .findFirst().orElse(null);
+ }
+ return null;
+ }
}
diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java
index 4523365c..ed2b26c8 100644
--- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java
+++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java
@@ -240,6 +240,16 @@ && getActionOperationOutputClassType(a).isIsMapped()
for (Action action: actionsForMappedNavigation) {
res.add(action.getTargetPageDefinition());
}
+ List actionsForCreateAndNavigate = pageDefinition.getActions()
+ .stream()
+ .filter(a -> a.getIsCreateAction()
+ && a.getTargetPageDefinition() != null
+ && !a.getTargetPageDefinition().isOpenInDialog()
+ )
+ .toList();
+ for (Action action: actionsForCreateAndNavigate) {
+ res.add(action.getTargetPageDefinition());
+ }
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/judo-ui-react/src/main/resources/actor/src/containers/dialog.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/containers/dialog.tsx.hbs
index f188588d..2cec9856 100644
--- a/judo-ui-react/src/main/resources/actor/src/containers/dialog.tsx.hbs
+++ b/judo-ui-react/src/main/resources/actor/src/containers/dialog.tsx.hbs
@@ -1,6 +1,6 @@
{{> fragment.header.hbs }}
-import { lazy, Suspense } from 'react';
+import { lazy, Suspense{{# if (containerHasCreateAction container) }}, useRef, useState, useCallback{{/ if }} } from 'react';
import type { Dispatch, SetStateAction } from 'react';
import Grid from '@mui/material/Grid';
import Button from '@mui/material/Button';
@@ -9,6 +9,15 @@ import IconButton from '@mui/material/IconButton';
import DialogContent from '@mui/material/DialogContent';
import DialogActions from '@mui/material/DialogActions';
import LoadingButton from '@mui/lab/LoadingButton';
+{{# if (containerHasCreateAction container) }}
+import ButtonGroup from '@mui/material/ButtonGroup';
+import Popper from '@mui/material/Popper';
+import Grow from '@mui/material/Grow';
+import Paper from '@mui/material/Paper';
+import MenuList from '@mui/material/MenuList';
+import MenuItem from '@mui/material/MenuItem';
+import ClickAwayListener from '@mui/material/ClickAwayListener';
+{{/ if }}
import { useTranslation } from 'react-i18next';
import { useJudoNavigation, MdiIcon } from '~/components';
import { useConfirmDialog } from '~/components/dialog';
@@ -67,6 +76,10 @@ export default function {{ containerComponentName container }}Dialog(props: {{ c
{{# unless (containerIsEmptyDashboard container) }}
const { t } = useTranslation();
const { navigate, back } = useJudoNavigation();
+ {{# if (containerHasCreateAction container) }}
+ const [isCreateDropdownOpen, setIsCreateDropdownOpen] = useState(false);
+ const createDropdownRef = useRef(null);
+ {{/ if }}
const {
ownerData,
onClose
@@ -99,6 +112,16 @@ export default function {{ containerComponentName container }}Dialog(props: {{ c
_mask: {{# unless container.form }}actions.getMask ? actions.getMask!() : {{/ unless }}'{{ getMaskForView container }}',
};
{{/ unless }}
+
+ {{# if (containerHasCreateAction container) }}
+ const handleCreateDropdownToggle = useCallback(() => {
+ setIsCreateDropdownOpen((prevOpen) => !prevOpen);
+ }, [isCreateDropdownOpen]);
+ const handleCreateDropdownClose = useCallback(() => {
+ setIsCreateDropdownOpen(false);
+ }, [isCreateDropdownOpen]);
+ {{/ if }}
+
{{/ unless }}
return (
@@ -151,6 +174,9 @@ export default function {{ containerComponentName container }}Dialog(props: {{ c
{{# each container.actionButtonGroup.buttons as |button| }}
{ {{ containerButtonAvailable button }} && actions.{{ simpleActionDefinitionName actionDefinition }} && (
+ {{# if button.actionDefinition.isCreateAction }}
+
+ {{/ if }}
{t('{{ getTranslationKeyForVisualElement button }}', { defaultValue: '{{ button.label }}' })}
{{/ if }}
+ {{# if button.actionDefinition.isCreateAction }}
+ {!isDraft && }
+
+
+ {({ TransitionProps, placement }) => (
+
+
+
+
+
+
+
+ )}
+
+ {{/ if }}
)}
{{/ each }}
diff --git a/judo-ui-react/src/main/resources/actor/src/pages/actions/CreateAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/actions/CreateAction.fragment.hbs
index f5c14841..d7154331 100644
--- a/judo-ui-react/src/main/resources/actor/src/pages/actions/CreateAction.fragment.hbs
+++ b/judo-ui-react/src/main/resources/actor/src/pages/actions/CreateAction.fragment.hbs
@@ -1,4 +1,4 @@
-const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
+const {{ simpleActionDefinitionName action.actionDefinition }} = async (openCreated?: boolean) => {
try {
{{# unless page.dataElement.isAccess }}
if (isDraft) {
@@ -24,10 +24,19 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
const payload: typeof payloadDiff.current = cleanUpPayload(payloadDiff.current);
const res = await {{ getServiceImplForPage page }}.create{{# if action.targetDataElement }}{{ firstToUpper action.targetDataElement.name }}{{/ if }}({{# unless action.ownerDataElement.isAccess }}ownerData, {{/ unless }}payload);
if (customActions?.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}) {
- await customActions.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}(data, res, onSubmit, onClose);
+ await customActions.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}(data, res, onSubmit, onClose, openCreated);
} else {
showSuccessSnack(t('judo.action.create.success', { defaultValue: 'Create successful' }));
- onSubmit(res);
+ await onSubmit(res);
+ if (openCreated) {
+ {{# if action.targetPageDefinition }}
+ {{# if action.targetPageDefinition.openInDialog }}
+ await open{{ pageName action.targetPageDefinition }}(res!);
+ {{ else }}
+ navigate(routeTo{{ pageName action.targetPageDefinition }}({{# if (pageHasSignedId action.targetPageDefinition) }}res!.__signedIdentifier{{/ if }}));
+ {{/ if }}
+ {{/ if }}
+ }
}
} catch (error) {
handleError<{{ classDataName (getReferenceClassType page) '' }}>(error, { setValidation }, data);
diff --git a/pom.xml b/pom.xml
index 0957aede..40af6b82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,7 @@
18.14.2
8.9.2
- 1.1.0.20240125_185516_95f13be8_develop
+ 1.1.0.20240129_105729_b9325619_develop
1.0.0.20231009_184136_321053b3_develop
1.0.0.20240125_123625_72e1a464_feature_JNG_5152_nested_create