From e6c8ca44c5de32ea86651c3ae52680ec76823bc3 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 1 Oct 2020 17:34:25 +0100 Subject: [PATCH] fix: View filter - handle change of field type --- .../database/DataTable/popovers/Filter.svelte | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/database/DataTable/popovers/Filter.svelte b/packages/builder/src/components/database/DataTable/popovers/Filter.svelte index ca3cb57bdd..ac3a9c4e95 100644 --- a/packages/builder/src/components/database/DataTable/popovers/Filter.svelte +++ b/packages/builder/src/components/database/DataTable/popovers/Filter.svelte @@ -98,6 +98,22 @@ function isDate(field) { return viewModel.schema[field].type === "datetime" } + + function isNumber(field) { + return viewModel.schema[field].type === "number" + } + + const fieldChanged = filter => ev => { + // reset if type changed + if ( + filter.key && + ev.target.value && + viewModel.schema[filter.key].type !== + viewModel.schema[ev.target.value].type + ) { + filter.value = "" + } + }
@@ -124,7 +140,11 @@ {/each} {/if} - {#each fields as field} @@ -138,6 +158,7 @@ {#if filter.key && isMultipleChoice(filter.key)} {:else}