Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Save calendar view (month vs week) in url param

Henriette Darge65de1f4b0357
diff --git a/frontend/src/app/features/calendar/calendar.routes.ts b/frontend/src/app/features/calendar/calendar.routes.ts
index 5ba021d2a43..165afe392ec 100644
--- a/frontend/src/app/features/calendar/calendar.routes.ts
+++ b/frontend/src/app/features/calendar/calendar.routes.ts
@@ -37,13 +37,15 @@ export const CALENDAR_ROUTES:Ng2StateDeclaration[] = [
{
name: 'calendar',
parent: 'optional_project',
- url: '/calendar?query_id&query_props',
+ url: '/calendar?query_id&query_props&cdate&cview',
redirectTo: 'calendar.page',
views: {
'!$default': { component: WorkPackagesBaseComponent },
},
params: {
query_id: { type: 'query', dynamic: true },
+ cdate: { type: 'string', dynamic: true },
+ cview: { type: 'string', dynamic: true },
// Use custom encoder/decoder that ensures validity of URL string
query_props: { type: 'opQueryString' },
},
diff --git a/frontend/src/app/features/calendar/op-calendar.service.ts b/frontend/src/app/features/calendar/op-calendar.service.ts
index b97953cb1e7..a5ffeaa65c9 100644
--- a/frontend/src/app/features/calendar/op-calendar.service.ts
+++ b/frontend/src/app/features/calendar/op-calendar.service.ts
@@ -243,6 +243,7 @@ export class OpCalendarService extends UntilDestroyedMixin {
right: '',
},
initialDate: this.initialDate,
+ initialView: this.initialView,
datesSet: (dates) => this.updateDateParam(dates),
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eventClick: this.openSplitView.bind(this),
@@ -352,10 +353,17 @@ export class OpCalendarService extends UntilDestroyedMixin {
return undefined;
}
+ private get initialView():string|undefined {
+ return this.urlParams.cview as string|undefined;
+ }
+
private updateDateParam(dates:DatesSetArg) {
void this.$state.go(
'.',
- { cdate: this.timezoneService.formattedISODate(dates.start) },
+ {
+ cdate: this.timezoneService.formattedISODate(dates.view.currentStart),
+ cview: dates.view.type,
+ },
);
}
}
diff --git a/frontend/src/app/features/calendar/wp-calendar/wp-calendar.component.ts b/frontend/src/app/features/calendar/wp-calendar/wp-calendar.component.ts
index b443fa9e283..28bc6251725 100644
--- a/frontend/src/app/features/calendar/wp-calendar/wp-calendar.component.ts
+++ b/frontend/src/app/features/calendar/wp-calendar/wp-calendar.component.ts
@@ -127,12 +127,6 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implement
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
events: this.calendarEventsFunction.bind(this),
plugins: [dayGridPlugin],
- initialView: (() => {
- if (this.static) {
- return 'dayGridWeek';
- }
- return undefined;
- })(),
}),
);
});