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

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

@ -1,14 +1,24 @@
import { UITypes } from 'nocodb-sdk' 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 text: string
value: string value: string
ignoreVal?: boolean ignoreVal?: boolean
includedTypes?: UITypes[] includedTypes?: UITypes[]
excludedTypes?: UITypes[] excludedTypes?: UITypes[]
}[] = [ }[] => [
{ {
text: 'is checked', text: 'is checked',
value: 'checked', value: 'checked',
@ -22,12 +32,12 @@ export const comparisonOpList: {
includedTypes: [UITypes.Checkbox], includedTypes: [UITypes.Checkbox],
}, },
{ {
text: 'is equal', text: numericUITypes.includes(fieldUiType) ? '=' : 'is equal',
value: 'eq', value: 'eq',
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment],
}, },
{ {
text: 'is not equal', text: numericUITypes.includes(fieldUiType) ? '!=' : 'is not equal',
value: 'neq', value: 'neq',
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment],
}, },

Loading…
Cancel
Save