Browse Source

Merge pull request #5233 from nocodb/fix/filter-value

fix(nc-gui): reset filter value to null instead
pull/5246/head
Raju Udava 2 years ago committed by GitHub
parent
commit
38a73781cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 8
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
  3. 1
      packages/nc-gui/components/smartsheet/toolbar/FilterInput.vue
  4. 2
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts

3
packages/nc-gui/components/cell/MultiSelect.vue

@ -32,6 +32,7 @@ interface Props {
modelValue?: string | string[] modelValue?: string | string[]
rowIndex?: number rowIndex?: number
disableOptionCreation?: boolean disableOptionCreation?: boolean
location?: 'cell' | 'filter'
} }
const { modelValue, disableOptionCreation } = defineProps<Props>() const { modelValue, disableOptionCreation } = defineProps<Props>()
@ -336,7 +337,7 @@ useEventListener(document, 'click', handleClose, true)
v-for="op of options" v-for="op of options"
:key="op.id || op.title" :key="op.id || op.title"
:value="op.title" :value="op.title"
:data-testid="`select-option-${column.title}-${rowIndex}`" :data-testid="`select-option-${column.title}-${location === 'filter' ? 'filter' : rowIndex}`"
:class="`nc-select-option-${column.title}-${op.title}`" :class="`nc-select-option-${column.title}-${op.title}`"
@click.stop @click.stop
> >

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

@ -85,17 +85,17 @@ const filterUpdateCondition = (filter: FilterType, i: number) => {
) { ) {
// anyof and nanyof can allow multiple selections, // anyof and nanyof can allow multiple selections,
// while `eq` and `neq` only allow one selection // while `eq` and `neq` only allow one selection
filter.value = '' filter.value = null
} else if (['blank', 'notblank', 'empty', 'notempty', 'null', 'notnull'].includes(filter.comparison_op!)) { } else if (['blank', 'notblank', 'empty', 'notempty', 'null', 'notnull'].includes(filter.comparison_op!)) {
// since `blank`, `empty`, `null` doesn't require value, // since `blank`, `empty`, `null` doesn't require value,
// hence remove the previous value // hence remove the previous value
filter.value = '' filter.value = null
filter.comparison_sub_op = '' filter.comparison_sub_op = ''
} else if ([UITypes.Date, UITypes.DateTime].includes(col.uidt as UITypes)) { } else if ([UITypes.Date, UITypes.DateTime].includes(col.uidt as UITypes)) {
// for date / datetime, // for date / datetime,
// the input type could be decimal or datepicker / datetime picker // the input type could be decimal or datepicker / datetime picker
// hence remove the previous value // hence remove the previous value
filter.value = '' filter.value = null
if ( if (
!comparisonSubOpList(filter.comparison_op!) !comparisonSubOpList(filter.comparison_op!)
.map((op) => op.value) .map((op) => op.value)
@ -181,7 +181,7 @@ const selectFilterField = (filter: Filter, index: number) => {
} }
// reset filter value as well // reset filter value as well
filter.value = '' filter.value = null
saveOrUpdate(filter, index) saveOrUpdate(filter, index)
} }

1
packages/nc-gui/components/smartsheet/toolbar/FilterInput.vue

@ -193,6 +193,7 @@ const hasExtraPadding = $computed(() => {
:column="column" :column="column"
class="flex" class="flex"
v-bind="componentProps" v-bind="componentProps"
location="filter"
/> />
</div> </div>
</template> </template>

2
tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts

@ -123,7 +123,7 @@ export class ToolbarFilterPage extends BasePage {
for (let i = 0; i < v.length; i++) { for (let i = 0; i < v.length; i++) {
await this.rootPage await this.rootPage
.locator(`.nc-dropdown-multi-select-cell`) .locator(`.nc-dropdown-multi-select-cell`)
.locator(`.nc-select-option-MultiSelect-${v[i]}`) .locator(`[data-testid="select-option-MultiSelect-filter"].nc-select-option-MultiSelect-${v[i]}`)
.click(); .click();
} }
break; break;

Loading…
Cancel
Save