webcit-ng: drag-and-drop mail to other folders is complete.
authorArt Cancro <ajc@citadel.org>
Fri, 7 Jul 2023 19:28:44 +0000 (10:28 -0900)
committerArt Cancro <ajc@citadel.org>
Fri, 7 Jul 2023 19:28:44 +0000 (10:28 -0900)
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

index 6647c03b263c77b274e99fa131ea8cf9740ce6cf..d88c5f09c72549eb65f8477115092d089927b152 100644 (file)
@@ -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);
+                       }
+               }
+       }
 }