Skip to content

Commit

Permalink
JNG-5767 handle missing single association
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed Jun 12, 2024
1 parent ad6d7b7 commit 212e93e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static String getContainerOwnActionReturnType(ActionDefinition actionDefi
// {{ classDataName container.dataElement 'Stored' }}{{# if container.table }}[]{{/ if }}
return "JudoRestResponse<" + classDataName((ClassType) container.getDataElement(), "Stored") + (container.isTable() ? "[]" : "") + ">";
} else if (actionDefinition.getIsPreFetchAction()) {
return "JudoRestResponse<" + classDataName(actionDefinition.getTargetType(), "Stored") + ">";
return "JudoRestResponse<" + classDataName(actionDefinition.getTargetType(), "Stored") + " | null>";
} else if (actionDefinition.getIsGetTemplateAction()) {
return "JudoRestResponse<" + classDataName(actionDefinition.getTargetType(), "") + ">";
}
Expand Down Expand Up @@ -207,7 +207,7 @@ public static String linkActionDefinitionResponseType(Link link, ActionDefinitio
} else if (actionDefinition.getIsOpenSelectorAction()) {
return classDataName(((ReferenceType) link.getDataElement()).getTarget(), "Stored") + " | undefined";
} else if (actionDefinition.getIsRefreshAction()) {
return "JudoRestResponse<" + classDataName(((ReferenceType) link.getDataElement()).getTarget(), "Stored") + ">";
return "JudoRestResponse<" + classDataName(((ReferenceType) link.getDataElement()).getTarget(), "Stored") + " | null>";
}
return "void";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface AssociationBaseProps {

export interface AssociationButtonProps extends AssociationBaseProps {
refreshCounter: number;
fetchCall?: () => Promise<JudoRestResponse<JudoIdentifiable<any>>>;
fetchCall?: () => Promise<JudoRestResponse<JudoIdentifiable<any> | null>>;
navigateAction?: (target?: JudoIdentifiable<any> | any) => Promise<void>;
children?: ReactNode;
}
Expand All @@ -31,7 +31,7 @@ export function AssociationButton({
children,
}: AssociationButtonProps) {
const { t } = useTranslation();
const [data, setData] = useState<JudoIdentifiable<any> | undefined>();
const [data, setData] = useState<JudoIdentifiable<any> | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(false);

useEffect(() => {
Expand All @@ -44,7 +44,7 @@ export function AssociationButton({

setData(res);
} catch (e) {
setData(undefined);
setData(null);
console.error(e);
} finally {
setIsLoading(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promise<JudoRestResponse<{{ classDataName action.actionDefinition.targetType 'Stored' }}>> => {
const {{ simpleActionDefinitionName action.actionDefinition }} = async (): Promise<JudoRestResponse<{{ classDataName action.actionDefinition.targetType 'Stored' }} | null>> => {
return {{ getServiceImplForPage page }}.get{{ firstToUpper action.targetDataElement.name }}({{# if (pageHasSignedId page) }}{{# if page.openInDialog }}data{{ else }}{ __signedIdentifier: signedIdentifier } as any{{/ if }}{{ else }}data{{/ if }}, {
_mask: '{}',
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{# if action.targetDataElement }}
const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCustomizer: {{ classDataName action.targetDataElement.target 'QueryCustomizer' }}): Promise<JudoRestResponse<{{ classDataName action.targetDataElement.target 'Stored' }}{{# if action.targetDataElement.isCollection }}[]{{/ if }}>> => {
const {{ simpleActionDefinitionName action.actionDefinition }} = async (queryCustomizer: {{ classDataName action.targetDataElement.target 'QueryCustomizer' }}): Promise<JudoRestResponse<{{ classDataName action.targetDataElement.target 'Stored' }}{{# if action.targetDataElement.isCollection }}[]{{ else }} | null{{/ if }}>> => {
const result = await {{ getServiceImplForPage page }}.{{# if action.targetDataElement.isCollection }}list{{ else }}get{{/ if }}{{ firstToUpper action.targetDataElement.name }}({{{ refreshActionDataParameter action }}}, queryCustomizer{{# with (getTableParentForActionDefinition action.actionDefinition) as |table| }}{{# if table.showTotalCount }}, { [X_JUDO_COUNT_RECORDS]: 'true' }{{/ if }}{{/ with }});
{{# if page.container.view }}
{{# if (isRefreshPageInitializer action page) }}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<judo-meta-ui-version>1.1.0.20240604_105835_a46ed24f_develop</judo-meta-ui-version>
<judo-generator-commons-version>1.0.0.20231009_184136_321053b3_develop</judo-generator-commons-version>
<judo-ui-typescript-rest-version>1.0.0.20240610_201205_f6f4ea61_feature_JNG_5742_eager_relations</judo-ui-typescript-rest-version>
<judo-ui-typescript-rest-version>1.0.0.20240612_165732_227581db_bugfix_JNG_5767_handle_missing_single_association</judo-ui-typescript-rest-version>

<surefire-version>3.0.0-M7</surefire-version>
<!--suppress UnresolvedMavenProperty -->
Expand Down

0 comments on commit 212e93e

Please sign in to comment.