Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNG-5395 manual operation template data override #286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading