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
Show meetings in user's correct timezone
Oliver Günther491dc91830cb
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.tsindex 832a5cc01e7..5e6cd216780 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@@ -90,6 +90,7 @@ import { ApiV3FilterBuilder } from 'core-app/shared/helpers/api-v3/api-v3-filterimport allLocales from '@fullcalendar/core/locales-all';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { MeetingResource } from 'core-app/features/hal/resources/meeting-resource';+import { TimezoneService } from 'core-app/core/datetime/timezone.service';@Component({templateUrl: './wp-calendar.template.html',@@ -146,6 +147,7 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implementreadonly dayService:DayResourceService,readonly apiV3Service:ApiV3Service,readonly pathHelper:PathHelperService,+ readonly timezoneService:TimezoneService,) {super();}@@ -217,19 +219,19 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implement.filtered(filters, { pageSize: '-1' }).get().subscribe((meetings) => {- const events = meetings.elements.map((meeting:MeetingResource) => {+ const events:EventInput[] = meetings.elements.map((meeting:MeetingResource) => {const sameProject = this.currentProject.id === meeting.project.id;const title:string = sameProject ? meeting.title : `${meeting.project.name}: ${meeting.title}`;return {title,- start: Date.parse(meeting.startTime),- end: Date.parse(meeting.endTime),+ start: this.timezoneService.parseDatetime(meeting.startTime as string).format(),+ end: this.timezoneService.parseDatetime(meeting.endTime as string).format(),editable: false,durationEditable: false,allDay: false,className: 'fc-event-clickable op-wp-calendar--meeting-resource',meeting,- };+ } as EventInput;});successCallback(events);diff --git a/modules/calendar/spec/features/calendar_widget_spec.rb b/modules/calendar/spec/features/calendar_widget_spec.rbindex 0d7725718ce..c8e9c105fcd 100644--- a/modules/calendar/spec/features/calendar_widget_spec.rb+++ b/modules/calendar/spec/features/calendar_widget_spec.rb@@ -50,7 +50,7 @@ RSpec.describe "Calendar Widget", :js, :with_cuprite, with_settings: { start_of_let(:wp_full_view) { Pages::FullWorkPackage.new(work_package, project) }let(:calendar) { Pages::Calendar.new project }- current_user do+ shared_let(:current_user) docreate(:user,member_with_permissions: {project => %w[view_work_packages view_meetings edit_work_packages view_calendar manage_overview]@@ -58,7 +58,11 @@ RSpec.describe "Calendar Widget", :js, :with_cuprite, with_settings: { start_of_endbefore do+ login_as(current_user)overview_page.visit!++ wait_for_network_idle if RSpec.current_example.metadata[:with_cuprite]+# within top-left area, add an additional widgetoverview_page.add_widget(1, 1, :row, "Calendar")@@ -67,11 +71,33 @@ RSpec.describe "Calendar Widget", :js, :with_cuprite, with_settings: { start_of_it "shows the meeting" doexpect(page).to have_css(".fc-event", text: "Weekly", visible: :all)+page.find(".fc-event", text: "Weekly", visible: :all).clickexpect(page).to have_current_path /meetings\/#{meeting.id}/end+ context "as a user in a different timezone" do+ shared_let(:current_user) do+ create(:user,+ preferences: { time_zone: "Asia/Tokyo" },+ member_with_permissions: {+ project => %w[view_work_packages view_meetings edit_work_packages view_calendar manage_overview]+ })+ end++ it "shows the meeting in the correct timezone" do+ expect(page).to have_css(".fc-event", text: "Weekly", visible: :all)++ start_time = Time.use_zone(current_user.time_zone) { meeting.start_time.strftime("%-l:%M%P") }+ end_time = Time.use_zone(current_user.time_zone) { (meeting.start_time + 1.hour).strftime("%-l:%M%P") }+ expect(page).to have_css(".fc-event-time", text: "#{start_time} - #{end_time}", visible: :all, exact_text: false)++ page.find(".fc-event", text: "Weekly", visible: :all).click+ expect(page).to have_current_path /meetings\/#{meeting.id}/+ end+ end+it "opens the work package full view when clicking a calendar entry" do# Clicking the calendar entry goes to work package full screenpage.find(".fc-event-title", text: work_package.subject).click