Save calendar view (month vs week) in url param

pull/9977/head
Henriette Darge 3 years ago
parent ccf14a2ed5
commit 65de1f4b03
  1. 4
      frontend/src/app/features/calendar/calendar.routes.ts
  2. 10
      frontend/src/app/features/calendar/op-calendar.service.ts
  3. 6
      frontend/src/app/features/calendar/wp-calendar/wp-calendar.component.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' },
},

@ -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,
},
);
}
}

@ -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;
})(),
}),
);
});

Loading…
Cancel
Save