From 3c87991c3456d5c6ca204aef3cf4c878a376d827 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 1 Jun 2024 11:29:24 +0000 Subject: [PATCH 1/2] fix: calendar shared view, range filters not working causing listing all rows with view filter only applied --- .../composables/useCalendarViewStore.ts | 22 ++++++++++--------- .../src/services/calendar-datas.service.ts | 14 ++++++++---- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/nc-gui/composables/useCalendarViewStore.ts b/packages/nc-gui/composables/useCalendarViewStore.ts index 2e57921a5f..72dbfc82d4 100644 --- a/packages/nc-gui/composables/useCalendarViewStore.ts +++ b/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 = [] - 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) { diff --git a/packages/nocodb/src/services/calendar-datas.service.ts b/packages/nocodb/src/services/calendar-datas.service.ts index ae28762c95..f547d3c958 100644 --- a/packages/nocodb/src/services/calendar-datas.service.ts +++ b/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> { 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]; } } From 114af828388ea7ab7dbe046b9a4054c2ca47a57a Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 1 Jun 2024 11:29:24 +0000 Subject: [PATCH 2/2] fix: calendar shared viewm download csv, excel failing --- .../nocodb/src/controllers/public-datas-export.controller.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/nocodb/src/controllers/public-datas-export.controller.ts b/packages/nocodb/src/controllers/public-datas-export.controller.ts index 1359ef2ed6..97d5674976 100644 --- a/packages/nocodb/src/controllers/public-datas-export.controller.ts +++ b/packages/nocodb/src/controllers/public-datas-export.controller.ts @@ -40,6 +40,7 @@ export class PublicDatasExportController { view.type !== ViewTypes.GRID && view.type !== ViewTypes.KANBAN && view.type !== ViewTypes.GALLERY && + view.type !== ViewTypes.CALENDAR && view.type !== ViewTypes.MAP ) NcError.notFound('Not found'); @@ -93,6 +94,7 @@ export class PublicDatasExportController { view.type !== ViewTypes.GRID && view.type !== ViewTypes.KANBAN && view.type !== ViewTypes.GALLERY && + view.type !== ViewTypes.CALENDAR && view.type !== ViewTypes.MAP ) NcError.notFound('Not found');