From 073d365bc3af561b5c36833e2330f0c9364bf732 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Fri, 27 Oct 2023 14:04:53 +0200 Subject: [PATCH] JNG-4838 fix row operation calls, simplify error handling --- .../model/ActionGroupTest-ui.model | 1524 ++++++++--------- .../ui/generator/react/UiActionsHelper.java | 35 +- .../src/components/dialog/RangeDialog.tsx.hbs | 5 +- .../src/containers/components/table.tsx.hbs | 5 +- .../resources/actor/src/dialogs/index.tsx.hbs | 16 +- .../AutocompleteRangeAction.fragment.hbs | 4 +- .../actions/CallOperationAction.fragment.hbs | 8 +- .../v2/actions/CreateAction.fragment.hbs | 2 +- .../v2/actions/DeleteAction.fragment.hbs | 6 +- .../v2/actions/GetTemplateAction.fragment.hbs | 6 +- .../v2/actions/OpenFormAction.fragment.hbs | 4 +- .../v2/actions/RefreshAction.fragment.hbs | 8 +- .../actions/SelectorRangeAction.fragment.hbs | 4 +- .../v2/actions/UpdateAction.fragment.hbs | 2 +- .../actor/src/pages/v2/index.tsx.hbs | 7 +- .../actor/src/utilities/error-handling.ts.hbs | 27 +- 16 files changed, 830 insertions(+), 833 deletions(-) diff --git a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model index b992a9c6..760aae88 100644 --- a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model +++ b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model @@ -1,18 +1,18 @@ - + - + - + - + - + @@ -21,15 +21,15 @@ + + + + + + - - - - - - @@ -39,18 +39,6 @@ - - - - - - - - - - - - @@ -62,15 +50,27 @@ + + + + + + + + + + + + + - @@ -82,15 +82,15 @@ + + + + + + - - - - - - @@ -143,9 +143,9 @@ + - @@ -183,9 +183,9 @@ - + @@ -193,10 +193,9 @@ - - + @@ -208,11 +207,7 @@ - - - - - + @@ -224,6 +219,11 @@ + + + + + @@ -250,9 +250,9 @@ + - @@ -260,9 +260,9 @@ + - @@ -290,15 +290,15 @@ + + + + + + - - - - - - @@ -318,9 +318,9 @@ + - @@ -393,18 +393,13 @@ View - - - - - - - - + - + + + REFRESH @@ -412,10 +407,15 @@ DELETE - - - + + + + + + + + LIST SET @@ -439,15 +439,15 @@ View + + + - - - LIST SET @@ -668,41 +668,41 @@ - + - + - + - + - + - + - + - + - + - + @@ -711,92 +711,92 @@ - + - + - + - + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + + + + + - - + + - + - - - - @@ -805,170 +805,94 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -983,15 +907,15 @@ - + - + - + @@ -1001,24 +925,24 @@ - + - + - - + + - - + + - + - + @@ -1026,66 +950,142 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1093,7 +1093,7 @@ - + @@ -1104,15 +1104,15 @@ - + - + - + @@ -1122,24 +1122,24 @@ - + - + - - + + - - + + - + - + @@ -1147,11 +1147,11 @@ - + - + @@ -1159,116 +1159,116 @@ - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - - + + + - - - + + + - - - + + + - - - + + + - + - - - + + + - - - + + + - - - + + + + + + + @@ -1276,23 +1276,23 @@ - + - + - + - + - + @@ -1300,16 +1300,16 @@ - + - + - + @@ -1317,49 +1317,49 @@ - - - + + + - - - - + + + + - - - - + + + + - + - + - + - + - + - + - + @@ -1367,31 +1367,31 @@ - + - + - + - + - + - + - + @@ -1399,125 +1399,125 @@ - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + + + + + - - + + - + - - - - - + - + - + - + - + @@ -1525,16 +1525,16 @@ - + - + - + @@ -1543,19 +1543,19 @@ - + - + - + - + @@ -1565,58 +1565,58 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -1624,7 +1624,7 @@ - + @@ -1633,24 +1633,24 @@ - + - + - - + + - - + + - + - + @@ -1658,11 +1658,11 @@ - + - + @@ -1672,120 +1672,120 @@ - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - + + - - + + + + + + - + @@ -1793,195 +1793,195 @@ - - - + + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1989,10 +1989,10 @@ - + - + @@ -2003,25 +2003,25 @@ - + - + - - - - - + - + + + + + @@ -2029,24 +2029,24 @@ - + - + - - + + - - + + - + - + @@ -2054,11 +2054,11 @@ - + - + @@ -2066,53 +2066,53 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2121,11 +2121,11 @@ - + - + @@ -2135,115 +2135,115 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + + + + + - - + + - + - - - - - + - - - + + + - - - - + + + + - - - - + + + + - + - + - + - + @@ -2252,28 +2252,28 @@ - + - + - + - + - + - + @@ -2281,10 +2281,10 @@ - + - + @@ -2295,11 +2295,11 @@ - + - + @@ -2308,113 +2308,113 @@ - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + + + + + - - + + - + - - - - - + - + @@ -2424,49 +2424,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -2474,7 +2474,7 @@ - + @@ -2483,52 +2483,52 @@ - + - - + + - + - + - + - + - + - + - + - + - + - + @@ -2536,7 +2536,7 @@ - + @@ -2545,115 +2545,115 @@ - + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - + + + - - + + - - - + + + - + - - - + + + - - - + + + + + + + + + + + + + + + - + @@ -2664,7 +2664,7 @@ - + @@ -2673,58 +2673,58 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -2732,7 +2732,7 @@ - + @@ -2741,52 +2741,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -2794,7 +2794,7 @@ - + @@ -2803,58 +2803,58 @@ - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + @@ -2862,7 +2862,7 @@ - + @@ -2870,36 +2870,36 @@ - + - + - + - + - + - + - + - + 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 be199069..93ccb533 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 @@ -194,33 +194,42 @@ public static String getServiceMethodSuffix(Action action) { } public static String getDialogOpenParameters(PageDefinition pageDefinition) { - Set result = new TreeSet<>(); - - if (pageDefinition.getContainer().isView()) { - result.add("targetData: JudoIdentifiable"); - } + List result = new ArrayList<>(); + result.add("ownerData: any"); if (pageDefinition.getContainer().isIsRelationSelector()) { result.add("alreadySelected: " + classDataName(getReferenceClassType(pageDefinition), "Stored") + "[]"); } - return String.join(", ", result); } public static String getSelectorOpenActionParameters(Action action, PageContainer container) { + List tokens = new ArrayList<>(); if (container.isTable()) { - return "[]"; + if (action.getTargetPageDefinition().getContainer().isIsRelationSelector()) { + tokens.add("{ __signedIdentifier: signedIdentifier }"); + } else { + tokens.add("[]"); + } + } else { + tokens.add("data"); } + if (action.getTargetPageDefinition().getContainer().isIsRelationSelector()) { if (action.getTargetDataElement() instanceof RelationType check) { - String result = "data." + check.getName(); - boolean isCollection = check.isIsCollection(); - if (isCollection) { - return result + " ?? []"; + if (container.isTable()) { + tokens.add("[]"); + } else { + String result = "data." + check.getName(); + boolean isCollection = check.isIsCollection(); + if (isCollection) { + tokens.add(result + " ?? []"); + } else { + tokens.add(result + "? [" + result + "] : []"); + } } - return result + "? [" + result + "] : []"; } } - return ""; + return String.join(", ", tokens); } public static boolean isActionAddOrSet(ActionDefinition actionDefinition) { diff --git a/judo-ui-react/src/main/resources/actor/src/components/dialog/RangeDialog.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/components/dialog/RangeDialog.tsx.hbs index 67679391..07bf75b2 100644 --- a/judo-ui-react/src/main/resources/actor/src/components/dialog/RangeDialog.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/components/dialog/RangeDialog.tsx.hbs @@ -26,7 +26,6 @@ import { mapFilterToFilterModel, useErrorHandler, processQueryCustomizer, - ERROR_PROCESSOR_HOOK_INTERFACE_KEY, mapFiltersToQueryCustomizerProperty, isRowSelectable, } from '~/utilities'; @@ -75,7 +74,7 @@ export const RangeDialog = , U extends QueryCustomizer(null); - const handleFetchError = useErrorHandler(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Fetch))`); + const handleError = useErrorHandler(); const { enqueueSnackbar } = useSnackbar(); const [isLoading, setIsLoading] = useState(false); const [rowCount, setRowCount] = useState(0); @@ -129,7 +128,7 @@ export const RangeDialog = , U extends QueryCustomizer>(`(&(${OBJECTCLASS}=${TABLE_ROW_HIGHLIGHTING_HOOK_INTERFACE_KEY})(component={{~ tableComponentName table ~}}))`); @@ -393,7 +392,7 @@ export function {{ tableComponentName table }}(props: {{ tableComponentName tabl setLastItem(res[res.length - 1]); setRowCount(res.length || 0); } catch (error) { - handleFetchError(error); + handleError(error); } finally { setIsLoading(false); } 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 23a97044..b8eb29b8 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 @@ -18,7 +18,6 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' uiDateToServiceDate, uiTimeToServiceTime, useErrorHandler, - ERROR_PROCESSOR_HOOK_INTERFACE_KEY, } from '~/utilities'; import type { DialogResult, @@ -41,7 +40,7 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' {{/ unless }} {{# unless (containerIsEmptyDashboard page.container) }} - export const use{{ pageName page }} = (ownerData: any): ({{{ getDialogOpenParameters page }}}) => Promise{{/ if }}>> => { + export const use{{ pageName page }} = (): ({{{ getDialogOpenParameters page }}}) => Promise{{/ if }}>> => { const [createDialog, closeDialog] = useDialog(); return ({{{ getDialogOpenParameters page }}}) => new Promise((resolve) => { @@ -61,9 +60,6 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' children: ( <{{ pageName page }} ownerData={ownerData} - {{# if page.container.view}} - targetData={targetData} - {{/ if }} {{# if page.container.isRelationSelector}} alreadySelected={alreadySelected} {{/ if }} @@ -96,7 +92,6 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' export interface {{ pageName page }}Props { ownerData: any; - {{# if page.container.view}}targetData: JudoIdentifiable{{/ if }} {{# if page.container.isRelationSelector }}alreadySelected: {{ classDataName (getReferenceClassType page) 'Stored' }}[]{{/ if }} onClose: () => void; onSubmit: (result: {{# if page.container.table }}Array<{{/ if }}{{ classDataName (getReferenceClassType page) 'Stored' }}{{# if page.container.table }}>{{/ if }}) => void; @@ -104,7 +99,7 @@ export interface {{ pageName page }}Props { // Name: {{ page.name }} export default function {{ pageName page }}(props: {{ pageName page }}Props) { - const { ownerData, {{# if page.container.view}}targetData, {{/ if }}{{# if page.container.isRelationSelector }}alreadySelected, {{/ if }}onClose, onSubmit } = props; + const { ownerData, {{# if page.container.isRelationSelector }}alreadySelected, {{/ if }}onClose, onSubmit } = props; {{# unless (containerIsEmptyDashboard page.container) }} // Hooks section @@ -113,10 +108,7 @@ export default function {{ pageName page }}(props: {{ pageName page }}Props) { const { navigate, back } = useJudoNavigation(); const { openFilterDialog } = useFilterDialog(); const { openConfirmDialog } = useConfirmDialog(); - const handleFetchError = useErrorHandler(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Fetch))`); - const handleCreateError = useErrorHandler<{{ classDataName (getReferenceClassType page) '' }}>(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Create)(component={{ pageName page }}))`); - const handleUpdateError = useErrorHandler<{{ classDataName (getReferenceClassType page) '' }}>(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Update)(component={{ pageName page }}))`); - const handleDeleteError = useErrorHandler(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Delete)(component={{ pageName page }}))`); + const handleError = useErrorHandler(); const [createDialog, closeDialog] = useDialog(); // State section @@ -162,7 +154,7 @@ export default function {{ pageName page }}(props: {{ pageName page }}Props) { // Dialog hooks {{# each (getRelatedDialogs page) as |relatedDialog| }} - const open{{ pageName relatedDialog }} = use{{ pageName relatedDialog }}({{# unless page.container.table }}data{{ else }}{}{{/ unless }}); + const open{{ pageName relatedDialog }} = use{{ pageName relatedDialog }}(); {{/ each }} // Calculated section diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/AutocompleteRangeAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/AutocompleteRangeAction.fragment.hbs index cc979bf6..880c3031 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/AutocompleteRangeAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/AutocompleteRangeAction.fragment.hbs @@ -2,8 +2,8 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCus {{# with (getLinkParentForActionDefinition action.actionDefinition) as |link| }} try { return {{ getServiceImplForPage page }}.getRangeFor{{ firstToUpper link.dataElement.name }}(data, queryCustomizer); - } catch (e) { - handleFetchError(e); + } catch (error) { + handleError(error); return Promise.resolve([]); } {{/ with }} diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CallOperationAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CallOperationAction.fragment.hbs index 31986c2a..cc0b6d04 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CallOperationAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CallOperationAction.fragment.hbs @@ -61,8 +61,12 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if a setRefreshCounter((prev) => prev + 1); {{/ if }} {{/ if }} - } catch (e) { - console.error(e); + } catch (error) { + {{# unless page.container.table }} + handleError<{{ classDataName (getReferenceClassType page) '' }}>(error, { setValidation }, data); + {{ else }} + handleError(error); + {{/ unless }} } finally { setIsLoading(false); } diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CreateAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CreateAction.fragment.hbs index 718a54ba..39a0cc09 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CreateAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/CreateAction.fragment.hbs @@ -10,7 +10,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => { onSubmit(res); } catch (error) { - handleCreateError(error, { setValidation }, data); + handleError<{{ classDataName (getReferenceClassType page) '' }}>(error, { setValidation }, data); } finally { setIsLoading(false); } diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/DeleteAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/DeleteAction.fragment.hbs index 3d198e7b..59cb43b9 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/DeleteAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/DeleteAction.fragment.hbs @@ -34,6 +34,10 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if a {{/ if }} } } catch(error) { - handleDeleteError(error, undefined, {{# if action.actionDefinition.targetType }}target{{ else }}data{{/ if }}); + {{# if action.actionDefinition.targetType }} + handleError<{{ classDataName action.actionDefinition.targetType '' }}>(error, undefined, target); + {{ else }} + handleError(error, undefined, data); + {{/ if }} } }; diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/GetTemplateAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/GetTemplateAction.fragment.hbs index 2069be73..de3717b2 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/GetTemplateAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/GetTemplateAction.fragment.hbs @@ -6,9 +6,9 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promi setData(result as {{ classDataName action.actionDefinition.targetType 'Stored' }}); return result; - } catch (e) { - handleFetchError(e); - return Promise.reject(e); + } catch (error) { + handleError(error); + return Promise.reject(error); } finally { setIsLoading(false); } diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/OpenFormAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/OpenFormAction.fragment.hbs index 42b762c1..da3a7d3e 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/OpenFormAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/OpenFormAction.fragment.hbs @@ -1,5 +1,5 @@ -const {{ simpleActionDefinitionName action.actionDefinition }} = async () => { - const { result, data: returnedData } = await open{{ pageName action.targetPageDefinition }}(); +const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if action.actionDefinition.targetType }}target: {{ classDataName action.actionDefinition.targetType 'Stored' }}{{/ 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 }} if (!editMode) { 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 973d823e..f06d1bc9 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 @@ -8,7 +8,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCus const result = await {{ getServiceImplForPage page }}.refresh( {{# if (pageHasSignedId page) }} {{# if page.openInDialog }} - targetData + ownerData {{ else }} { __signedIdentifier: signedIdentifier } as JudoIdentifiable {{/ if }} @@ -34,9 +34,9 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCus return result; {{/ if }} - } catch (e) { - handleFetchError(e); - return Promise.reject(e); + } catch (error) { + handleError(error); + return Promise.reject(error); } finally { setIsLoading(false); setRefreshCounter((prevCounter) => prevCounter + 1); diff --git a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/SelectorRangeAction.fragment.hbs b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/SelectorRangeAction.fragment.hbs index d707a9b7..518f81c8 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/SelectorRangeAction.fragment.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/v2/actions/SelectorRangeAction.fragment.hbs @@ -5,8 +5,8 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCus {{ else }} return {{ getServiceImplForPage page }}.getRangeFor{{ firstToUpper action.ownerDataElement.name }}(ownerData, queryCustomizer); {{/ if }} - } catch (e) { - handleFetchError(e); + } catch (error) { + handleError(error); return Promise.resolve([]); } }; 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 83cbcb16..3624a352 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 @@ -20,7 +20,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => { setEditMode(false); } } catch (error) { - handleUpdateError(error, { setValidation }, data); + handleError<{{ classDataName (getReferenceClassType page) '' }}>(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 b0bc6e54..9a421a32 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 @@ -18,7 +18,6 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react' uiDateToServiceDate, uiTimeToServiceTime, useErrorHandler, - ERROR_PROCESSOR_HOOK_INTERFACE_KEY, } from '~/utilities'; import { PageContainerTransition } from '~/theme/animations'; {{# each (getRelatedPages page) as |relatedPage| }} @@ -61,9 +60,7 @@ export default function {{ pageName page }}() { const { navigate, back } = useJudoNavigation(); const { openFilterDialog } = useFilterDialog(); const { openConfirmDialog } = useConfirmDialog(); - const handleFetchError = useErrorHandler(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Fetch))`); - const handleUpdateError = useErrorHandler<{{ classDataName (getReferenceClassType page) '' }}>(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Update)(component={{ pageName page }}))`); - const handleDeleteError = useErrorHandler(`(&(${OBJECTCLASS}=${ERROR_PROCESSOR_HOOK_INTERFACE_KEY})(operation=Delete)(component={{ pageName page }}))`); + const handleError = useErrorHandler(); const [createDialog, closeDialog] = useDialog(); // State section @@ -112,7 +109,7 @@ export default function {{ pageName page }}() { // Dialog hooks {{# each (getRelatedDialogs page) as |relatedDialog| }} - const open{{ pageName relatedDialog }} = use{{ pageName relatedDialog }}({{# if page.container.table }}{{# if (pageHasSignedId page) }}{ __signedIdentifier: signedIdentifier }{{ else }}{}{{/ if }}{{ else }}data{{/ if }}); + const open{{ pageName relatedDialog }} = use{{ pageName relatedDialog }}(); {{/ each }} // Calculated section diff --git a/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs b/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs index 426bbd9d..7727dcbc 100644 --- a/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs +++ b/judo-ui-react/src/main/resources/actor/src/utilities/error-handling.ts.hbs @@ -12,12 +12,6 @@ import { toastConfig } from '../config'; type EnqueueSnackbarCallback = (message: SnackbarMessage, options?: OptionsObject | undefined) => SnackbarKey; export interface ErrorHandlingOption { - - /** - * Duration to use for potential toasts, could be ignored in actual implementations. - */ - duration?: number; - /** * Callback from a component owning the form data used to set error messages on form inputs. Key-value pair is for * form field name and validation error message. Should be called only once per error handler call! @@ -45,9 +39,9 @@ export type ErrorProcessor = (error: any, defaultResults: ErrorProcessResult< export const ERROR_PROCESSOR_HOOK_INTERFACE_KEY = 'ErrorProcessorHook'; -export type ErrorProcessorHook = () => ErrorProcessor; +export type ErrorProcessorHook = () => ErrorProcessor; -export type ErrorHandler = (error: any, options?: ErrorHandlingOption, payload?: T) => void; +// export type ErrorHandler = (error: any, options?: ErrorHandlingOption, payload?: T) => void; export interface ErrorProcessResult { errorToastConfig: OptionsObject, @@ -55,13 +49,13 @@ export interface ErrorProcessResult { validation?: Map; } -export const useErrorHandler = (filter: string): ErrorHandler => { +export const useErrorHandler = () => { const { t } = useTranslation(); const { enqueueSnackbar } = useSnackbar(); - const { service: processorHook } = useTrackService>(filter); - const customErrorProcessor = processorHook && processorHook(); + // const { service: processorHook } = useTrackService>(filter); + // const customErrorProcessor = processorHook && processorHook(); - return (error: any, options?: ErrorHandlingOption, payload?: T) => { + return (error: any, options?: ErrorHandlingOption, payload?: T) => { console.error(error); const errorResults: ErrorProcessResult = { errorToastConfig: { @@ -101,7 +95,6 @@ export const useErrorHandler = (filter: string): ErrorHandler => { const errorList = response.data as ServerError[]; errorResults.errorToastConfig = { ...errorResults.errorToastConfig, - autoHideDuration: options?.duration ?? undefined, }; errorResults.toastMessage = t('judo.error.validation-failed', { defaultValue: 'Please make sure all fields are filled in correctly.', error, payload }) as string; @@ -118,10 +111,10 @@ export const useErrorHandler = (filter: string): ErrorHandler => { } } - if (typeof customErrorProcessor === 'function') { - customErrorProcessor(error, errorResults, options, payload); - return; - } + // if (typeof customErrorProcessor === 'function') { + // customErrorProcessor(error, errorResults, options, payload); + // return; + // } if (errorResults.toastMessage) { enqueueSnackbar(errorResults.toastMessage, errorResults.errorToastConfig);