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

[#59781] Export of an unsaved query not working properly

as-op06f64b689940
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/export/form.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/export/form.controller.ts
index 149bd00801b..70832ed8b33 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/export/form.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/export/form.controller.ts
@@ -41,12 +41,16 @@ export default class FormController extends Controller<HTMLFormElement> {
return result.job_id;
}
+ generateExportURL():string {
+ const formatURL = this.element.getAttribute('action') as string;
+ const searchParams = this.getExportParams();
+ const append = formatURL.includes('?') ? '&' : '?';
+ return `${formatURL}${append}${searchParams.toString()}`
+ }
+
submitForm(evt:CustomEvent) {
evt.preventDefault(); // Don't submit
- const formatURL = this.element.getAttribute('action');
- const searchParams = this.getExportParams();
- const exportURL = `${formatURL}?${searchParams.toString()}`;
- this.requestExport(exportURL)
+ this.requestExport(this.generateExportURL())
.then((job_id) => this.showJobModal(job_id))
.catch((error:HttpErrorResponse) => this.handleError(error));
}
diff --git a/spec/features/work_packages/export_spec.rb b/spec/features/work_packages/export_spec.rb
index 8c16a1bd3b4..e4d14d052b1 100644
--- a/spec/features/work_packages/export_spec.rb
+++ b/spec/features/work_packages/export_spec.rb
@@ -126,7 +126,7 @@ RSpec.describe "work package export" do
context "with activated options" do
let(:query) do
create(
- :query, user: current_user, project:,
+ :query, id: 1234, user: current_user, project:,
display_sums: true,
include_subprojects: true,
show_hierarchies: true,
@@ -135,6 +135,7 @@ RSpec.describe "work package export" do
end
let(:expected_params) do
default_expected_params.merge({
+ query_id: "1234",
showSums: "true",
includeSubprojects: "true",
showHierarchies: "true"