Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix datatables download feature (2.9) #7147

Merged
merged 1 commit into from
Oct 25, 2022

Conversation

pdelboca
Copy link
Member

Affected Versions

2.9 (already fixed in 2.10 with the new datatablesview design)

When downloading data from the datatablesview plugin the hidden form is never refreshed after downloading. This causes a buggy behavior in which if the user downloads a CSV file, and then tries to download in another format, it will keep downloading CSV files.

image

Proposed fixes

Since datatablesview has a major upgrade in CKAN 2.10, this patch takes the fixed applied in the run_query function and back ports it. It basically removes the input HTML element we are creating to set the format of the download. This causes the form to be reset to the orginal state after downloading.

const run_query = function (params, format) {
const form = $('#filtered-datatables-download')
const p = $('<input name="params" type="hidden"/>')
p.attr('value', JSON.stringify(params))
form.append(p)
const f = $('<input name="format" type="hidden"/>')
f.attr('value', format)
form.append(f)
form.submit()
p.remove()
f.remove()
}

@pdelboca pdelboca marked this pull request as ready for review October 20, 2022 07:46
@amercader amercader self-assigned this Oct 20, 2022
@amercader amercader merged commit 993093c into ckan:dev-v2.9 Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants