From a53a33187af913dd6e167332ffbe00f424a50343 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 3 Feb 2023 16:03:56 +0800 Subject: [PATCH] feat(nc-gui): reset filter value when changing field & add type to isComparisonOpAllowed --- .../smartsheet/toolbar/ColumnFilter.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue index b492c5f0b2..8aeb3cdcfb 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue @@ -117,10 +117,16 @@ const applyChanges = async (hookId?: string, _nested = false) => { } } -const isComparisonOpAllowed = (filter: FilterType, compOp: typeof comparisonOpList[number]) => { - // show current selected value in list even if not allowed - if (filter.comparison_op === compOp.value) return true - +const isComparisonOpAllowed = ( + filter: FilterType, + compOp: { + text: string + value: string + ignoreVal?: boolean + includedTypes?: UITypes[] + excludedTypes?: UITypes[] + }, +) => { // include allowed values only if selected column type matches if (compOp.includedTypes) { return filter.fk_column_id && compOp.includedTypes.includes(types.value[filter.fk_column_id]) @@ -141,6 +147,8 @@ const selectFilterField = (filter: Filter, index: number) => { filter.comparison_op = comparisonOpList(getColumn(filter)!.uidt as UITypes).filter((compOp) => isComparisonOpAllowed(filter, compOp), )?.[0].value + // reset filter value as well + filter.value = "" saveOrUpdate(filter, index) }