Browse Source

fix(nc-gui): update data fetch filter

pull/7611/head
DarkPhoenix2704 10 months ago
parent
commit
3d15fdf35e
  1. 119
      packages/nc-gui/composables/useCalendarViewStore.ts

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

@ -231,74 +231,97 @@ 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')
} }
if (!fromCol && !toCol) { if (fromCol && toCol) {
return []
} else if (fromCol && !toCol) {
return [
{
fk_column_id: fromCol.id,
comparison_op: 'btw',
value: `${fromDate},${toDate}`,
},
]
} else if (fromCol && toCol) {
return [ return [
{ {
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'and',
children: [ children: [
{ {
fk_column_id: fromCol.id, is_group: true,
comparison_op: 'btw', logical_op: 'or',
value: `${dayjs(fromDate).format('YYYY-MM-DD')},${dayjs(toDate).format('YYYY-MM-DD')}`, 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}`,
},
],
}, },
{ {
fk_column_id: toCol.id, is_group: true,
comparison_op: 'btw', logical_op: 'or',
value: `${dayjs(fromDate).format('YYYY-MM-DD')},${dayjs(toDate).format('YYYY-MM-DD')}`, children: [
{
fk_column_id: fromCol.id,
comparison_op: 'lte',
comparison_sub_op: 'exactDate',
value: fromDate,
},
{
fk_column_id: toCol.id,
comparison_op: 'gte',
comparison_sub_op: 'exactDate',
value: toDate,
},
],
}, },
{ {
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'or',
children: [ children: [
{ {
is_group: true, fk_column_id: fromCol.id,
logical_op: 'and', comparison_op: 'gte',
children: [ comparison_sub_op: 'exactDate',
{ value: fromDate,
fk_column_id: fromCol.id,
comparison_op: 'lte',
value: `${dayjs(fromDate).format('YYYY-MM-DD')}`,
},
{
fk_column_id: toCol.id,
comparison_op: 'gte',
value: `${dayjs(toDate).format('YYYY-MM-DD')}`,
},
],
}, },
{ {
is_group: true, fk_column_id: toCol.id,
logical_op: 'and', comparison_op: 'lte',
children: [ comparison_sub_op: 'exactDate',
{ value: toDate,
fk_column_id: fromCol.id,
comparison_op: 'gte',
value: `${dayjs(fromDate).format('YYYY-MM-DD')}`,
},
{
fk_column_id: toCol.id,
comparison_op: 'lte',
value: `${dayjs(toDate).format('YYYY-MM-DD')}`,
},
],
}, },
], ],
}, },
], ],
}, },
{
is_group: true,
logical_op: 'or',
children: [
{
fk_column_id: fromCol.id,
comparison_op: 'eq',
comparison_sub_op: 'exactDate',
value: fromDate,
},
{
fk_column_id: toCol.id,
comparison_op: 'eq',
comparison_sub_op: 'exactDate',
value: toDate,
},
],
},
] ]
} } else if (fromCol) {
return [
{
fk_column_id: fromCol.id,
comparison_op: 'btw',
comparison_sub_op: 'exactDate',
value: `${fromDate},${toDate}`,
},
]
} else return []
}) })
// Set of Dates that have data // Set of Dates that have data
@ -355,7 +378,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
} }
async function loadCalendarData() { async function loadCalendarData() {
if ((!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) && !isPublic?.value) return if ((!base?.value?.id || !meta.value?.id || !viewMeta.value?.id || !filterJSON.value) && !isPublic?.value) return
isCalendarDataLoading.value = true isCalendarDataLoading.value = true
const res = !isPublic.value const res = !isPublic.value
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value!.id!, { ? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value!.id!, {

Loading…
Cancel
Save