From d57e6bb875c51e342e201510c84605263fb2d233 Mon Sep 17 00:00:00 2001 From: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Date: Fri, 24 Jun 2022 22:43:01 +0800 Subject: [PATCH] Improve IDs field interaction for Flows item read/update/delete operations when empty (#14090) * Prevent empty key array in item operations * tweak visual on app side --- api/src/operations/item-delete/index.ts | 2 +- api/src/operations/item-read/index.ts | 2 +- api/src/operations/item-update/index.ts | 2 +- app/src/operations/item-delete/index.ts | 2 +- app/src/operations/item-read/index.ts | 2 +- app/src/operations/item-update/index.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/operations/item-delete/index.ts b/api/src/operations/item-delete/index.ts index 2354239e0a..55460d594d 100644 --- a/api/src/operations/item-delete/index.ts +++ b/api/src/operations/item-delete/index.ts @@ -42,7 +42,7 @@ export default defineOperationApi({ let result: PrimaryKey | PrimaryKey[] | null; - if (!key) { + if (!key || (Array.isArray(key) && key.length === 0)) { result = await itemsService.deleteByQuery(sanitizedQueryObject); } else { const keys = toArray(key); diff --git a/api/src/operations/item-read/index.ts b/api/src/operations/item-read/index.ts index 3ce20c2f01..3313d22c17 100644 --- a/api/src/operations/item-read/index.ts +++ b/api/src/operations/item-read/index.ts @@ -42,7 +42,7 @@ export default defineOperationApi({ let result: Item | Item[] | null; - if (!key) { + if (!key || (Array.isArray(key) && key.length === 0)) { result = await itemsService.readByQuery(sanitizedQueryObject); } else { const keys = toArray(key); diff --git a/api/src/operations/item-update/index.ts b/api/src/operations/item-update/index.ts index 6de5fbadef..e77ceb6ca1 100644 --- a/api/src/operations/item-update/index.ts +++ b/api/src/operations/item-update/index.ts @@ -53,7 +53,7 @@ export default defineOperationApi({ let result: PrimaryKey | PrimaryKey[] | null; - if (!key) { + if (!key || (Array.isArray(key) && key.length === 0)) { result = await itemsService.updateByQuery(sanitizedQueryObject, payloadObject, { emitEvents }); } else { const keys = toArray(key); diff --git a/app/src/operations/item-delete/index.ts b/app/src/operations/item-delete/index.ts index 4dc5454cc3..5aecc1382d 100644 --- a/app/src/operations/item-delete/index.ts +++ b/app/src/operations/item-delete/index.ts @@ -14,7 +14,7 @@ export default defineOperationApp({ }, { label: '$t:operations.item-delete.key', - text: key ? toArray(key).join(', ') : '--', + text: toArray(key).length > 0 ? toArray(key).join(', ') : '--', }, ]; diff --git a/app/src/operations/item-read/index.ts b/app/src/operations/item-read/index.ts index 100e0aa8fe..d3e3cc21e8 100644 --- a/app/src/operations/item-read/index.ts +++ b/app/src/operations/item-read/index.ts @@ -14,7 +14,7 @@ export default defineOperationApp({ }, { label: '$t:operations.item-read.key', - text: key ? toArray(key).join(', ') : '--', + text: toArray(key).length > 0 ? toArray(key).join(', ') : '--', }, ]; diff --git a/app/src/operations/item-update/index.ts b/app/src/operations/item-update/index.ts index c3056ddfe3..6e1dacc93b 100644 --- a/app/src/operations/item-update/index.ts +++ b/app/src/operations/item-update/index.ts @@ -13,7 +13,7 @@ export default defineOperationApp({ }, { label: '$t:operations.item-update.key', - text: key ? toArray(key).join(', ') : '--', + text: toArray(key).length > 0 ? toArray(key).join(', ') : '--', }, ];