From e63621af30f59da3b51dc7fad6580c64ccaf8d08 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 9 Nov 2023 13:44:52 -1000 Subject: [PATCH] upload.js: moved the delete-an-attachment skeleton code to its own function --- webcit-ng/static/js/upload.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/webcit-ng/static/js/upload.js b/webcit-ng/static/js/upload.js index 2d0751baf..ac72bbee8 100644 --- a/webcit-ng/static/js/upload.js +++ b/webcit-ng/static/js/upload.js @@ -74,6 +74,19 @@ function handle_upload_files(files) { } +// Delete an uploaded item from the list +delete_upload = async(ref) => { + + response = await fetch( + "/ctdl/p/" + ref, { method: "DELETE" } + ); + + if (response.ok) { // If the server accepted the delete, remove it from the screen + // FIXME do the delete + } +} + + function upload_file(file) { var url = '/ctdl/p/'; var xhr = new XMLHttpRequest(); @@ -94,7 +107,7 @@ function upload_file(file) { j_response.forEach((item) => { let new_upl = document.createElement("li"); // item["ref"] is what we need - new_upl.innerHTML = `` + new_upl.innerHTML = `` + ` ` + item["uploadfilename"] + " (" + item["contenttype"] + ", " + item["contentlength"] + " " + _("bytes") + ")"; document.getElementById("ctdl-upload_list").appendChild(new_upl); -- 2.30.2