Browse Source

fix(nc-gui): simplify filters

pull/7611/head
DarkPhoenix2704 8 months ago
parent
commit
4ac03389c5
  1. 115
      packages/nc-gui/composables/useCalendarViewStore.ts

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

@ -163,8 +163,8 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
toDate = dayjs(selectedDateRange.value.end).endOf('day') toDate = dayjs(selectedDateRange.value.end).endOf('day')
break break
case 'month': case 'month':
fromDate = dayjs(selectedDate.value).startOf('month') fromDate = dayjs(selectedMonth.value).startOf('month')
toDate = dayjs(selectedDate.value).endOf('month') toDate = dayjs(selectedMonth.value).endOf('month')
break break
case 'year': case 'year':
@ -200,59 +200,26 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'or',
children: [ children: [
{
fk_column_id: fromCol.id,
comparison_op: 'btw',
comparison_sub_op: 'exactDate',
value: `${fromDate},${toDate}`,
},
{
fk_column_id: toCol.id,
comparison_op: 'btw',
comparison_sub_op: 'exactDate',
value: `${fromDate},${toDate}`,
},
],
},
{ {
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'and',
children: [ children: [
{ {
fk_column_id: fromCol.id, fk_column_id: fromCol.id,
comparison_op: 'lte', comparison_op: 'lte',
comparison_sub_op: 'exactDate', comparison_sub_op: 'exactDate',
value: fromDate,
},
{
fk_column_id: toCol.id,
comparison_op: 'gte',
comparison_sub_op: 'exactDate',
value: toDate, value: toDate,
}, },
],
},
{
is_group: true,
logical_op: 'or',
children: [
{ {
fk_column_id: fromCol.id, fk_column_id: toCol.id,
comparison_op: 'gte', comparison_op: 'gte',
comparison_sub_op: 'exactDate', comparison_sub_op: 'exactDate',
value: fromDate, value: fromDate,
}, },
{
fk_column_id: toCol.id,
comparison_op: 'lte',
comparison_sub_op: 'exactDate',
value: toDate,
},
],
},
], ],
}, },
{ {
// Exact match check
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'or',
children: [ children: [
@ -270,19 +237,9 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
comparison_sub_op: 'exactDate', comparison_sub_op: 'exactDate',
value: toDate, value: toDate,
}, },
{ ],
fk_column_id: toCol.id,
comparison_op: 'eq',
logical_op: 'or',
comparison_sub_op: 'exactDate',
value: fromDate,
}, },
{ ],
fk_column_id: fromCol.id,
comparison_op: 'eq',
logical_op: 'or',
comparison_sub_op: 'exactDate',
value: toDate,
}, },
], ],
}, },
@ -374,8 +331,8 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
fromDate = dayjs(selectedDate.value).startOf('day') fromDate = dayjs(selectedDate.value).startOf('day')
toDate = dayjs(selectedDate.value).endOf('day') toDate = dayjs(selectedDate.value).endOf('day')
} else if (activeCalendarView.value === 'month') { } else if (activeCalendarView.value === 'month') {
fromDate = dayjs(selectedDate.value).startOf('month') fromDate = dayjs(selectedMonth.value).startOf('month')
toDate = dayjs(selectedDate.value).endOf('month') toDate = dayjs(selectedMonth.value).endOf('month')
} else if (activeCalendarView.value === 'year') { } else if (activeCalendarView.value === 'year') {
fromDate = dayjs(selectedDate.value).startOf('year') fromDate = dayjs(selectedDate.value).startOf('year')
toDate = dayjs(selectedDate.value).endOf('year') toDate = dayjs(selectedDate.value).endOf('year')
@ -404,58 +361,26 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
logical_op: 'or', logical_op: 'or',
children: [ children: [
{ {
fk_column_id: fromCol.id, // Check for overlap or within range
comparison_op: 'btw',
comparison_sub_op: 'exactDate',
value: `${fromDate},${toDate}`,
},
{
fk_column_id: toCol.id,
comparison_op: 'btw',
comparison_sub_op: 'exactDate',
value: `${fromDate},${toDate}`,
},
],
},
{
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'and',
children: [ children: [
{ {
fk_column_id: fromCol.id, fk_column_id: fromCol.id,
comparison_op: 'lte', comparison_op: 'lte',
comparison_sub_op: 'exactDate', comparison_sub_op: 'exactDate',
value: fromDate,
},
{
fk_column_id: toCol.id,
comparison_op: 'gte',
comparison_sub_op: 'exactDate',
value: toDate, value: toDate,
}, },
],
},
{
is_group: true,
logical_op: 'or',
children: [
{ {
fk_column_id: fromCol.id, fk_column_id: toCol.id,
comparison_op: 'gte', comparison_op: 'gte',
comparison_sub_op: 'exactDate', comparison_sub_op: 'exactDate',
value: fromDate, value: fromDate,
}, },
{
fk_column_id: toCol.id,
comparison_op: 'lte',
comparison_sub_op: 'exactDate',
value: toDate,
},
],
},
], ],
}, },
{ {
// Exact match check
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'or',
children: [ children: [
@ -473,19 +398,9 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
comparison_sub_op: 'exactDate', comparison_sub_op: 'exactDate',
value: toDate, value: toDate,
}, },
{ ],
fk_column_id: toCol.id,
comparison_op: 'eq',
logical_op: 'or',
comparison_sub_op: 'exactDate',
value: fromDate,
}, },
{ ],
fk_column_id: fromCol.id,
comparison_op: 'eq',
logical_op: 'or',
comparison_sub_op: 'exactDate',
value: toDate,
}, },
], ],
}, },

Loading…
Cancel
Save