Skip to content

Commit

Permalink
Merge pull request #17371 from opf/bug/59781-export-of-an-unsaved-que…
Browse files Browse the repository at this point in the history
…ry-not-working-properly

[#59781] Export of an unsaved query not working properly
  • Loading branch information
as-op authored Dec 5, 2024
2 parents 5556368 + c30eab1 commit 6a4cd4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ export default class FormController extends Controller<HTMLFormElement> {
return result.job_id;
}

generateExportURL():string {
const actionURL = this.element.getAttribute('action') as string;
const searchParams = this.getExportParams();
const append = actionURL.includes('?') ? '&' : '?';
return `${actionURL}${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));
}
Expand Down
3 changes: 2 additions & 1 deletion spec/features/work_packages/export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def export!
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,
Expand All @@ -135,6 +135,7 @@ def export!
end
let(:expected_params) do
default_expected_params.merge({
query_id: "1234",
showSums: "true",
includeSubprojects: "true",
showHierarchies: "true"
Expand Down

0 comments on commit 6a4cd4b

Please sign in to comment.