[#43504] Date picker not working as expected for UTC time hour minus

- https://community.openproject.org/work_packages/43504
- (boyscouting) fixed some eslint issues in wp-calender
- (boyscouting) removed unused code in wp-calender
bug/43504-date-picker-not-working-as-expected-for-utc-time-hour-minus
Eric Schubert 2 years ago
parent 961907110e
commit 416a47aaf0
No known key found for this signature in database
GPG Key ID: 1D346C019BD4BAA2
  1. 4
      frontend/src/app/features/calendar/op-work-packages-calendar.service.ts
  2. 75
      frontend/src/app/features/calendar/wp-calendar/wp-calendar.component.ts
  3. 30
      frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts

@ -261,9 +261,9 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {
/** /**
* The end date from fullcalendar is open, which means it targets * The end date from fullcalendar is open, which means it targets
* the next day instead of current day 23:59:59. * the next day instead of current day 23:59:59.
* @param end * @param end A string representation of the end date
*/ */
public getEndDateFromTimestamp(end:Date):string { public getEndDateFromTimestamp(end:string):string {
return moment(end).subtract(1, 'd').format('YYYY-MM-DD'); return moment(end).subtract(1, 'd').format('YYYY-MM-DD');
} }

@ -1,3 +1,31 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2022 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++
import { import {
Component, Component,
ElementRef, ElementRef,
@ -6,37 +34,37 @@ import {
ViewChild, ViewChild,
} from '@angular/core'; } from '@angular/core';
import { import {
EventClickArg, CalendarOptions,
FullCalendarComponent, DateSelectArg,
ToolbarInput, EventDropArg,
} from '@fullcalendar/angular'; EventInput,
} from '@fullcalendar/core';
import { EventClickArg, FullCalendarComponent, ToolbarInput } from '@fullcalendar/angular';
import dayGridPlugin from '@fullcalendar/daygrid';
import * as moment from 'moment';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { States } from 'core-app/core/states/states.service'; import { States } from 'core-app/core/states/states.service';
import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space'; import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource'; import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { WorkPackageCollectionResource } from 'core-app/features/hal/resources/wp-collection-resource'; import { WorkPackageCollectionResource } from 'core-app/features/hal/resources/wp-collection-resource';
import { WorkPackageViewFiltersService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service'; import {
import * as moment from 'moment'; WorkPackageViewFiltersService,
} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';
import { WorkPackagesListService } from 'core-app/features/work-packages/components/wp-list/wp-list.service'; import { WorkPackagesListService } from 'core-app/features/work-packages/components/wp-list/wp-list.service';
import { StateService } from '@uirouter/core'; import { StateService } from '@uirouter/core';
import { I18nService } from 'core-app/core/i18n/i18n.service'; import { I18nService } from 'core-app/core/i18n/i18n.service';
import { ToastService } from 'core-app/shared/components/toaster/toast.service'; import { ToastService } from 'core-app/shared/components/toaster/toast.service';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { OpTitleService } from 'core-app/core/html/op-title.service';
import dayGridPlugin from '@fullcalendar/daygrid';
import {
CalendarOptions,
DateSelectArg,
EventDropArg,
EventInput,
} from '@fullcalendar/core';
import { debounceTime } from 'rxjs/operators';
import { ConfigurationService } from 'core-app/core/config/configuration.service'; import { ConfigurationService } from 'core-app/core/config/configuration.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin'; import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service'; import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
import { Subject } from 'rxjs';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service'; import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import interactionPlugin, { EventResizeDoneArg } from '@fullcalendar/interaction'; import interactionPlugin, { EventResizeDoneArg } from '@fullcalendar/interaction';
import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service'; import {
HalResourceEditingService,
} from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service'; import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';
import { splitViewRoute } from 'core-app/features/work-packages/routing/split-view-routes.helper'; import { splitViewRoute } from 'core-app/features/work-packages/routing/split-view-routes.helper';
import { import {
@ -75,7 +103,6 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implement
readonly wpListService:WorkPackagesListService, readonly wpListService:WorkPackagesListService,
readonly querySpace:IsolatedQuerySpace, readonly querySpace:IsolatedQuerySpace,
readonly schemaCache:SchemaCacheService, readonly schemaCache:SchemaCacheService,
readonly titleService:OpTitleService,
private element:ElementRef, private element:ElementRef,
readonly i18n:I18nService, readonly i18n:I18nService,
readonly toastService:ToastService, readonly toastService:ToastService,
@ -218,7 +245,7 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implement
} }
private mapToCalendarEvents(workPackages:WorkPackageResource[]) { private mapToCalendarEvents(workPackages:WorkPackageResource[]) {
const events = workPackages.map((workPackage:WorkPackageResource) => { return workPackages.map((workPackage:WorkPackageResource) => {
const startDate = this.workPackagesCalendar.eventDate(workPackage, 'start'); const startDate = this.workPackagesCalendar.eventDate(workPackage, 'start');
const endDate = this.workPackagesCalendar.eventDate(workPackage, 'due'); const endDate = this.workPackagesCalendar.eventDate(workPackage, 'due');
@ -230,16 +257,10 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implement
editable: this.workPackagesCalendar.eventDurationEditable(workPackage), editable: this.workPackagesCalendar.eventDurationEditable(workPackage),
end: exclusiveEnd, end: exclusiveEnd,
allDay: true, allDay: true,
className: `__hl_background_type_${workPackage.type.id}`, className: `__hl_background_type_${workPackage.type.id || ''}`,
workPackage, workPackage,
}; };
}); });
return events;
}
private get initialView():string|undefined {
return this.static ? 'dayGridWeek' : undefined;
} }
private async updateEvent(info:EventResizeDoneArg|EventDropArg):Promise<void> { private async updateEvent(info:EventResizeDoneArg|EventDropArg):Promise<void> {
@ -257,7 +278,7 @@ export class WorkPackagesCalendarComponent extends UntilDestroyedMixin implement
private handleDateClicked(info:DateSelectArg) { private handleDateClicked(info:DateSelectArg) {
const defaults = { const defaults = {
startDate: info.startStr, startDate: info.startStr,
dueDate: this.workPackagesCalendar.getEndDateFromTimestamp(info.end), dueDate: this.workPackagesCalendar.getEndDateFromTimestamp(info.endStr),
}; };
void this.$state.go( void this.$state.go(

@ -1,3 +1,31 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2022 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++
import { import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
Component, Component,
@ -713,7 +741,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
this.openNewSplitCreate( this.openNewSplitCreate(
info.startStr, info.startStr,
// end date is exclusive // end date is exclusive
this.workPackagesCalendar.getEndDateFromTimestamp(info.end), this.workPackagesCalendar.getEndDateFromTimestamp(info.endStr),
info.resource?.id || '', info.resource?.id || '',
); );
} }

Loading…
Cancel
Save