Skip to content

Commit

Permalink
JNG-5395 manual operation template data override
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Jan 5, 2024
1 parent 87c0c83 commit a3117f9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ public static String getServiceMethodSuffix(Action action) {
public static String getDialogOpenParameters(PageDefinition pageDefinition) {
List<String> result = new ArrayList<>();
result.add("ownerData: any");
if (pageDefinition.getContainer().isIsRelationSelector()) {
if (!pageDefinition.getContainer().isIsSelector()) {
result.add("templateDataOverride?: " + classDataName(getReferenceClassType(pageDefinition), ""));
} else if (pageDefinition.getContainer().isIsRelationSelector()) {
result.add("alreadySelected: " + classDataName(getReferenceClassType(pageDefinition), "Stored") + "[]");
}
return String.join(", ", result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ import { {{# unless page.container.table }}useCallback, useEffect, useRef, {{/ u
{{# if page.container.isRelationSelector}}
alreadySelected={alreadySelected}
{{/ if }}
{{# unless page.container.isSelector }}
templateDataOverride={templateDataOverride}
{{/ unless }}
onClose={async () => {
await closeDialog();
resolve({
Expand Down Expand Up @@ -135,6 +138,7 @@ import { {{# unless page.container.table }}useCallback, useEffect, useRef, {{/ u
export interface {{ pageName page }}Props {
ownerData: any;
{{# if page.container.isRelationSelector }}alreadySelected: {{ classDataName (getReferenceClassType page) 'Stored' }}[]{{/ if }}
{{# unless page.container.isSelector }}templateDataOverride?: {{ classDataName (getReferenceClassType page) '' }}{{/ unless }}
onClose: () => Promise<void>;
{{# if (pageHasOutputTarget page) }}
onSubmit: (result?: {{ classDataName (getPageOutputTarget page) 'Stored' }}) => Promise<void>;
Expand All @@ -146,7 +150,7 @@ export interface {{ pageName page }}Props {
// XMIID: {{ getXMIID page }}
// Name: {{ page.name }}
export default function {{ pageName page }}(props: {{ pageName page }}Props) {
const { ownerData, {{# if page.container.isRelationSelector }}alreadySelected, {{/ if }}onClose, onSubmit } = props;
const { ownerData, {{# if page.container.isRelationSelector }}alreadySelected, {{/ if }}{{# unless page.container.isSelector }}templateDataOverride, {{/ unless }}onClose, onSubmit } = props;

{{# unless (containerIsEmptyDashboard page.container) }}
// Services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promi
if (customActions?.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}) {
await customActions.post{{ firstToUpper (simpleActionDefinitionName action.actionDefinition) }}(ownerData, result, storeDiff);
}
if (templateDataOverride) {
setData((prevData) => ({ ...prevData, ...templateDataOverride }));
payloadDiff.current = {
...(templateDataOverride as Record<keyof {{ classDataName (getReferenceClassType page) 'Stored' }}, any>),
};
}
return result;
} catch (error) {
handleError(error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if action.actionDefinition.targetType }}target: {{ classDataName action.actionDefinition.targetType 'Stored' }}{{/ if}}) => {
const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if action.actionDefinition.targetType }}target: {{ classDataName action.actionDefinition.targetType 'Stored' }}, templateDataOverride?: {{ classDataName action.actionDefinition.targetType '' }}{{/ 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 }}
Expand Down

0 comments on commit a3117f9

Please sign in to comment.