fix itemId being null (#12799)

This commit is contained in:
Nitwel
2022-04-18 15:38:55 +02:00
committed by GitHub
parent 69d40af5b3
commit e57718dde5
2 changed files with 3 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -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<string, any>;
return;
}