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

Listen to close events to change the edit field back to display mode

Henriette Dargeb673232dbe8f
diff --git a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
index a735b390523..153ab359fa7 100644
--- a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
@@ -403,6 +403,7 @@ import {
import {
WorkPackageSplitViewEntryComponent,
} from 'core-app/features/work-packages/routing/wp-split-view/wp-split-view-entry.component';
+import { OpWpDatePickerModalComponent } from 'core-app/shared/components/datepicker/wp-date-picker-modal/wp-date-picker.modal';
@NgModule({
imports: [
@@ -637,6 +638,8 @@ import {
OpBaselineComponent,
OpBaselineLoadingComponent,
OpBaselineLegendsComponent,
+
+ OpWpDatePickerModalComponent,
],
exports: [
WorkPackagesTableComponent,
@@ -668,6 +671,7 @@ import {
WorkPackageSingleViewComponent,
WorkPackageSplitViewComponent,
BackButtonComponent,
+ OpWpDatePickerModalComponent,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.module.ts b/frontend/src/app/shared/components/datepicker/datepicker.module.ts
index e29dd925553..103d6ffe5b5 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.module.ts
+++ b/frontend/src/app/shared/components/datepicker/datepicker.module.ts
@@ -14,7 +14,6 @@ import { OpenprojectModalModule } from '../modal/modal.module';
import { OpDatePickerSheetComponent } from 'core-app/shared/components/datepicker/sheet/date-picker-sheet.component';
import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';
import { OpWpDatePickerInstanceComponent } from 'core-app/shared/components/datepicker/wp-date-picker-modal/wp-date-picker-instance.component';
-import { OpWpDatePickerModalComponent } from 'core-app/shared/components/datepicker/wp-date-picker-modal/wp-date-picker.modal';
@NgModule({
imports: [
@@ -36,7 +35,6 @@ import { OpWpDatePickerModalComponent } from 'core-app/shared/components/datepic
OpModalSingleDatePickerComponent,
OpDatePickerSheetComponent,
OpWpDatePickerInstanceComponent,
- OpWpDatePickerModalComponent,
],
exports: [
@@ -44,7 +42,6 @@ import { OpWpDatePickerModalComponent } from 'core-app/shared/components/datepic
OpBasicDatePickerModule,
OpDatePickerSheetComponent,
OpWpDatePickerInstanceComponent,
- OpWpDatePickerModalComponent,
],
})
export class OpDatePickerModule { }
diff --git 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
index 4e9bef518d8..7fcc019de50 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
@@ -84,15 +84,6 @@ export abstract class DatePickerEditFieldComponent extends EditFieldComponent im
super.ngOnInit();
this.turboFrameSrc = `${this.pathHelper.workPackageDatepickerDialogContentPath(this.change.id)}?field=${this.name}`;
- this.handler
- .$onUserActivate
- .pipe(
- this.untilDestroyed(),
- )
- .subscribe(() => {
- this.showDatePickerModal();
- });
-
document.addEventListener('date-picker-modal:create', this.createHandler);
document.addEventListener('date-picker-modal:update', this.updateHandler);
document.addEventListener('date-picker-modal:cancel', this.cancelHandler);
@@ -107,12 +98,23 @@ export abstract class DatePickerEditFieldComponent extends EditFieldComponent im
}
public showDatePickerModal():void {
- this.opModalService.show(
- OpWpDatePickerModalComponent,
- this.injector,
- { resource: this.resource, name: this.name },
- );
- this.opened = true;
+ this.opModalService
+ .show(
+ OpWpDatePickerModalComponent,
+ this.injector,
+ { resource: this.resource, name: this.name, change: this.change },
+ )
+ .subscribe((modal) => {
+ modal
+ .closingEvent
+ .subscribe(() => {
+ if (this.opened) {
+ this.onModalClosed();
+ }
+ });
+
+ this.opened = true;
+ });
}
public handleSuccessfulCreate(event:CustomEvent):void {
diff --git a/spec/features/work_packages/table/milestones_spec.rb b/spec/features/work_packages/table/milestones_spec.rb
index 2b74d9a7c9b..9f193914fa1 100644
--- a/spec/features/work_packages/table/milestones_spec.rb
+++ b/spec/features/work_packages/table/milestones_spec.rb
@@ -38,8 +38,11 @@ RSpec.describe "Inline editing milestones", :js do
start_date.activate!
start_date.expect_active!
- # Open second date, closes first
- scroll_to_and_click(due_date.display_element)
+ # Open second date, close first
+ start_date.cancel_by_escape
+ start_date.expect_inactive!
+
+ due_date.activate!
due_date.expect_active!
# Close with escape