Skip to content

Commit

Permalink
JNG-4838 implement dialog refresh, open
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Oct 19, 2023
1 parent 082885b commit 5664a98
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ export default (props: {{ containerComponentName container }}DialogProps) => {
</Suspense>
</DialogContent>
<DialogActions>
{{# unless container.table }}
{editMode{{# unless container.table }} && isFormUpdateable(){{/ unless }} && (
<Grid className="page-action" item>
{{# with (getRefreshActionDefinitionForContainer container) as |actionDefinition| }}
<Button
id="page-action-cancel"
variant="outlined"
startIcon={<MdiIcon path="cancel" />}
onClick={ async () => {
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(queryCustomizer));
} }
disabled={isLoading}
>
{t('judo.pages.cancel', { defaultValue: 'Cancel' })}
</Button>
{{/ with }}
</Grid>
)}
{{/ unless }}
{{# each container.actionButtonGroup.buttons as |button| }}
{ {{ containerButtonAvailable button }} && actions.{{ simpleActionDefinitionName actionDefinition }} && (
<Grid className="page-action" item>
Expand Down
11 changes: 8 additions & 3 deletions judo-ui-react/src/main/resources/actor/src/dialogs/index.tsx.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react'
import { toastConfig } from '~/config';
import {
passesLocalValidation,
processQueryCustomizer,
uiDateToServiceDate,
uiTimeToServiceTime,
useErrorHandler,
Expand All @@ -40,10 +41,10 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react'
{{/ unless }}

{{# unless (containerIsEmptyDashboard page.container) }}
export const use{{ pageName page }} = (ownerData: any): () => Promise<DialogResult<{{# if page.container.table }}Array<{{/ if }}{{ classDataName (getReferenceClassType page) 'Stored' }}{{# if page.container.table }}>{{/ if }}>> => {
export const use{{ pageName page }} = (ownerData: any): ({{# if page.container.view}}targetData: JudoIdentifiable<any>{{/ if }}) => Promise<DialogResult<{{# if page.container.table }}Array<{{/ if }}{{ classDataName (getReferenceClassType page) 'Stored' }}{{# if page.container.table }}>{{/ if }}>> => {
const [createDialog, closeDialog] = useDialog();

return () => new Promise((resolve) => {
return ({{# if page.container.view}}targetData: JudoIdentifiable<any>{{/ if }}) => new Promise((resolve) => {
createDialog({
{{# if page.dialogSize }}
fullWidth: true,
Expand All @@ -60,6 +61,9 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react'
children: (
<{{ pageName page }}
ownerData={ownerData}
{{# if page.container.view}}
targetData={targetData}
{{/ if }}
onClose={() => {
closeDialog();
resolve({
Expand Down Expand Up @@ -89,13 +93,14 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react'

export interface {{ pageName page }}Props {
ownerData: any;
{{# if page.container.view}}targetData: JudoIdentifiable<any>{{/ if }}
onClose: () => void;
onSubmit: (result: {{# if page.container.table }}Array<{{/ if }}{{ classDataName (getReferenceClassType page) 'Stored' }}{{# if page.container.table }}>{{/ if }}) => void;
}

// Name: {{ page.name }}
export default function {{ pageName page }}(props: {{ pageName page }}Props) {
const { ownerData, onClose, onSubmit } = props;
const { ownerData, {{# if page.container.view}}targetData, {{/ if }}onClose, onSubmit } = props;

{{# unless (containerIsEmptyDashboard page.container) }}
// Hooks section
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
const {{ simpleActionDefinitionName action.actionDefinition }} = async (target?: {{ classDataName action.actionDefinition.targetType 'Stored' }}) => {
{{# if action.targetPageDefinition.openInDialog }}
alert('TODO Open Dialog');
await open{{ pageName action.targetPageDefinition }}(target!);

{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
{{# if page.container.view }}
if (!editMode) {
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
}
{{/ if }}
{{# if page.container.table }}
setRefreshCounter((prev) => prev + 1);
{{/ if }}
{{/ with }}
{{ else }}
{{# if (pageHasSignedId action.targetPageDefinition) }}
// if the `target` is missing we are likely navigating to a relation table page, in which case we need the owner's id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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<any>{{/ if }}{{ else }}undefined{{/ if }}, queryCustomizer);
{{ else }}
const result = await {{ getServiceImplForPage page }}.refresh({{# if (pageHasSignedId page) }}{{# if page.openInDialog }}data{{ else }}{ __signedIdentifier: signedIdentifier } as JudoIdentifiable<any>{{/ if }}{{ else }}undefined{{/ if }}, pageQueryCustomizer);
const result = await {{ getServiceImplForPage page }}.refresh({{# if (pageHasSignedId page) }}{{# if page.openInDialog }}targetData{{ else }}{ __signedIdentifier: signedIdentifier } as JudoIdentifiable<any>{{/ if }}{{ else }}undefined{{/ if }}, pageQueryCustomizer);

setData(result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useCallback, useEffect, useRef, useState, lazy, Suspense } from 'react'
import { toastConfig } from '~/config';
import {
passesLocalValidation,
processQueryCustomizer,
uiDateToServiceDate,
uiTimeToServiceTime,
useErrorHandler,
Expand Down

0 comments on commit 5664a98

Please sign in to comment.