From a15a7b547cb96f9c42627cc3ef12170a520623b2 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Tue, 20 Feb 2024 07:15:47 +0000 Subject: [PATCH] fix(nocodb): include calendar range in views --- .../controllers/calendars.controller.spec.ts | 21 +++++++++++++++++++ packages/nocodb/src/models/CalendarRange.ts | 8 +++---- packages/nocodb/src/models/View.ts | 4 +++- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 packages/nocodb/src/controllers/calendars.controller.spec.ts diff --git a/packages/nocodb/src/controllers/calendars.controller.spec.ts b/packages/nocodb/src/controllers/calendars.controller.spec.ts new file mode 100644 index 0000000000..f4c472c0af --- /dev/null +++ b/packages/nocodb/src/controllers/calendars.controller.spec.ts @@ -0,0 +1,21 @@ +import { Test } from '@nestjs/testing'; +import { CalendarsService } from '../services/calendars.service'; +import { CalendarsController } from './calendars.controller'; +import type { TestingModule } from '@nestjs/testing'; + +describe('CalendarsController', () => { + let controller: CalendarsController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [CalendarsController], + providers: [CalendarsService], + }).compile(); + + controller = module.get(CalendarsController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/packages/nocodb/src/models/CalendarRange.ts b/packages/nocodb/src/models/CalendarRange.ts index c4226728d3..f6bd4bde3e 100644 --- a/packages/nocodb/src/models/CalendarRange.ts +++ b/packages/nocodb/src/models/CalendarRange.ts @@ -5,10 +5,10 @@ import {extractProps} from '~/helpers/extractProps'; import {CacheGetType, CacheScope, MetaTable} from '~/utils/globals'; export default class CalendarRange implements CalendarRangeType { - id: string; - fk_from_column_id: string; - fk_to_column_id: string | null; - fk_view_id: string; + id?: string; + fk_from_column_id?: string; + fk_to_column_id?: string | null; + fk_view_id?: string; constructor(data: Partial) { Object.assign(this, data); diff --git a/packages/nocodb/src/models/View.ts b/packages/nocodb/src/models/View.ts index bba1eedc84..c523030d11 100644 --- a/packages/nocodb/src/models/View.ts +++ b/packages/nocodb/src/models/View.ts @@ -63,6 +63,7 @@ export default class View implements ViewType { | MapViewColumn | CalendarViewColumn >; + calendar_range?: Array; sorts: Sort[]; filter: Filter; @@ -134,6 +135,7 @@ 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; @@ -280,7 +282,7 @@ export default class View implements ViewType { Partial & { copy_from_id?: string; fk_grp_col_id?: string; - calendar_range?: Partial[]; + calendar_range?: Partial[]; }, ncMeta = Noco.ncMeta, ) {