diff --git a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model index 37d721ab..5afe53ad 100644 --- a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model +++ b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model @@ -3,16 +3,16 @@ - + - + - + - + @@ -20,15 +20,15 @@ - - - - + - + + - + + + @@ -37,37 +37,37 @@ - - - - - - + + + + + + - - - - - + + + + + - - + + @@ -78,15 +78,15 @@ - - - - + - + + - + + + @@ -129,9 +129,9 @@ - - + + @@ -172,18 +172,18 @@ + - + - @@ -195,6 +195,11 @@ + + + + + @@ -205,11 +210,6 @@ - - - - - @@ -222,18 +222,18 @@ - - + + - - + + @@ -254,15 +254,15 @@ - - - - + - + + - + + + @@ -296,17 +296,17 @@ - + - - + + - - + + LIST @@ -374,28 +374,28 @@ View - - + + + REFRESH + UPDATE + DELETE + + + - - - - - - - - - REFRESH - UPDATE - DELETE - + + + + + + LIST @@ -420,14 +420,14 @@ View - - + + - - + + LIST @@ -649,41 +649,41 @@ - + - + - + - + - + - + - + - + - + - + @@ -692,91 +692,91 @@ - + - + - + - + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - - - + + + @@ -786,128 +786,90 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -922,41 +884,79 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - - + + - + - + @@ -964,99 +964,99 @@ - + - + - - - - - + + + + + - - + + - - + + - - + + - - - - + + + + - - - + + + - - - - + + + + - - - + + + - + - + - + - + - + - + - + - + - + - + - + @@ -1064,7 +1064,7 @@ - + @@ -1075,15 +1075,15 @@ - + - + - + @@ -1092,24 +1092,24 @@ - + - + - - + + - - + + - + - + @@ -1117,11 +1117,11 @@ - + - + @@ -1129,116 +1129,116 @@ - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + + + + + - + + + + + - + - - - - - - - + + + - + - - - - - - - + + + - - - + + + @@ -1246,64 +1246,64 @@ - + - + - + - + - - - + + + - - - - + + + + - - - - + + + + - + - + - + - + - + - + @@ -1311,27 +1311,27 @@ - + - + - + - + - + - + @@ -1339,101 +1339,101 @@ - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - - - + + + @@ -1441,19 +1441,19 @@ - + - + - + - + @@ -1461,16 +1461,16 @@ - + - + - + @@ -1478,16 +1478,16 @@ - + - + - + @@ -1495,19 +1495,19 @@ - + - + - + - + @@ -1516,58 +1516,58 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -1575,7 +1575,7 @@ - + @@ -1584,24 +1584,24 @@ - + - + - - + + - - + + - + - + @@ -1609,11 +1609,11 @@ - + - + @@ -1623,120 +1623,120 @@ - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + + + + + - + - + - - - - - + @@ -1744,190 +1744,190 @@ - - - + + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1935,10 +1935,10 @@ - + - + @@ -1949,49 +1949,49 @@ - + - + + + + + - + - + - - - - - + - + - - + + - - + + - + - + @@ -1999,11 +1999,11 @@ - + - + @@ -2012,78 +2012,78 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - - - + + + - + @@ -2091,53 +2091,53 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2145,48 +2145,48 @@ - + - + - - - + + + - - - - + + + + - - - - + + + + - + - + - + - + @@ -2194,24 +2194,24 @@ - + - + - + - + - + @@ -2219,10 +2219,10 @@ - + - + @@ -2233,11 +2233,11 @@ - + - + @@ -2245,101 +2245,101 @@ - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - - - + + + @@ -2347,11 +2347,11 @@ - + - + @@ -2360,49 +2360,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -2410,7 +2410,7 @@ - + @@ -2419,52 +2419,52 @@ - + - - + + - + - + - + - + - + - + - + - + - + - + @@ -2472,7 +2472,7 @@ - + @@ -2481,115 +2481,115 @@ - + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + + + + + + - + + + + + - + - - - - - - - + + + - + - - - - - - - + + + - - - - + + + - + @@ -2600,7 +2600,7 @@ - + @@ -2609,58 +2609,58 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -2668,7 +2668,7 @@ - + @@ -2677,52 +2677,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -2730,7 +2730,7 @@ - + @@ -2739,58 +2739,58 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -2798,7 +2798,7 @@ - + @@ -2806,38 +2806,38 @@ - + - + - + - + - + - + - + - - + + @@ -2846,9 +2846,9 @@ + - 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 d1d72d01..3cbf03cf 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 @@ -29,6 +29,7 @@ import java.util.List; import java.util.stream.Collectors; +import static hu.blackbelt.judo.ui.generator.react.UiWidgetHelper.collectVisualElementsMatchingCondition; import static hu.blackbelt.judo.ui.generator.react.UiWidgetHelper.getReferenceClassType; import static hu.blackbelt.judo.ui.generator.typescript.rest.commons.UiCommonsHelper.*; import static java.util.Arrays.stream; @@ -644,15 +645,15 @@ public static boolean pageShouldInitialize(PageDefinition pageDefinition) { // public static boolean pageShouldOpenInDialog(PageDefinition pageDefinition) { // return pageDefinition.isOpenInDialog(); // } -// -// public static boolean hasPageRequiredBy(PageDefinition pageDefinition) { -// return !(getRequiredByWidgetsForPage(pageDefinition).isEmpty()); -// } -// -// public static List getRequiredByWidgetsForPage(PageDefinition pageDefinition) { -// Set elements = new LinkedHashSet<>(); -// collectVisualElementsMatchingCondition(pageDefinition.getOriginalPageContainer(), (element) -> element.getRequiredBy() != null, elements); -// -// return elements.stream().sorted(Comparator.comparing(NamedElement::getFQName)).collect(Collectors.toList()); -// } + + public static boolean hasPageRequiredBy(PageDefinition pageDefinition) { + return !(getRequiredByWidgetsForPage(pageDefinition).isEmpty()); + } + + public static List getRequiredByWidgetsForPage(PageDefinition pageDefinition) { + Set elements = new LinkedHashSet<>(); + collectVisualElementsMatchingCondition(pageDefinition.getContainer(), (element) -> element.getRequiredBy() != null, elements); + + return elements.stream().sorted(Comparator.comparing(NamedElement::getFQName)).collect(Collectors.toList()); + } } diff --git a/judo-ui-react/src/main/resources/actor/src/fragments/page/local-validate.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/fragments/page/local-validate.fragment.hbs index f8c8f4e6..98d17e94 100644 --- a/judo-ui-react/src/main/resources/actor/src/fragments/page/local-validate.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/fragments/page/local-validate.fragment.hbs @@ -5,7 +5,7 @@ const requiredByRecord: Record = { {{/ each }} }; -const result = passesLocalValidation<{{ classDataName page.dataElement.target '' }}>(data, requiredByRecord, t, setValidation); +const result = passesLocalValidation<{{ classDataName (getReferenceClassType page) '' }}>(data, requiredByRecord, t, setValidation); if (!result) { return; 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 c7b69e12..9c480452 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 @@ -1,5 +1,4 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCustomizer: {{ classDataName (getReferenceClassType page) 'QueryCustomizer' }}): Promise<{{ classDataName (getReferenceClassType page) 'Stored' }}{{# if page.container.table }}[]{{/ if }}> => { - // alert('RefreshAction'); try { setIsLoading(true); setEditMode(false); diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/UpdateAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/UpdateAction.fragment.hbs index 2fd858fa..d6eec8ee 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/UpdateAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/UpdateAction.fragment.hbs @@ -1,3 +1,27 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => { - alert('UpdateAction'); + {{# if (hasPageRequiredBy page) }} + {{> actor/src/fragments/page/local-validate.fragment.hbs }} + {{/ if }} + + setIsLoading(true); + + try { + const res = await {{ getServiceImplForPage page }}.update({{# unless page.dataElement.isAccess }}{ __signedIdentifier: signedIdentifier! }, {{/ unless }}payloadDiff.current); + + if (res) { + enqueueSnackbar(t('judo.action.save.success', { defaultValue: 'Changes saved' }), { + variant: 'success', + ...toastConfig.success, + }); + setValidation(new Map()); + {{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }} + await actions.{{ simpleActionDefinitionName actionDefinition }}!(pageQueryCustomizer); + {{/ with }} + setEditMode(false); + } + } catch (error) { + handleUpdateError(error, { setValidation }, data); + } finally { + setIsLoading(false); + } }; 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 4f90f98e..62f1ebed 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 @@ -6,12 +6,20 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' import type { JudoIdentifiable } from '@judo/data-api-common'; import { useTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; + import { useSnackbar } from 'notistack'; {{# if page.container.table }} import type { GridFilterModel } from '@mui/x-data-grid{{ getMUIDataGridPlanSuffix }}'; import type { Filter } from '~/components-api'; {{/ if }} import { useJudoNavigation } from '~/components'; - import { uiDateToServiceDate, uiTimeToServiceTime, useErrorHandler, ERROR_PROCESSOR_HOOK_INTERFACE_KEY } from '~/utilities'; + import { toastConfig } from '~/config'; + import { + passesLocalValidation, + uiDateToServiceDate, + uiTimeToServiceTime, + useErrorHandler, + ERROR_PROCESSOR_HOOK_INTERFACE_KEY, + } from '~/utilities'; import { PageContainerTransition } from '~/theme/animations'; {{# each (getRelatedPages page) as |relatedPage| }} import { routeTo{{ pageName relatedPage }} } from '~/routes'; @@ -40,8 +48,15 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' export default function {{ pageName page }}() { {{# unless (containerIsEmptyDashboard page.container) }} const { t } = useTranslation(); + const { enqueueSnackbar } = useSnackbar(); const { navigate, back } = useJudoNavigation(); const handleFetchError = useErrorHandler(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Fetch))`); + {{# if page.dataElement.isUpdatable }} + const handleUpdateError = useErrorHandler<{{ classDataName (getReferenceClassType page) '' }}>(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Update)(component={{ pageName page }}))`); + {{/ if }} + {{# if page.dataElement.isDeletable }} + const handleDeleteError = useErrorHandler<{{ classDataName (getReferenceClassType page) '' }}>(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Delete)(component={{ pageName page }}))`); + {{/ if }} {{# if (pageHasSignedId page) }} const { signedIdentifier } = useParams(); {{/ if }} diff --git a/pom.xml b/pom.xml index 95e997fa..08bb64d9 100644 --- a/pom.xml +++ b/pom.xml @@ -55,9 +55,9 @@ 18.14.2 8.5.1 - 1.1.0-SNAPSHOT + 1.1.0.20231011_143440_62adaf9c_feature_JNG_4838_SeparatePageContainerAndDefinition 1.0.0.20230826_230139_c0dd2610_develop - 1.0.0.20231010_135708_f916574d_feature_JNG_4838_SeparatePageContainerAndDefinition + 1.0.0.20231011_153046_1afebe97_feature_JNG_4838_SeparatePageContainerAndDefinition 3.0.0-M7