From: ArthurHoaro Date: Tue, 26 Jan 2021 15:25:09 +0000 (+0100) Subject: Merge pull request #1694 from ArthurHoaro/fix/bulk-add-redirect-token X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=83b4eb17958c0c03bea637db7e394f6d622aeb00;hp=-c;p=github%2Fshaarli%2FShaarli.git Merge pull request #1694 from ArthurHoaro/fix/bulk-add-redirect-token Fix: bulk add redirection with ending slash --- 83b4eb17958c0c03bea637db7e394f6d622aeb00 diff --combined assets/common/js/shaare-batch.js index 4a1fdb2e,3324193f..6fc16faf --- a/assets/common/js/shaare-batch.js +++ b/assets/common/js/shaare-batch.js @@@ -4,11 -4,7 +4,11 @@@ const sendBookmarkForm = (basePath, for const formData = new FormData(); [...inputs].forEach((input) => { - formData.append(input.getAttribute('name'), input.value); + if (input.getAttribute('type') === 'checkbox') { + formData.append(input.getAttribute('name'), input.checked); + } else { + formData.append(input.getAttribute('name'), input.value); + } }); return new Promise((resolve, reject) => { @@@ -30,9 -26,9 +30,9 @@@ const sendBookmarkDelete = (buttonElement, formElement) => ( new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); - xhr.open('GET', buttonElement.href); + xhr.open('GET', `${buttonElement.href}&source=batch`); xhr.onload = () => { - if (xhr.status !== 200) { + if (xhr.status !== 204) { alert(`An error occurred. Return code: ${xhr.status}`); reject(); } else { @@@ -104,7 -100,7 +104,7 @@@ const redirectIfEmptyBatch = (basePath }); Promise.all(promises).then(() => { - window.location.href = basePath || '/'; + window.location.href = `${basePath}/`; }); }); });