Browse Source

feat(nc-gui): reset filter value when changing field & add type to isComparisonOpAllowed

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
a53a33187a
  1. 16
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue

16
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)
}

Loading…
Cancel
Save