]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1693 from ArthurHoaro/fix/bulk-add-delete
authorArthurHoaro <arthur@hoa.ro>
Tue, 19 Jan 2021 13:31:15 +0000 (14:31 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Jan 2021 13:31:15 +0000 (14:31 +0100)
Fix: bulk add - delete existing link

1  2 
assets/common/js/shaare-batch.js

index 9753137ddf51a9558c26f95ecd4d576bebe647c2,2b438045c5f401ce8a21305278fcd57e8e083b86..4a1fdb2ed928ac59962c7bded70554ab3631bf4f
@@@ -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 {