Browse Source

feat(nc-gui): display filter operator text conditionally

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
bd28bb837a
  1. 4
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
  2. 20
      packages/nc-gui/utils/filterUtils.ts

4
packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue

@ -215,7 +215,6 @@ defineExpose({
{{ op.text }}
</a-select-option>
</a-select>
<LazySmartsheetToolbarFieldListAutoCompleteDropdown
:key="`${i}_6`"
v-model="filter.fk_column_id"
@ -225,7 +224,6 @@ defineExpose({
@click.stop
@change="selectFilterField(filter, i)"
/>
<a-select
v-model:value="filter.comparison_op"
:dropdown-match-select-width="false"
@ -238,7 +236,7 @@ defineExpose({
dropdown-class-name="nc-dropdown-filter-comp-op"
@change="filterUpdateCondition(filter, i)"
>
<template v-for="compOp of comparisonOpList" :key="compOp.value">
<template v-for="compOp of comparisonOpList(getColumn(filter).uidt)" :key="compOp.value">
<a-select-option v-if="isComparisonOpAllowed(filter, compOp)" :value="compOp.value">
{{ compOp.text }}
</a-select-option>

20
packages/nc-gui/utils/filterUtils.ts

@ -1,14 +1,24 @@
import { UITypes } from 'nocodb-sdk'
const numericUITypes = [UITypes.Duration, UITypes.Currency, UITypes.Percent, UITypes.Number, UITypes.Rating, UITypes.Rollup]
const numericUITypes: UITypes[] = [
UITypes.Duration,
UITypes.Currency,
UITypes.Percent,
UITypes.Number,
UITypes.Decimal,
UITypes.Rating,
UITypes.Rollup,
]
export const comparisonOpList: {
export const comparisonOpList = (
fieldUiType: UITypes,
): {
text: string
value: string
ignoreVal?: boolean
includedTypes?: UITypes[]
excludedTypes?: UITypes[]
}[] = [
}[] => [
{
text: 'is checked',
value: 'checked',
@ -22,12 +32,12 @@ export const comparisonOpList: {
includedTypes: [UITypes.Checkbox],
},
{
text: 'is equal',
text: numericUITypes.includes(fieldUiType) ? '=' : 'is equal',
value: 'eq',
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment],
},
{
text: 'is not equal',
text: numericUITypes.includes(fieldUiType) ? '!=' : 'is not equal',
value: 'neq',
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment],
},

Loading…
Cancel
Save