Browse Source

refactor(nc-gui): filter inputs

pull/5498/head
Wing-Kam Wong 2 years ago
parent
commit
52615bb846
  1. 26
      packages/nc-gui/components/smartsheet/toolbar/FilterInput.vue

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

@ -115,18 +115,28 @@ const booleanOptions = [
{ value: null, label: 'unset' }, { value: null, label: 'unset' },
] ]
const renderSingleSelect = (op: string) => {
// use MultiSelect for SingleSelect columns for anyof / nanyof filters
if (['anyof', 'nanyof'].includes(op)) {
return MultiSelect
}
return SingleSelect
}
const renderDateFilterInput = (sub_op: string) => {
if (['daysAgo', 'daysFromNow', 'pastNumberOfDays', 'nextNumberOfDays'].includes(sub_op)) {
return Decimal
}
return DatePicker
}
const componentMap: Partial<Record<FilterType, any>> = $computed(() => { const componentMap: Partial<Record<FilterType, any>> = $computed(() => {
return { return {
// use MultiSelect for SingleSelect columns for anyof / nanyof filters isSingleSelect: renderSingleSelect(props.filter.comparison_op!),
isSingleSelect: ['anyof', 'nanyof'].includes(props.filter.comparison_op!) ? MultiSelect : SingleSelect,
isMultiSelect: MultiSelect, isMultiSelect: MultiSelect,
isDate: ['daysAgo', 'daysFromNow', 'pastNumberOfDays', 'nextNumberOfDays'].includes(props.filter.comparison_sub_op!) isDate: renderDateFilterInput(props.filter.comparison_sub_op!),
? Decimal
: DatePicker,
isYear: YearPicker, isYear: YearPicker,
isDateTime: ['daysAgo', 'daysFromNow', 'pastNumberOfDays', 'nextNumberOfDays'].includes(props.filter.comparison_sub_op!) isDateTime: renderDateFilterInput(props.filter.comparison_sub_op!),
? Decimal
: DateTimePicker,
isTime: TimePicker, isTime: TimePicker,
isRating: Rating, isRating: Rating,
isDuration: Duration, isDuration: Duration,

Loading…
Cancel
Save