Attachments: implement browsing & deleting using fineuploader
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 25 Jan 2014 20:00:07 +0000 (21:00 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 25 Jan 2014 20:00:07 +0000 (21:00 +0100)
webcit/static/t/edit/message.html
webcit/static/t/edit/message/attachments_pane.html
webcit/static/t/edit/message/json_attlist.js [new file with mode: 0644]
webcit/static/t/edit/message/section_attach_list.js [new file with mode: 0644]
webcit/static/t/edit/message/section_attach_select.html [deleted file]

index 23b96434085bb4ae4ad09dfccf73a1deb4fa9627..f803f3762ac35b4846c6ab5d8f2e95eccf8fcf00 100644 (file)
                );
        }
 
-       function remove_attachment(which_one) {
-               p = 'which_attachment=' + which_one + '&r=' + CtdlRandomString();
-               new Ajax.Updater(
-                       'gonna_upload_this',
-                       'remove_attachment',
-                       {
-                               method: 'get',
-                               parameters: p,
-                               onComplete: function(){
-                                       show_attachments_form();
-                                       update_attachment_count();
-                               }
-                       }
-               );
-       }
-
 </script>
 </div>
 </div>
index b74ce35093087f01387b306694bab46f50827396..c2dc3a0f358f92446a4ef712426a23157dccc8fa 100644 (file)
@@ -5,7 +5,6 @@
     <?_("Close window")>&nbsp;<img src="static/webcit_icons/closewindow.gif" border="0"></div>
 </a>
 <h2><img src="static/webcit_icons/essen/16x16/attachement.png">&nbsp;<?_("Attachments:")></h2>
-<ul><?ITERATE("MSG:ATTACHNAMES", ="edit_message_section_attach_select")></ul>
 
 <!-- Fine Uploader JS
 ====================================================================== -->
@@ -15,9 +14,13 @@ function createUploader()
 {
     var uploader = new qq.FineUploader(
        {
+           session: {
+               endpoint: "do_template?template=edit_message_json_attlist"
+           },
            callbacks: {
-               "onComplete": update_attachment_count,
-               "delete": update_attachment_count
+               onComplete: update_attachment_count,
+               delete: update_attachment_count,
+               deleteComplete: update_attachment_count
            },
            element: document.getElementById('fine-uploader'),
            request: {
@@ -26,7 +29,7 @@ function createUploader()
            deleteFile: {
                enabled: true,
                forceConfirm: true,
-               endpoint: 'remove_attachment?nonce=<?NONCE>&template=edit_message_upl_att'
+               endpoint: 'remove_attachment?nonce=<?NONCE>&template=edit_message_upl_att&which_attachment='
            }
        });
 }
diff --git a/webcit/static/t/edit/message/json_attlist.js b/webcit/static/t/edit/message/json_attlist.js
new file mode 100644 (file)
index 0000000..2260ab3
--- /dev/null
@@ -0,0 +1,3 @@
+[
+<?ITERATE("MSG:ATTACHNAMES", ="edit_message_section_attach_list")>
+]
\ No newline at end of file
diff --git a/webcit/static/t/edit/message/section_attach_list.js b/webcit/static/t/edit/message/section_attach_list.js
new file mode 100644 (file)
index 0000000..4ea3b6e
--- /dev/null
@@ -0,0 +1,5 @@
+{
+    "name":"<?MAIL:MIME:FILENAME("J")>",
+    "uuid":"<?MAIL:MIME:PARTNUM("J")>",
+    "size": <?MAIL:MIME:LENGTH>
+}<?%("COND:ITERATE:LASTN", 1, 0, 0, "", ",")>
diff --git a/webcit/static/t/edit/message/section_attach_select.html b/webcit/static/t/edit/message/section_attach_select.html
deleted file mode 100644 (file)
index aa29038..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<li>
-       <?MAIL:MIME:FILENAME("X")> (<?MAIL:MIME:CONTENTTYPE>, <?MAIL:MIME:LENGTH> bytes)
-       &nbsp;
-       <a href="javascript:remove_attachment('<?MAIL:MIME:FILENAME("J")>');"><?_("Remove")></a>
-</li>