Browse Source

Merge pull request #8628 from nocodb/nc-fix/cal-shared-filters

Nc fix/cal shared filters
pull/8541/merge
Ramesh Mane 6 months ago committed by GitHub
parent
commit
aaac83b6a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nc-gui/composables/useCalendarViewStore.ts
  2. 2
      packages/nocodb/src/controllers/public-datas-export.controller.ts
  3. 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, value: fromDate,
}, },
] ]
combinedFilters.push({
is_group: true,
logical_op: 'or',
children: rangeFilter,
})
} else if (fromCol) { } else if (fromCol) {
rangeFilter = [ rangeFilter = [
{ {
@ -266,11 +271,9 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
value: prevDate, value: prevDate,
}, },
] ]
}
if (rangeFilter.length > 0) {
combinedFilters.push({ combinedFilters.push({
is_group: true, is_group: true,
logical_op: 'or', logical_op: 'and',
children: rangeFilter, children: rangeFilter,
}) })
} }
@ -323,9 +326,8 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
: await fetchSharedViewData({ : await fetchSharedViewData({
...params, ...params,
sortsArr: sorts.value, sortsArr: sorts.value,
filtersArr: sideBarFilter.value, filtersArr: [...nestedFilters.value, ...sideBarFilter.value],
offset: params.offset, offset: params.offset,
where: where?.value ?? '',
}) })
formattedSideBarData.value = [...formattedSideBarData.value, ...formatData(response!.list)] formattedSideBarData.value = [...formattedSideBarData.value, ...formatData(response!.list)]
} catch (e) { } catch (e) {
@ -356,8 +358,6 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
prevDate = prevDate!.format('YYYY-MM-DD HH:mm:ssZ') prevDate = prevDate!.format('YYYY-MM-DD HH:mm:ssZ')
nextDate = nextDate!.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 if (!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) return
try { try {
@ -371,7 +371,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
from_date: prevDate, from_date: prevDate,
to_date: nextDate, to_date: nextDate,
sortsArr: sorts.value, sortsArr: sorts.value,
filtersArr: activeDateFilter, filtersArr: nestedFilters.value,
}) })
activeDates.value = res.dates.map((dateObj: unknown) => dayjs(dateObj as string)) activeDates.value = res.dates.map((dateObj: unknown) => dayjs(dateObj as string))
@ -516,7 +516,6 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
from_date: prevDate, from_date: prevDate,
to_date: nextDate, to_date: nextDate,
filtersArr: nestedFilters.value, filtersArr: nestedFilters.value,
where: where?.value ?? '',
}) })
formattedData.value = formatData(res!.list) formattedData.value = formatData(res!.list)
} catch (e) { } catch (e) {
@ -622,7 +621,10 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
...{}, ...{},
...{ filterArrJson: JSON.stringify([...sideBarFilter.value]) }, ...{ 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) formattedSideBarData.value = formatData(res!.list)
} catch (e) { } catch (e) {

2
packages/nocodb/src/controllers/public-datas-export.controller.ts

@ -40,6 +40,7 @@ export class PublicDatasExportController {
view.type !== ViewTypes.GRID && view.type !== ViewTypes.GRID &&
view.type !== ViewTypes.KANBAN && view.type !== ViewTypes.KANBAN &&
view.type !== ViewTypes.GALLERY && view.type !== ViewTypes.GALLERY &&
view.type !== ViewTypes.CALENDAR &&
view.type !== ViewTypes.MAP view.type !== ViewTypes.MAP
) )
NcError.notFound('Not found'); NcError.notFound('Not found');
@ -93,6 +94,7 @@ export class PublicDatasExportController {
view.type !== ViewTypes.GRID && view.type !== ViewTypes.GRID &&
view.type !== ViewTypes.KANBAN && view.type !== ViewTypes.KANBAN &&
view.type !== ViewTypes.GALLERY && view.type !== ViewTypes.GALLERY &&
view.type !== ViewTypes.CALENDAR &&
view.type !== ViewTypes.MAP view.type !== ViewTypes.MAP
) )
NcError.notFound('Not found'); NcError.notFound('Not found');

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

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

Loading…
Cancel
Save