Browse Source

fix(nc-gui): support for multiple filters

pull/7611/head
DarkPhoenix2704 9 months ago
parent
commit
1c62ef8752
  1. 32
      packages/nc-gui/composables/useCalendarViewStore.ts

32
packages/nc-gui/composables/useCalendarViewStore.ts

@ -211,9 +211,11 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
} }
const filterJSON = computed(() => { const filterJSON = computed(() => {
if (!meta.value?.columns || !calendarRange.value || !calendarRange.value[0]) return [] const combinedFilters = {
const fromCol = calendarRange.value[0].fk_from_col is_group: true,
const toCol = calendarRange.value[0].fk_to_col logical_op: 'and',
children: [],
}
let fromDate let fromDate
let toDate let toDate
@ -231,8 +233,14 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
fromDate = dayjs(selectedDate.value).startOf('year').format('YYYY-MM-DD') fromDate = dayjs(selectedDate.value).startOf('year').format('YYYY-MM-DD')
toDate = dayjs(selectedDate.value).endOf('year').format('YYYY-MM-DD') toDate = dayjs(selectedDate.value).endOf('year').format('YYYY-MM-DD')
} }
calendarRange.value.forEach((range) => {
const fromCol = range.fk_from_col
const toCol = range.fk_to_col
let rangeFilter = []
if (fromCol && toCol) { if (fromCol && toCol) {
return [ rangeFilter = [
{ {
is_group: true, is_group: true,
logical_op: 'and', logical_op: 'and',
@ -315,7 +323,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
}, },
] ]
} else if (fromCol) { } else if (fromCol) {
return [ rangeFilter = [
{ {
fk_column_id: fromCol.id, fk_column_id: fromCol.id,
comparison_op: 'btw', comparison_op: 'btw',
@ -323,7 +331,19 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
value: `${fromDate},${toDate}`, value: `${fromDate},${toDate}`,
}, },
] ]
} else return [] }
if (rangeFilter.length > 0) {
combinedFilters.children.push({
is_group: true,
logical_op: 'or',
children: rangeFilter,
})
}
})
console.log('combinedFilters', combinedFilters)
return combinedFilters.children.length > 0 ? [combinedFilters] : []
}) })
// Set of Dates that have data // Set of Dates that have data

Loading…
Cancel
Save