upload.js: when removing an attachment, delete the div
[citadel.git] / webcit-ng / static / js / upload.js
index 5541213724bc4044b88cd177202a4c6e652eb21b..5ae027c8f6f506fef9903e75fb5377676fc96483 100644 (file)
@@ -82,7 +82,9 @@ delete_upload = async(ref) => {
        );
 
        if (response.ok) {                              // If the server accepted the delete, remove it from the screen
-               // FIXME do the delete
+               console.log("server deleted " + ref);
+               var el = document.getElementById(ref);
+               el.parentNode.removeChild(el);
        }
 }
 
@@ -106,7 +108,7 @@ function upload_file(file) {
                        // Add these uploads to the displayed list
                        j_response.forEach((item) => {
                                let new_upl = document.createElement("li");
-                               // item["ref"] is what we need
+                               new_upl.setAttribute("id", item["ref"]);        // set the element id to the upload reference
                                new_upl.innerHTML = `<i class="fa-solid fa-circle-xmark" style="color:red" onClick="delete_upload('` + item["ref"] + `')"></i>`
                                + `&nbsp;`
                                + item["uploadfilename"] + " (" + item["contenttype"] + ", " + item["contentlength"] + " " + _("bytes") + ")";