Browse Source

fix: calendar shared view, range filters not working causing listing all rows with view filter only applied

pull/8628/head
DarkPhoenix2704 6 months ago
parent
commit
3c87991c34
  1. 22
      packages/nc-gui/composables/useCalendarViewStore.ts
  2. 14
      packages/nocodb/src/services/calendar-datas.service.ts

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

@ -251,6 +251,11 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
value: fromDate,
},
]
combinedFilters.push({
is_group: true,
logical_op: 'or',
children: rangeFilter,
})
} else if (fromCol) {
rangeFilter = [
{
@ -266,11 +271,9 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
value: prevDate,
},
]
}
if (rangeFilter.length > 0) {
combinedFilters.push({
is_group: true,
logical_op: 'or',
logical_op: 'and',
children: rangeFilter,
})
}
@ -323,9 +326,8 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
: await fetchSharedViewData({
...params,
sortsArr: sorts.value,
filtersArr: sideBarFilter.value,
filtersArr: [...nestedFilters.value, ...sideBarFilter.value],
offset: params.offset,
where: where?.value ?? '',
})
formattedSideBarData.value = [...formattedSideBarData.value, ...formatData(response!.list)]
} catch (e) {
@ -356,8 +358,6 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
prevDate = prevDate!.format('YYYY-MM-DD HH:mm:ssZ')
nextDate = nextDate!.format('YYYY-MM-DD HH:mm:ssZ')
const activeDateFilter: Array<any> = []
if (!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) return
try {
@ -371,7 +371,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
from_date: prevDate,
to_date: nextDate,
sortsArr: sorts.value,
filtersArr: activeDateFilter,
filtersArr: nestedFilters.value,
})
activeDates.value = res.dates.map((dateObj: unknown) => dayjs(dateObj as string))
@ -516,7 +516,6 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
from_date: prevDate,
to_date: nextDate,
filtersArr: nestedFilters.value,
where: where?.value ?? '',
})
formattedData.value = formatData(res!.list)
} catch (e) {
@ -622,7 +621,10 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
...{},
...{ filterArrJson: JSON.stringify([...sideBarFilter.value]) },
})
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: sideBarFilter.value })
: await fetchSharedViewData({
sortsArr: sorts.value,
filtersArr: [...nestedFilters.value, ...sideBarFilter.value],
})
formattedSideBarData.value = formatData(res!.list)
} catch (e) {

14
packages/nocodb/src/services/calendar-datas.service.ts

@ -44,7 +44,10 @@ export class CalendarDatasService {
to_date,
});
query.filterArr = [...(query.filterArr ? query.filterArr : []), filterArr];
query.filterArrJson = JSON.stringify([
...filterArr,
...(query.filterArrJson ? JSON.parse(query.filterArrJson) : []),
]);
const model = await Model.getByIdOrName({
id: view.fk_model_id,
@ -146,7 +149,10 @@ export class CalendarDatasService {
to_date,
});
query.filterArr = [...(query.filterArr ? query.filterArr : []), filterArr];
query.filterArrJson = JSON.stringify([
...filterArr,
...(query.filterArrJson ? JSON.parse(query.filterArrJson) : []),
]);
const model = await Model.getByIdOrName({
id: view.fk_model_id,
@ -193,7 +199,7 @@ export class CalendarDatasService {
viewId: string;
from_date: string;
to_date: string;
}) {
}): Promise<Array<FilterType>> {
const calendarRange = await CalendarRange.read(viewId);
if (!calendarRange?.ranges?.length) NcError.badRequest('No ranges found');
@ -226,6 +232,6 @@ export class CalendarDatasService {
if (rangeFilter.length > 0) filterArr.children.push(rangeFilter);
});
return filterArr;
return [filterArr];
}
}

Loading…
Cancel
Save