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
also send a dialog:close event when the modal is closed unsuccessfully and add a field to the event
Klaus Zandersd30c9eb85850
diff --git a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.tsindex c7fcdb6a7a3..4dc9ffd4794 100644--- a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts+++ b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts@@ -761,8 +761,8 @@ export class TimeEntryCalendarComponent implements AfterViewInit, OnDestroy {}private handleDialogClose(event:CustomEvent):void {- const { detail: { dialog } } = event as { detail:{ dialog:HTMLDialogElement } };- if (dialog.id === 'time-entry-dialog') {+ const { detail: { dialog, submitted } } = event as { detail:{ dialog:HTMLDialogElement, submitted:boolean } };+ if (dialog.id === 'time-entry-dialog' && submitted) {void this.fetchTimeEntries(this.memoizedTimeEntries.start, this.memoizedTimeEntries.end).then(async (collection) => {this.entries.emit(collection);diff --git a/frontend/src/app/shared/components/fields/display/field-types/wp-spent-time-display-field.module.ts b/frontend/src/app/shared/components/fields/display/field-types/wp-spent-time-display-field.module.tsindex ffe593a79f9..19c27e99891 100644--- a/frontend/src/app/shared/components/fields/display/field-types/wp-spent-time-display-field.module.ts+++ b/frontend/src/app/shared/components/fields/display/field-types/wp-spent-time-display-field.module.ts@@ -30,7 +30,6 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.serviceimport { ProjectResource } from 'core-app/features/hal/resources/project-resource';import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';import * as URI from 'urijs';-import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { WorkDisplayField } from 'core-app/shared/components/fields/display/field-types/work-display-field.module';@@ -45,12 +44,12 @@ export class WorkPackageSpentTimeDisplayField extends WorkDisplayField {@InjectField() PathHelper:PathHelperService;- @InjectField(TimeEntryCreateService, null) timeEntryCreateService:TimeEntryCreateService;-@InjectField() apiV3Service:ApiV3Service;@InjectField() TurboRequests:TurboRequestsService;+ private closeDialogHandler:EventListener = this.handleDialogClose.bind(this);+public render(element:HTMLElement, displayText:string):void {if (!this.value) {return;@@ -90,7 +89,7 @@ export class WorkPackageSpentTimeDisplayField extends WorkDisplayField {}private appendTimelogLink(element:HTMLElement) {- if (this.timeEntryCreateService && this.resource.logTime) {+ if (this.resource.logTime) {const timelogElement = document.createElement('a');timelogElement.setAttribute('class', 'icon icon-time');timelogElement.setAttribute('href', '');@@ -103,9 +102,23 @@ export class WorkPackageSpentTimeDisplayField extends WorkDisplayField {}private showTimelogWidget(wp:WorkPackageResource) {+ document.addEventListener('dialog:close', this.closeDialogHandler);+void this.TurboRequests.request(`${this.PathHelper.timeEntryWorkPackageDialog(wp.id as string)}?date=${moment().format('YYYY-MM-DD')}`,{ method: 'GET' },);}++ private handleDialogClose(event:CustomEvent):void {+ document.removeEventListener('dialog:close', this.closeDialogHandler);++ const { detail: { dialog, submitted } } = event as { detail:{ dialog:HTMLDialogElement, submitted:boolean } };+ if (dialog.id === 'time-entry-dialog' && submitted) {+ void this.apiV3Service+ .work_packages+ .id(this.resource.id!)+ .refresh();+ }+ }}diff --git a/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts b/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.tsindex 20ba65bd7fd..1d4bde0ea50 100644--- a/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts+++ b/frontend/src/app/shared/components/time_entries/edit/trigger-actions-entry.component.ts@@ -60,8 +60,8 @@ export class TriggerActionsEntryComponent {editTimeEntry() {void this.loadEntry().subscribe((entry:TimeEntryResource) => {document.addEventListener('dialog:close', (event:CustomEvent) => {- const { detail: { dialog } } = event as { detail:{ dialog:HTMLDialogElement } };- if (dialog.id === 'time-entry-dialog') {+ const { detail: { dialog, submitted } } = event as { detail:{ dialog:HTMLDialogElement, submitted:boolean } };+ if (dialog.id === 'time-entry-dialog' && submitted) {window.location.reload();}});diff --git a/frontend/src/turbo/dialog-stream-action.ts b/frontend/src/turbo/dialog-stream-action.tsindex 08296b6d55b..bd086ae67a3 100644--- a/frontend/src/turbo/dialog-stream-action.ts+++ b/frontend/src/turbo/dialog-stream-action.ts@@ -17,6 +17,10 @@ export function registerDialogStreamAction() {} else {dialog.remove();}++ if (dialog.returnValue !== 'close-event-already-dispatched') {+ document.dispatchEvent(new CustomEvent('dialog:close', { detail: { dialog, submitted: false } }));+ }});// Hack to fix the width calculation of nested elementsdiff --git a/frontend/src/turbo/turbo-event-listeners.ts b/frontend/src/turbo/turbo-event-listeners.tsindex 667cc6f98ab..c1f431872ca 100644--- a/frontend/src/turbo/turbo-event-listeners.ts+++ b/frontend/src/turbo/turbo-event-listeners.ts@@ -16,10 +16,10 @@ export function addTurboEventListeners() {if (dialog) {if (dialog.dataset.keepOpenOnSubmit !== 'true') {- dialog.close();+ dialog.close('close-event-already-dispatched');}- document.dispatchEvent(new CustomEvent('dialog:close', { detail: { dialog } }));+ document.dispatchEvent(new CustomEvent('dialog:close', { detail: { dialog, submitted: true } }));}}});