From fa6933824ed4acf1de09f0e6252a1a25d229c36b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 7 Jul 2023 10:28:44 -0900 Subject: [PATCH] webcit-ng: drag-and-drop mail to other folders is complete. The fact that this could be completed without writing any new C code is a good indicator that the DAV foundation is in good shape. --- webcit-ng/static/js/mail_folder_list.js | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/webcit-ng/static/js/mail_folder_list.js b/webcit-ng/static/js/mail_folder_list.js index 6647c03b2..d88c5f09c 100644 --- a/webcit-ng/static/js/mail_folder_list.js +++ b/webcit-ng/static/js/mail_folder_list.js @@ -93,6 +93,28 @@ function mail_folder_drop(event, destination_room) { // mail_folder_drop() calls this function for each message being moved -function mail_move(msgdiv, destination_room) { - console.log("mail_move() " + msgdiv + " to " + destination_room); +mail_move = async(msgdivid, destination_room) => { + let msgdiv = document.getElementById(msgdivid); + let m = parseInt(msgdivid.substring(12)); // derive msgnum from row id + let source = "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + m; + let destination = "/ctdl/r/" + escapeHTMLURI(destination_room); + + let response = await fetch( + source, { + method: "MOVE", + headers: { + "Destination" : destination + } + } + ); + + // If the server accepted the MOVE operation, delete the row from our screen. + if (response.ok) { + var table = document.getElementById("ctdl-onscreen-mailbox"); + for (var i = 0, row; row = table.rows[i]; i++) { + if (row.id == msgdivid) { + table.deleteRow(i); + } + } + } } -- 2.39.2