From e57718dde562ffe3d8358ddb9adabc65ca3aa39a Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 18 Apr 2022 15:38:55 +0200 Subject: [PATCH] fix itemId being null (#12799) --- app/src/composables/use-relation/use-relation-multiple.ts | 5 ++--- app/src/composables/use-relation/use-relation-single.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/composables/use-relation/use-relation-multiple.ts b/app/src/composables/use-relation/use-relation-multiple.ts index 56deeee42d..844fbad9ad 100644 --- a/app/src/composables/use-relation/use-relation-multiple.ts +++ b/app/src/composables/use-relation/use-relation-multiple.ts @@ -4,7 +4,6 @@ import { unexpectedError } from '@/utils/unexpected-error'; import { clamp, cloneDeep, isEqual, merge, isPlainObject } from 'lodash'; import { computed, ref, Ref, watch } from 'vue'; import { RelationM2A, RelationM2M, RelationO2M } from '@/composables/use-relation'; -import { Method } from 'axios'; export type RelationQueryMultiple = { page: number; @@ -318,7 +317,7 @@ export function useRelationMultiple( await updateItemCount(targetCollection, targetPKField, reverseJunctionField); - if (itemId.value === '+') { + if (!itemId.value || itemId.value === '+') { fetchedItems.value = []; } else { const response = await api.get(getEndpoint(targetCollection), { @@ -342,7 +341,7 @@ export function useRelationMultiple( } async function updateItemCount(targetCollection: string, targetPKField: string, reverseJunctionField: string) { - if (itemId.value === '+') { + if (!itemId.value || itemId.value === '+') { existingItemCount.value = 0; return; } diff --git a/app/src/composables/use-relation/use-relation-single.ts b/app/src/composables/use-relation/use-relation-single.ts index acd83860f3..f0e7cb2aed 100644 --- a/app/src/composables/use-relation/use-relation-single.ts +++ b/app/src/composables/use-relation/use-relation-single.ts @@ -55,7 +55,7 @@ export function useRelationSingle( const id = typeof val === 'object' ? val[relation.value.relatedPrimaryKeyField.field] : val; if (!id) { - displayItem.value = val; + displayItem.value = val as Record; return; }