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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix changes in upgrade of fullcalendar
Oliver Günthera3acfdc9fcba
diff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sassindex 1d9eefc3c3d..7296d65a099 100644--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass@@ -1,4 +1,4 @@-.fc-view-container+.fc-viewoverflow-x: auto.fc-viewdiff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.tsindex 3af0fece8e5..b3e18bea715 100644--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts@@ -332,7 +332,7 @@ export class TimeEntryCalendarComponent implements AfterViewInit {}private get calendarElement() {- return jQuery(this.element.nativeElement).find('.fc-view-container');+ return jQuery(this.element.nativeElement).find('full-calendar');}private dispatchEventClick(event:CalendarViewEvent) {@@ -476,7 +476,7 @@ export class TimeEntryCalendarComponent implements AfterViewInit {let formattedDuration = this.timezone.formattedDuration(event.event.extendedProps.entry.hours);jQuery(event.el)- .find('.fc-title')+ .find('.fc-event-title').prepend(`<div class="fc-duration">${formattedDuration}</div>`);}diff --git a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.tsindex 4c0d0ba52f1..6975844ed3b 100644--- a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts+++ b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts@@ -1,4 +1,13 @@-import {AfterViewInit, Component, ElementRef, Input, OnInit, SecurityContext, ViewChild} from "@angular/core";+import {+ AfterViewInit,+ ChangeDetectorRef,+ Component,+ ElementRef,+ Input,+ OnInit,+ SecurityContext,+ ViewChild+} from "@angular/core";import {FullCalendarComponent} from '@fullcalendar/angular';import {States} from "core-components/states.service";import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";@@ -31,8 +40,27 @@ interface CalendarViewEvent {styleUrls: ['./wp-calendar.sass'],selector: 'wp-calendar',})-export class WorkPackagesCalendarController extends UntilDestroyedMixin implements OnInit, AfterViewInit {- @ViewChild(FullCalendarComponent) ucCalendar:FullCalendarComponent;+export class WorkPackagesCalendarController extends UntilDestroyedMixin implements OnInit {+ private ucCalendar:FullCalendarComponent;+ @ViewChild(FullCalendarComponent)+ set container(v:FullCalendarComponent|undefined) {+ // ViewChild reference may be undefined initially+ // due to ngIf+ if (v !== undefined) {+ this.ucCalendar = v;++ // The full-calendar component's outputs do not seem to work+ // see: https://github.com/fullcalendar/fullcalendar-angular/issues/228#issuecomment-523505044+ // Therefore, setting the outputs via the underlying API+ this.ucCalendar.getApi().setOption('eventDidMount', (event:CalendarViewEvent) => {+ this.addTooltip(event);+ });+ this.ucCalendar.getApi().setOption('eventClick', (event:CalendarViewEvent) => {+ this.toWPFullView(event);+ });+ }+ }+@Input() projectIdentifier:string;@Input() static:boolean = false;static MAX_DISPLAYED = 100;@@ -41,22 +69,7 @@ export class WorkPackagesCalendarController extends UntilDestroyedMixin implemenprivate alreadyLoaded = false;- calendarOptions:CalendarOptions = {- editable: false,- locale: this.i18n.locale,- fixedWeekCount: false,- height: undefined,- initialView: (() => {- if (this.static) {- return 'dayGridWeek';- } else {- return undefined;- }- })(),- firstDay: this.configuration.startOfWeek(),- events: this.calendarEventsFunction.bind(this),- plugins: [dayGridPlugin],- };+ calendarOptions:CalendarOptions|undefined;constructor(readonly states:States,readonly $state:StateService,@@ -79,20 +92,7 @@ export class WorkPackagesCalendarController extends UntilDestroyedMixin implementhis.querySpace.stopAllSubscriptions.next();this.setupWorkPackagesListener();- }-- ngAfterViewInit() {this.initializeCalendar();-- // The full-calendar component's outputs do not seem to work- // see: https://github.com/fullcalendar/fullcalendar-angular/issues/228#issuecomment-523505044- // Therefore, setting the outputs via the underlying API- this.ucCalendar.getApi().setOption('eventDidMount', (event:CalendarViewEvent) => {- this.addTooltip(event);- });- this.ucCalendar.getApi().setOption('eventClick', (event:CalendarViewEvent) => {- this.toWPFullView(event);- });}public calendarEventsFunction(fetchInfo:{ start:Date, end:Date, timeZone:string },@@ -117,7 +117,19 @@ export class WorkPackagesCalendarController extends UntilDestroyedMixin implemenprivate initializeCalendar() {this.calendarOptions = {- ...this.calendarOptions,+ editable: false,+ locale: this.i18n.locale,+ fixedWeekCount: false,+ firstDay: this.configuration.startOfWeek(),+ events: this.calendarEventsFunction.bind(this),+ plugins: [dayGridPlugin],+ initialView: (() => {+ if (this.static) {+ return 'dayGridWeek';+ } else {+ return undefined;+ }+ })(),height: this.calendarHeight(),headerToolbar: this.buildHeader()};@@ -183,7 +195,7 @@ export class WorkPackagesCalendarController extends UntilDestroyedMixin implemen{ inherit: false });}private get calendarElement() {- return jQuery(this.element.nativeElement).find('.fc-view-container');+ return jQuery(this.element.nativeElement).find('full-calendar');}private calendarHeight():number {diff --git a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.template.html b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.template.htmlindex 4073a60dc67..f854f10d4d6 100644--- a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.template.html+++ b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.template.html@@ -3,6 +3,7 @@[attr.data-indicator-name]="'table'"style="position: relative"><full-calendar #ucCalendar+ *ngIf="calendarOptions"[options]="calendarOptions"></full-calendar><divdiff --git a/modules/dashboards/spec/features/work_package_calendar_spec.rb b/modules/dashboards/spec/features/work_package_calendar_spec.rbindex 648ef7a913b..79a0799d8f9 100644--- a/modules/dashboards/spec/features/work_package_calendar_spec.rb+++ b/modules/dashboards/spec/features/work_package_calendar_spec.rb@@ -127,19 +127,19 @@ describe 'Work package calendar widget on dashboard',within(calendar_widget.area) doexpect(page)- .to have_selector('.fc-event-container', text: spanning_work_package.subject)+ .to have_selector('.fc-event-title', text: spanning_work_package.subject)expect(page)- .to have_selector('.fc-event-container', text: starting_work_package.subject)+ .to have_selector('.fc-event-title', text: starting_work_package.subject)expect(page)- .to have_selector('.fc-event-container', text: ending_work_package.subject)+ .to have_selector('.fc-event-title', text: ending_work_package.subject)expect(page)- .to have_no_selector('.fc-event-container', text: outdated_work_package.subject)+ .to have_no_selector('.fc-event-title', text: outdated_work_package.subject)expect(page)- .to have_no_selector('.fc-event-container', text: other_project_work_package.subject)+ .to have_no_selector('.fc-event-title', text: other_project_work_package.subject)endendenddiff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rbindex 87f586380a8..e8070b91abf 100644--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb@@ -124,12 +124,12 @@ describe 'My page time entries current user widget spec', type: :feature, js: trexpect(page).to have_content visible_time_entry.spent_on.strftime('%-m/%-d')expect(page)- .to have_selector('.fc-event .fc-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")+ .to have_selector('.fc-event .fc-event-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")expect(page).to have_content(other_visible_time_entry.spent_on.strftime('%-m/%-d'))expect(page)- .to have_selector('.fc-event .fc-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")+ .to have_selector('.fc-event .fc-event-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")# go to last weekwithin entries_area.area do@@ -142,7 +142,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: trexpect(page).to have_content(last_week_visible_time_entry.spent_on.strftime('%-m/%-d'))expect(page)- .to have_selector('.fc-event .fc-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")+ .to have_selector('.fc-event .fc-event-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")# go to today againwithin entries_area.area do@@ -153,7 +153,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr.to have_content "Total: 5.00"within entries_area.area do- find(".fc-content-skeleton td:nth-of-type(3) .fc-event-container .te-calendar--time-entry").hover+ find(".te-calendar--time-entry", match: :first).hoverendexpect(page)@@ -163,7 +163,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr# The add time entry event is invisiblewithin entries_area.area do- find(".fc-content-skeleton td:nth-of-type(5) .te-calendar--add-entry", visible: false).click+ find("td.fc-timegrid-col:nth-of-type(5) .te-calendar--add-entry", visible: false).clickendtime_logging_modal.is_visible true@@ -194,7 +194,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: trwithin entries_area.area doexpect(page)- .to have_selector(".fc-content-skeleton td:nth-of-type(5) .fc-event-container .te-calendar--time-entry",+ .to have_selector("td.fc-timegrid-col:nth-of-type(5) .te-calendar--time-entry",text: other_work_package.subject)end@@ -207,7 +207,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr## Editing an entrywithin entries_area.area do- find(".fc-content-skeleton td:nth-of-type(3) .fc-event-container .te-calendar--time-entry").click+ find("td.fc-timegrid-col:nth-of-type(3) .te-calendar--time-entry").clickendtime_logging_modal.is_visible true@@ -231,7 +231,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: trmy_page.expect_and_dismiss_notification message: I18n.t(:notice_successful_update)within entries_area.area do- find(".fc-content-skeleton td:nth-of-type(3) .fc-event-container .te-calendar--time-entry").hover+ find("td.fc-timegrid-col:nth-of-type(3) .te-calendar--time-entry").hoverendexpect(page)@@ -267,8 +267,8 @@ describe 'My page time entries current user widget spec', type: :feature, js: trwithin entries_area.area do# to place the tooltip at a different spot- find(".fc-content-skeleton td:nth-of-type(5) .fc-event-container .te-calendar--time-entry").hover- find(".fc-content-skeleton td:nth-of-type(5) .fc-event-container .te-calendar--time-entry").click+ find("td.fc-timegrid-col:nth-of-type(5) .te-calendar--time-entry").hover+ find("td.fc-timegrid-col:nth-of-type(5) .te-calendar--time-entry").clickendtime_logging_modal.is_visible true@@ -279,7 +279,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: trwithin entries_area.area doexpect(page)- .not_to have_selector(".fc-content-skeleton td:nth-of-type(5) .fc-event-container .te-calendar--time-entry")+ .not_to have_selector("td.fc-timegrid-col:nth-of-type(5) .te-calendar--time-entry")endexpect(TimeEntry.where(id: other_visible_time_entry.id))@@ -294,10 +294,10 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr.to have_content(/#{Regexp.escape(I18n.t('js.grid.widgets.time_entries_current_user.title'))}/i)expect(page)- .to have_selector(".fc-event-container .te-calendar--time-entry", count: 1)+ .to have_selector(".te-calendar--time-entry", count: 1)expect(page)- .not_to have_selector('.fc-day-header', text: 'Mon')+ .not_to have_selector('.fc-col-header-cell', text: 'Mon')end# Removing the widgetdiff --git a/spec/features/calendars/calendars_spec.rb b/spec/features/calendars/calendars_spec.rbindex ec75ed97f2e..426dcf33d8b 100644--- a/spec/features/calendars/calendars_spec.rb+++ b/spec/features/calendars/calendars_spec.rb@@ -80,13 +80,13 @@ describe 'Work package calendars', type: :feature, js: true do# should open the calendar with the current month displayedexpect(page)- .to have_selector '.fc-event-container', text: current_work_package.subject+ .to have_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_selector '.fc-event', text: another_current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: future_work_package.subject+ .to have_no_selector '.fc-event', text: future_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: another_future_work_package.subject+ .to have_no_selector '.fc-event', text: another_future_work_package.subjectfilters.expect_filter_count 1@@ -99,9 +99,9 @@ describe 'Work package calendars', type: :feature, js: true do# non matching work packages are no longer displayedexpect(page)- .to have_no_selector '.fc-event-container', text: current_work_package.subject+ .to have_no_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_selector '.fc-event', text: another_current_work_package.subject# The filter for the time frame added implicitly should not be visiblefilters.expect_filter_count 2@@ -110,25 +110,25 @@ describe 'Work package calendars', type: :feature, js: true dofind('.fc-next-button').clickexpect(page)- .to have_no_selector '.fc-event-container', text: current_work_package.subject+ .to have_no_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_no_selector '.fc-event', text: another_current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: future_work_package.subject+ .to have_no_selector '.fc-event', text: future_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_future_work_package.subject+ .to have_selector '.fc-event', text: another_future_work_package.subject# removing the filter will show the event againfilters.remove_filter 'subject'expect(page)- .to have_no_selector '.fc-event-container', text: current_work_package.subject+ .to have_no_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_no_selector '.fc-event', text: another_current_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: future_work_package.subject+ .to have_selector '.fc-event', text: future_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_future_work_package.subject+ .to have_selector '.fc-event', text: another_future_work_package.subjectfuture_url = current_url@@ -136,40 +136,40 @@ describe 'Work package calendars', type: :feature, js: true dofind('.fc-prev-button').clickexpect(page)- .to have_selector '.fc-event-container', text: current_work_package.subject+ .to have_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_selector '.fc-event', text: another_current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: future_work_package.subject+ .to have_no_selector '.fc-event', text: future_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: another_future_work_package.subject+ .to have_no_selector '.fc-event', text: another_future_work_package.subject# open the page via the url should show the next month againvisit future_urlexpect(page)- .to have_no_selector '.fc-event-container', text: current_work_package.subject+ .to have_no_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_no_selector '.fc-event', text: another_current_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: future_work_package.subject+ .to have_selector '.fc-event', text: future_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_future_work_package.subject+ .to have_selector '.fc-event', text: another_future_work_package.subject# go back a month by using the browser back functionalitypage.execute_script('window.history.back()')expect(page)- .to have_selector '.fc-event-container', text: current_work_package.subject+ .to have_selector '.fc-event', text: current_work_package.subjectexpect(page)- .to have_selector '.fc-event-container', text: another_current_work_package.subject+ .to have_selector '.fc-event', text: another_current_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: future_work_package.subject+ .to have_no_selector '.fc-event', text: future_work_package.subjectexpect(page)- .to have_no_selector '.fc-event-container', text: another_future_work_package.subject+ .to have_no_selector '.fc-event', text: another_future_work_package.subject# click goes to work package show page- page.find('.fc-event-container', text: current_work_package.subject).click+ page.find('.fc-event', text: current_work_package.subject).clickexpect(page).to have_selector('.subject-header', text: current_work_package.subject)@@ -180,10 +180,10 @@ describe 'Work package calendars', type: :feature, js: true do# click goes to work package show pageexpect(page)- .to have_selector('.fc-event-container', text: current_work_package.subject, wait: 20)+ .to have_selector('.fc-event', text: current_work_package.subject, wait: 20)# click goes to work package show page again- page.find('.fc-event-container', text: current_work_package.subject).click+ page.find('.fc-event', text: current_work_package.subject).clickexpect(page).to have_selector('.subject-header', text: current_work_package.subject)@@ -192,6 +192,6 @@ describe 'Work package calendars', type: :feature, js: true dopage.find('.work-packages-back-button').clickexpect(page)- .to have_selector '.fc-event-container', text: current_work_package.subject, wait: 20+ .to have_selector '.fc-event', text: current_work_package.subject, wait: 20endend