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
[47057] Non-working Days/Holidays selection with 12.5 update (#12397)
Behrokh Satarnejadd7fc8505ae8e
diff --git a/frontend/src/app/features/calendar/op-calendar.service.ts b/frontend/src/app/features/calendar/op-calendar.service.tsindex 8b9ae2ad1c5..845373979cb 100644--- a/frontend/src/app/features/calendar/op-calendar.service.ts+++ b/frontend/src/app/features/calendar/op-calendar.service.ts@@ -34,11 +34,14 @@ export class OpCalendarService extends UntilDestroyedMixin {}applyNonWorkingDay({ date }:{ date?:Date }, nonWorkingDays:IDay[]):string[] {- const formatted = moment(date).format('YYYY-MM-DD');- if (date && (this.weekdayService.isNonWorkingDay(date) || nonWorkingDays.find((el) => el.date === formatted))) {- return ['fc-non-working-day'];+ if (date) {+ // we need to find the UTC date for each date while highlighting non-wrking days on full-calendar+ const utcDate = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());+ const formatted = moment(utcDate).format('YYYY-MM-DD');+ if (this.weekdayService.isNonWorkingDay(utcDate) || nonWorkingDays.find((el) => el.date === formatted)) {+ return ['fc-non-working-day'];+ }}-return [];}}diff --git a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.tsindex 28f68c11eee..9190960e948 100644--- a/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts+++ b/frontend/src/app/shared/components/datepicker/modal-single-date-picker/modal-single-date-picker.component.ts@@ -270,8 +270,11 @@ export class OpModalSingleDatePickerComponent implements ControlValueAccessor, O}writeWorkingValue(value:string):void {+ const date = new Date(value);+ // since new Date() returns a date in our local timezone, we need to find the UTC date+ const utcDate = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());this.workingValue = value;- this.workingDate = new Date(value);+ this.workingDate = utcDate;}writeValue(value:string):void {diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rbindex 03b1a0c0de6..035de2e154c 100644--- a/spec/features/admin/working_days_spec.rb+++ b/spec/features/admin/working_days_spec.rb@@ -189,6 +189,10 @@ describe 'Working Days', js: true doit 'can add non-working days' doclick_on 'Non-working day'+ # Check if a date is correctly highlighted after selecting it in different time zones+ datepicker.select_day 5+ datepicker.expect_day '5'+# It can cancel and reopenpage.within('[data-qa-selector="op-datepicker-modal"]') doclick_on 'Cancel'