Browse Source

refactor(nc-gui): rename date filter sub ops

pull/5185/head
Wing-Kam Wong 2 years ago
parent
commit
445fb6cdcd
  1. 4
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
  2. 4
      packages/nc-gui/components/smartsheet/toolbar/FilterInput.vue
  3. 14
      packages/nc-gui/utils/filterUtils.ts

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

@ -96,7 +96,7 @@ const filterUpdateCondition = (filter: FilterType, i: number) => {
// 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 = 'exact_date' if (!filter.comparison_sub_op) 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 +160,7 @@ 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)) {
filter.comparison_sub_op = 'exact_date' filter.comparison_sub_op = 'exactDate'
} else { } else {
// reset // reset
filter.comparison_sub_op = '' filter.comparison_sub_op = ''

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

@ -117,9 +117,9 @@ const componentMap: Partial<Record<FilterType, any>> = $computed(() => {
// use MultiSelect for SingleSelect columns for anyof / nanyof filters // use MultiSelect for SingleSelect columns for anyof / nanyof filters
isSingleSelect: ['anyof', 'nanyof'].includes(props.filter.comparison_op!) ? MultiSelect : SingleSelect, isSingleSelect: ['anyof', 'nanyof'].includes(props.filter.comparison_op!) ? MultiSelect : SingleSelect,
isMultiSelect: MultiSelect, isMultiSelect: MultiSelect,
isDate: ['number_of_days_ago', 'number_of_days_from_now'].includes(props.filter.comparison_sub_op!) ? Decimal : DatePicker, isDate: ['daysAgo', 'daysFromNow'].includes(props.filter.comparison_sub_op!) ? Decimal : DatePicker,
isYear: YearPicker, isYear: YearPicker,
isDateTime: ['number_of_days_ago', 'number_of_days_from_now'].includes(props.filter.comparison_sub_op!) isDateTime: ['daysAgo', 'daysFromNow'].includes(props.filter.comparison_sub_op!)
? Decimal ? Decimal
: DateTimePicker, : DateTimePicker,
isTime: TimePicker, isTime: TimePicker,

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

@ -250,43 +250,43 @@ export const comparisonSubOpList: {
}, },
{ {
text: 'one week ago', text: 'one week ago',
value: 'one_week_ago', value: 'oneWeekAgo',
ignoreVal: true, ignoreVal: true,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },
{ {
text: 'one week from now', text: 'one week from now',
value: 'one_week_from_now', value: 'oneWeekFromNow',
ignoreVal: true, ignoreVal: true,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },
{ {
text: 'one month ago', text: 'one month ago',
value: 'one_month_ago', value: 'oneMonthAgo',
ignoreVal: true, ignoreVal: true,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },
{ {
text: 'one month from now', text: 'one month from now',
value: 'one_month_from_now', value: 'oneMonthFromNow',
ignoreVal: true, ignoreVal: true,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },
{ {
text: 'number of days ago', text: 'number of days ago',
value: 'number_of_days_ago', value: 'daysAgo',
ignoreVal: false, ignoreVal: false,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },
{ {
text: 'number of days from now', text: 'number of days from now',
value: 'number_of_days_from_now', value: 'daysFromNow',
ignoreVal: false, ignoreVal: false,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },
{ {
text: 'exact date', text: 'exact date',
value: 'exact_date', value: 'exactDate',
ignoreVal: false, ignoreVal: false,
includedTypes: [UITypes.Date, UITypes.DateTime], includedTypes: [UITypes.Date, UITypes.DateTime],
}, },

Loading…
Cancel
Save