Skip to content

Commit

Permalink
JNG-5402 mask api in actions (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Jan 9, 2024
1 parent 2497663 commit 9963a75
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface {{ componentName table }}ActionDefinitions {
{{ else }}
{{# if actionDefinition.isRefreshAction }}
{{ simpleActionDefinitionName actionDefinition }}?: (queryCustomizer: {{ classDataName (getReferenceClassType table) 'QueryCustomizer' }}) => Promise<{{ classDataName (getReferenceClassType table) 'Stored' }}[]>;
get{{ firstToUpper table.relationName }}Mask?: () => string;
{{ else }}
{{# if actionDefinition.isSelectorRangeAction }}
{{ simpleActionDefinitionName actionDefinition }}?: (queryCustomizer: {{ classDataName (getReferenceClassType table) 'QueryCustomizer' }}) => Promise<{{ classDataName (getReferenceClassType table) 'Stored' }}[]>;
Expand Down Expand Up @@ -478,17 +479,19 @@ export function {{ componentName table }}(props: {{ componentName table }}Props)
setIsLoading(true);

try {
const processedQueryCustomizer = {
...processQueryCustomizer(queryCustomizer),
{{# if (getRefreshActionDefinitionForTable table) }}
_mask: actions.get{{ firstToUpper table.relationName }}Mask ? actions.get{{ firstToUpper table.relationName }}Mask() : queryCustomizer._mask,
{{/ if }}
};
{{# if container.isSelector }}
{{# with (getRangeActionDefinitionForTable table) as |actionDefinition| }}
const res = await actions.{{ simpleActionDefinitionName actionDefinition }}!(
processQueryCustomizer(queryCustomizer),
);
const res = await actions.{{ simpleActionDefinitionName actionDefinition }}!(processedQueryCustomizer);
{{/ with }}
{{ else }}
{{# with (getRefreshActionDefinitionForTable table) as |actionDefinition| }}
const res = await actions.{{ simpleActionDefinitionName actionDefinition }}!(
processQueryCustomizer(queryCustomizer),
);
const res = await actions.{{ simpleActionDefinitionName actionDefinition }}!(processedQueryCustomizer);
{{/ with }}
{{/ if }}

Expand Down Expand Up @@ -629,11 +632,17 @@ export function {{ componentName table }}(props: {{ componentName table }}Props)
}
{{/ if }}
{{ else }}
const processedQueryCustomizer = {
...processQueryCustomizer(queryCustomizer),
{{# if (getRefreshActionDefinitionForTable table) }}
_mask: actions.get{{ firstToUpper table.relationName }}Mask ? actions.get{{ firstToUpper table.relationName }}Mask() : queryCustomizer._mask,
{{/ if }}
};
{{# if actionDefinition.isRefreshAction }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(queryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processedQueryCustomizer);
{{ else }}
{{# if actionDefinition.isSelectorRangeAction }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(queryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processedQueryCustomizer);
{{ else }}
{{# if actionDefinition.isBulk }}
const { result: bulkResult } = await actions.{{ simpleActionDefinitionName actionDefinition }}!(selectedRows.current);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export interface {{ pageContainerActionDefinitionTypeName container }}{{# if (co
{{# each (getElementsWithHiddenBy container) as |ve| }}
is{{ safeName ve }}Hidden?: ({{{ inputModifierParams container false }}}) => boolean;
{{/ each }}
{{# if container.view }}
getMask?: () => string;
{{/ if }}
}
{{/ unless }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function {{ containerComponentName container }}Dialog(props: {{ c
} = props;
{{# unless container.table }}
const queryCustomizer: {{ classDataName container.dataElement 'QueryCustomizer' }} = {
_mask: '{{ getMaskForView container }}',
_mask: {{# unless container.form }}actions.getMask ? actions.getMask!() : {{/ unless }}'{{ getMaskForView container }}',
};
{{/ unless }}
{{/ unless }}
Expand All @@ -103,7 +103,7 @@ export default function {{ containerComponentName container }}Dialog(props: {{ c
<>
{{# unless (containerIsEmptyDashboard container) }}
<DialogTitle>
{actions?.getPageTitle ? actions?.getPageTitle({{# unless container.table }}data{{/ unless }}) : ''}
{actions.getPageTitle ? actions.getPageTitle({{# unless container.table }}data{{/ unless }}) : ''}
<IconButton
id="{{ getXMIID container }}-dialog-close-wrapper"
aria-label="close"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function {{ containerComponentName container }}Page (props: {{ co
const { actions, isLoading, editMode, refreshCounter{{# unless container.table }}, data, isFormUpdateable, isFormDeleteable, storeDiff, validation, setValidation, submit{{/ unless }} } = props;
{{# unless container.table }}
const queryCustomizer: {{ classDataName container.dataElement 'QueryCustomizer' }} = {
_mask: '{{ getMaskForView container }}',
_mask: {{# unless container.form }}actions.getMask ? actions.getMask!() : {{/ unless }}'{{ getMaskForView container }}',
};
{{/ unless }}
{{/ unless }}
Expand Down
10 changes: 5 additions & 5 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 @@ -218,9 +218,9 @@ export default function {{ pageName page }}(props: {{ pageName page }}Props) {
}, [data]);

{{# if page.container.view }}
const pageQueryCustomizer: {{ classDataName (getReferenceClassType page) 'QueryCustomizer' }} = {
_mask: '{{ getMaskForView page.container }}',
};
const getPageQueryCustomizer: () => {{ classDataName (getReferenceClassType page) 'QueryCustomizer' }} = () => ({
_mask: actions.getMask ? actions.getMask!() : '{{ getMaskForView page.container }}',
});
{{/ if }}
{{/ unless }}

Expand All @@ -244,7 +244,7 @@ export default function {{ pageName page }}(props: {{ pageName page }}Props) {
{{# if page.container.view }}
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }}
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) {
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ with }}
{{/ if }}
Expand Down Expand Up @@ -319,7 +319,7 @@ export default function {{ pageName page }}(props: {{ pageName page }}Props) {
// Effect section
{{# if (pageShouldInitialize page) }}
useEffect(() => {
actions.{{ simpleActionDefinitionName page.container.onInit }}!({{# if page.container.view }}pageQueryCustomizer{{/ if }});
actions.{{ simpleActionDefinitionName page.container.onInit }}!({{# if page.container.view }}getPageQueryCustomizer(){{/ if }});
}, []);
{{/ if }}
{{/ unless }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (selected
{{# if page.container.view }}
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }}
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) {
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ with }}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (selected
{{# if page.container.view }}
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }}
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) {
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ with }}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (selected
{{# if page.container.view }}
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }}
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) {
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ with }}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if a
{{# if page.container.view }}
if (!editMode) {
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
{{/ with }}
}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
// no need to set editMode to false, given refresh should do it implicitly
await {{ simpleActionDefinitionName actionDefinition }}(processQueryCustomizer(pageQueryCustomizer));
await {{ simpleActionDefinitionName actionDefinition }}(processQueryCustomizer(getPageQueryCustomizer()));
{{/ with }}
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
{{# if page.container.view }}
if (!editMode) {
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
{{/ with }}
}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if a
{{ else }}
{{# if (containerIsRefreshable page.container) }}
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }}
{{ simpleActionDefinitionName refreshActionDefinition }}(pageQueryCustomizer);
{{ simpleActionDefinitionName refreshActionDefinition }}(getPageQueryCustomizer());
{{/ with }}
{{/ if }}
{{/ unless }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
{{# if page.container.view }}
if (!editMode) {
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
{{/ with }}
}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if a
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
{{# if page.container.view }}
if (result === 'submit' && !editMode) {
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ if }}
{{# if page.container.table }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
{{# if page.container.view }}
if (!editMode) {
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
{{/ with }}
}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (target?:
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
{{# if page.container.view }}
if (!editMode) {
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ if }}
{{# if page.container.table }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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({{{ refreshActionDataParameter action }}}, pageQueryCustomizer);
const result = await {{ getServiceImplForPage page }}.refresh({{{ refreshActionDataParameter action }}}, getPageQueryCustomizer());
setData(result);
setLatestViewData(result);
// re-set payloadDiff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (target?:
{{# if page.container.view }}
if (!editMode) {
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName actionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
{{/ with }}
}
{{/ if }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
showSuccessSnack(t('judo.action.save.success', { defaultValue: 'Changes saved' }));
setValidation(new Map<keyof {{ classDataName (getReferenceClassType page) '' }}, string>());
{{# with (getRefreshActionDefinitionForContainer page.container) as |actionDefinition| }}
await actions.{{ simpleActionDefinitionName actionDefinition }}!(pageQueryCustomizer);
await actions.{{ simpleActionDefinitionName actionDefinition }}!(getPageQueryCustomizer());
{{/ with }}
setEditMode(false);
}
Expand Down
10 changes: 5 additions & 5 deletions judo-ui-react/src/main/resources/actor/src/pages/index.tsx.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ export default function {{ pageName page }}() {
}, [data]);

{{# if page.container.view }}
const pageQueryCustomizer: {{ classDataName (getReferenceClassType page) 'QueryCustomizer' }} = {
_mask: '{{ getMaskForView page.container }}',
};
const getPageQueryCustomizer: () => {{ classDataName (getReferenceClassType page) 'QueryCustomizer' }} = () => ({
_mask: actions.getMask ? actions.getMask!() : '{{ getMaskForView page.container }}',
});
{{/ if }}
{{/ unless }}

Expand All @@ -177,7 +177,7 @@ export default function {{ pageName page }}() {
{{# if page.container.view }}
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }}
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) {
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer));
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(getPageQueryCustomizer()));
}
{{/ with }}
{{/ if }}
Expand Down Expand Up @@ -265,7 +265,7 @@ export default function {{ pageName page }}() {
return;
}
{{/ if }}
await actions.{{ simpleActionDefinitionName page.container.onInit }}!({{# if page.container.view }}pageQueryCustomizer{{/ if }});
await actions.{{ simpleActionDefinitionName page.container.onInit }}!({{# if page.container.view }}getPageQueryCustomizer(){{/ if }});
})();
}, []);
{{/ if }}
Expand Down

0 comments on commit 9963a75

Please sign in to comment.