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

Ensure modals can be previewed in the context of create forms

Aaron Contreras4a953fe872d5
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts
index 3b25384af89..4df05b9f691 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/progress/preview-progress.controller.ts
@@ -83,11 +83,25 @@ export default class PreviewProgressController extends Controller {
['field', field.name ?? 'estimatedTime'],
];
- const editUrl = `${form.action}/edit?${new URLSearchParams(wpParams).toString()}`;
+ const wpPath = this.ensureValidPathname(form.action);
+
+ const editUrl = `${wpPath}/edit?${new URLSearchParams(wpParams).toString()}`;
const turboFrame = this.formTarget.closest('turbo-frame') as HTMLFrameElement;
if (turboFrame) {
turboFrame.src = editUrl;
}
}
+
+ // Ensures that on create forms, there is an "id" for the un-persisted
+ // work package when sending requests to the edit action for previews.
+ private ensureValidPathname(formAction:string):string {
+ const wpPath = new URL(formAction);
+
+ if (wpPath.pathname === '/work_packages/progress') {
+ wpPath.pathname = '/work_packages/new/progress';
+ }
+
+ return wpPath.toString();
+ }
}