Skip to content

Commit

Permalink
Re-arranged order of action on submit form success to refresh only wh…
Browse files Browse the repository at this point in the history
…en necessary (not when a file was downloaded)
  • Loading branch information
gbastien committed May 21, 2021
1 parent 2f22f4a commit eeb906b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/imio/helpers/browser/static/helpers.js
Expand Up @@ -189,23 +189,25 @@ function submitFormHelper(form, onsuccess=submitFormHelperOnsuccessDefault, oner
}

function submitFormHelperOnsuccessDefault(data, textStatus, request) {
cancel_button = $('input#form-buttons-cancel');
// download file if 'content-disposition' header found
if (request.getResponseHeader('content-disposition')) {
contentType = request.getResponseHeader('content-type');
var blob = new Blob([data], {type: contentType});
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}
// close the overlay
cancel_button = $('input#form-buttons-cancel');
if (cancel_button) {
cancel_button.click();
}
// reload faceted
if (has_faceted()) {
Faceted.URLHandler.hash_changed();
} else {
// window.location.reload(); will keep old values of selected checkboxes
window.location.href = window.location.href;
// close the overlay
if (cancel_button) {
cancel_button.click();
}
// reload faceted
if (has_faceted()) {
Faceted.URLHandler.hash_changed();
} else {
// window.location.reload(); will keep old values of selected checkboxes
window.location.href = window.location.href;
}
}
}

0 comments on commit eeb906b

Please sign in to comment.