From 7eb2cb1137b5fff29dc192656dd480baade0d38d Mon Sep 17 00:00:00 2001 From: Oreille <33065839+Oreilles@users.noreply.github.com> Date: Mon, 25 Oct 2021 17:37:47 +0200 Subject: [PATCH] Fix filter added twice and remove unnecessary `_and` node. (#9116) --- .../_system/system-filter/system-filter.vue | 14 ++++++++++---- app/src/modules/collections/routes/collection.vue | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/interfaces/_system/system-filter/system-filter.vue b/app/src/interfaces/_system/system-filter/system-filter.vue index 74c36ee925..0ea5616492 100644 --- a/app/src/interfaces/_system/system-filter/system-filter.vue +++ b/app/src/interfaces/_system/system-filter/system-filter.vue @@ -112,10 +112,16 @@ export default defineComponent({ } }, set(newVal) { - if (newVal.length === 0) { - emit('input', null); - } else { - emit('input', { _and: newVal }); + switch (newVal.length) { + case 0: + emit('input', null); + break; + case 1: + emit('input', newVal[0]); + break; + default: + emit('input', { _and: newVal }); + break; } }, }); diff --git a/app/src/modules/collections/routes/collection.vue b/app/src/modules/collections/routes/collection.vue index 564f5c3b9d..ea3426065f 100644 --- a/app/src/modules/collections/routes/collection.vue +++ b/app/src/modules/collections/routes/collection.vue @@ -381,7 +381,7 @@ export default defineComponent({ const field = currentCollection.value.meta.archive_field; - if (!field) return filter.value; + if (!field) return null; let archiveValue: any = currentCollection.value.meta.archive_value; if (archiveValue === 'true') archiveValue = true;