Browse Source

feat(nc-gui): include isWithin logic

pull/5185/head
Wing-Kam Wong 2 years ago
parent
commit
6a72125828
  1. 25
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue

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

@ -90,13 +90,23 @@ const filterUpdateCondition = (filter: FilterType, i: number) => {
// 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 = ''
filter.comparison_sub_op = null 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 = ''
if (!filter.comparison_sub_op) filter.comparison_sub_op = 'exactDate' if (
!comparisonSubOpList(filter.comparison_op!)
.map((op) => op.value)
.includes(filter.comparison_sub_op!)
) {
if (filter.comparison_op === 'isWithin') {
filter.comparison_sub_op = 'pastNumberOfDays'
} else {
filter.comparison_sub_op = 'exactDate'
}
}
} }
saveOrUpdate(filter, i) saveOrUpdate(filter, i)
filterPrevComparisonOp.value[filter.id] = filter.comparison_op filterPrevComparisonOp.value[filter.id] = filter.comparison_op
@ -160,7 +170,11 @@ const selectFilterField = (filter: Filter, index: number) => {
)?.[0].value )?.[0].value
if ([UITypes.Date, UITypes.DateTime].includes(col.uidt as UITypes) && !['blank', 'notblank'].includes(filter.comparison_op)) { if ([UITypes.Date, UITypes.DateTime].includes(col.uidt as UITypes) && !['blank', 'notblank'].includes(filter.comparison_op)) {
if (filter.comparison_op === 'isWithin') {
filter.comparison_sub_op = 'pastNumberOfDays'
} else {
filter.comparison_sub_op = 'exactDate' filter.comparison_sub_op = 'exactDate'
}
} else { } else {
// reset // reset
filter.comparison_sub_op = '' filter.comparison_sub_op = ''
@ -298,7 +312,7 @@ defineExpose({
dropdown-class-name="nc-dropdown-filter-comp-sub-op" dropdown-class-name="nc-dropdown-filter-comp-sub-op"
@change="filterUpdateCondition(filter, i)" @change="filterUpdateCondition(filter, i)"
> >
<template v-for="compSubOp of comparisonSubOpList" :key="compSubOp.value"> <template v-for="compSubOp of comparisonSubOpList(filter.comparison_op)" :key="compSubOp.value">
<a-select-option v-if="isComparisonSubOpAllowed(filter, compSubOp)" :value="compSubOp.value"> <a-select-option v-if="isComparisonSubOpAllowed(filter, compSubOp)" :value="compSubOp.value">
{{ compSubOp.text }} {{ compSubOp.text }}
</a-select-option> </a-select-option>
@ -318,8 +332,9 @@ defineExpose({
<span <span
v-else-if=" v-else-if="
filter.comparison_sub_op filter.comparison_sub_op
? comparisonSubOpList.find((op) => op.value === filter.comparison_sub_op).ignoreVal ? comparisonSubOpList(filter.comparison_op).find((op) => op.value === filter.comparison_sub_op)?.ignoreVal ??
: comparisonOpList(getColumn(filter)?.uidt).find((op) => op.value === filter.comparison_op).ignoreVal false
: comparisonOpList(getColumn(filter)?.uidt).find((op) => op.value === filter.comparison_op)?.ignoreVal ?? false
" "
:key="`span${i}`" :key="`span${i}`"
/> />

Loading…
Cancel
Save