Browse Source

fix(nocodb): fk_view_id missing in calendar_view_range

pull/7611/head
DarkPhoenix2704 9 months ago
parent
commit
4dde683c35
  1. 3
      packages/nocodb/src/controllers/calendars.controller.ts
  2. 2
      packages/nocodb/src/models/CalendarRange.ts
  3. 38
      packages/nocodb/src/models/CalendarView.ts
  4. 2
      packages/nocodb/src/models/View.ts
  5. 9
      packages/nocodb/src/schema/swagger.json

3
packages/nocodb/src/controllers/calendars.controller.ts

@ -55,7 +55,8 @@ export class CalendarsController {
'/api/v1/db/meta/calendars/:calendarViewId',
'/api/v2/meta/calendars/:calendarViewId',
])
@Acl('calendarViewUpdate')
// #TODO Enable ACL Later
// @Acl('calendarViewUpdate')
async calendarViewUpdate(
@Param('calendarViewId') calendarViewId: string,
@Body() body,

2
packages/nocodb/src/models/CalendarRange.ts

@ -100,7 +100,7 @@ export default class CalendarRange implements CalendarRangeType {
}
public static async read(fk_view_id: string, ncMeta = Noco.ncMeta) {
const cachedList = await NocoCache.getList(CacheScope.CALENDAR_VIEW, [
const cachedList = await NocoCache.getList(CacheScope.CALENDAR_VIEW_RANGE, [
fk_view_id,
]);
let { list: ranges } = cachedList;

38
packages/nocodb/src/models/CalendarView.ts

@ -5,6 +5,7 @@ import {extractProps} from '~/helpers/extractProps';
import NocoCache from '~/cache/NocoCache';
import Noco from '~/Noco';
import {CacheGetType, CacheScope, MetaTable} from '~/utils/globals';
import CalendarRange from "~/models/CalendarRange";
export default class CalendarView implements CalendarType {
fk_view_id: string;
@ -12,7 +13,7 @@ export default class CalendarView implements CalendarType {
base_id?: string;
source_id?: string;
meta?: MetaType;
calendar_range?: Array<Partial<CalendarRange>>
fk_cover_image_col_id?: string;
// below fields are not in use at this moment
// keep them for time being
@ -32,10 +33,21 @@ export default class CalendarView implements CalendarType {
`${CacheScope.CALENDAR_VIEW}:${viewId}`,
CacheGetType.TYPE_OBJECT,
));
if (!view) {
if (view) {
const calendarRange = await CalendarRange.read(viewId, ncMeta);
if (calendarRange) {
view.calendar_range = calendarRange.ranges;
} else {
view.calendar_range = [];
}
} else {
view = await ncMeta.metaGet2(null, null, MetaTable.CALENDAR_VIEW, {
fk_view_id: viewId,
});
const calendarRange = await CalendarRange.read(viewId);
if (calendarRange) {
view.calendar_range = calendarRange.ranges;
}
await NocoCache.set(`${CacheScope.CALENDAR_VIEW}:${viewId}`, view);
}
@ -83,18 +95,18 @@ export default class CalendarView implements CalendarType {
await NocoCache.set(key, o);
}
// TODO: Update this when API is ready
/*if (body.fk_geo_data_col_id != null) {
const mapViewColumns = await MapViewColumn.list(mapId);
const mapViewMappedByColumn = mapViewColumns.find(
(mapViewColumn) =>
mapViewColumn.fk_column_id === body.fk_geo_data_col_id,
);
await View.updateColumn(body.fk_view_id, mapViewMappedByColumn.id, {
show: true,
if (body.calendar_range) {
await NocoCache.del(`${CacheScope.CALENDAR_VIEW_RANGE}:${calendarId}`);
await ncMeta.metaDelete(null, null, MetaTable.CALENDAR_VIEW_RANGE, {}, {
fk_view_id: calendarId,
});
}*/
await CalendarRange.bulkInsert(body.calendar_range.map((range) => {
return {
fk_view_id: calendarId,
...range
}
}));
}
// update meta
return await ncMeta.metaUpdate(null, null, MetaTable.CALENDAR_VIEW, updateObj, {
fk_view_id: calendarId,

2
packages/nocodb/src/models/View.ts

@ -63,7 +63,6 @@ export default class View implements ViewType {
| MapViewColumn
| CalendarViewColumn
>;
calendar_range?: Array<CalendarRange>;
sorts: Sort[];
filter: Filter;
@ -135,7 +134,6 @@ export default class View implements ViewType {
break;
case ViewTypes.CALENDAR:
this.view = await CalendarView.get(this.id, ncMeta);
this.calendar_range = (await CalendarRange.read(this.id, ncMeta)).ranges;
break;
}
return this.view;

9
packages/nocodb/src/schema/swagger.json

@ -20332,6 +20332,13 @@
"$ref": "#/components/schemas/CalendarColumn"
}
},
"calendar_range": {
"type": "array",
"description": "Calendar Date Range",
"items": {
"$ref": "#/components/schemas/CalendarRange"
}
},
"meta": {
"$ref": "#/components/schemas/Meta",
"description": "Meta Info for Kanban"
@ -20519,7 +20526,7 @@
"type": "array",
"description": "Calendar Columns",
"items": {
"$ref": "#/components/schemas/CalendarDateRange"
"$ref": "#/components/schemas/CalendarRange"
}
},
"meta": {

Loading…
Cancel
Save