Skip to content

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

Merge remote-tracking branch 'origin/dev' into feature/41341-updated-date-picker-drop-modal-including-duration-and-non-working-days

Henriette Dargee13adcc543f8
diff --cc frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts
index b1266349c26,9b7a8cb6d3d..7780300e797
--- a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts
@@@ -26,17 -26,10 +26,14 @@@
// See COPYRIGHT and LICENSE files for more details.
//++
- import { Component, OnDestroy, OnInit } from '@angular/core';
- import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
- import { OpModalService } from 'core-app/shared/components/modal/modal.service';
- import { DateEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component';
- import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';
- import { TimezoneService } from 'core-app/core/datetime/timezone.service';
- import { SingleDateModalComponent } from 'core-app/shared/components/datepicker/single-date-modal/single-date.modal';
- import { take } from 'rxjs/operators';
- import { Observable } from 'rxjs';
- import { MultiDateModalComponent } from 'core-app/shared/components/datepicker/multi-date-modal/multi-date.modal';
-import { ChangeDetectionStrategy, Component } from '@angular/core';
++import {
++ ChangeDetectionStrategy,
++ Component,
++} from '@angular/core';
+ import { DatePickerEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/date-picker-edit-field.component';
+ import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
+
+
@Component({
template: `
<input [value]="dates"
diff --cc frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts
index 00000000000,59a25db7943..02590ccfdd4
mode 000000,100644..100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts
@@@ -1,0 -1,87 +1,90 @@@
+ /*
+ * OpenProject is an open source project management software.
+ * Copyright (C) 2010-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 {
+ Directive,
+ OnDestroy,
+ OnInit,
+ } from '@angular/core';
+ import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
+ import { OpModalService } from 'core-app/shared/components/modal/modal.service';
+ import { take } from 'rxjs/operators';
-import { DatePickerModalComponent } from 'core-app/shared/components/datepicker/datepicker.modal';
+ import { TimezoneService } from 'core-app/core/datetime/timezone.service';
+ import { EditFieldComponent } from 'core-app/shared/components/fields/edit/edit-field.component';
++import { SingleDateModalComponent } from 'core-app/shared/components/datepicker/single-date-modal/single-date.modal';
++import { MultiDateModalComponent } from 'core-app/shared/components/datepicker/multi-date-modal/multi-date.modal';
++import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';
+
+ @Directive()
+ export abstract class DatePickerEditFieldComponent extends EditFieldComponent implements OnInit, OnDestroy {
+ @InjectField() readonly timezoneService:TimezoneService;
+
+ @InjectField() opModalService:OpModalService;
+
- protected modal:DatePickerModalComponent;
++ protected modal:SingleDateModalComponent|MultiDateModalComponent;
+
+ ngOnInit():void {
+ super.ngOnInit();
+
+ this.handler
+ .$onUserActivate
+ .pipe(
+ this.untilDestroyed(),
+ )
+ .subscribe(() => {
+ this.showDatePickerModal();
+ });
+ }
+
+ ngOnDestroy():void {
+ super.ngOnDestroy();
+ this.modal?.closeMe();
+ }
+
+ public showDatePickerModal():void {
++ const component = this.change.schema.isMilestone ? SingleDateModalComponent : MultiDateModalComponent;
+ this.modal = this
+ .opModalService
- .show(DatePickerModalComponent, this.injector, { changeset: this.change, fieldName: this.name }, true);
++ .show<SingleDateModalComponent|MultiDateModalComponent>(component, this.injector, { changeset: this.change, fieldName: this.name }, true);
+
+ const { modal } = this;
+
+ setTimeout(() => {
+ const modalElement = jQuery(modal.elementRef.nativeElement).find('.op-datepicker-modal');
+ const field = jQuery(this.elementRef.nativeElement);
+ modal.reposition(modalElement, field);
+ });
+
- modal
++ (modal as OpModalComponent)
+ .closingEvent
+ .pipe(take(1))
+ .subscribe(() => {
+ void this.handler.handleUserSubmit();
+ });
+ }
+ }