ソースを参照

Add restore functionality for multiple selection

- Add restore mail function oin Trash folder for multiple selection
  and list items
Alexey Edelev 4 年 前
コミット
6bcbb6912c
3 ファイル変更20 行追加1 行削除
  1. 18 0
      web/js/index.js
  2. 1 1
      web/templates/index.html
  3. 1 0
      web/templates/maillist.html

+ 18 - 0
web/js/index.js

@@ -367,6 +367,7 @@ function restoreMail(mailId, callback) {
         success: function() {
             if (currentFolder == 'Trash') {
                 $('#mail'+mailId).remove();
+                removeFromSelectionList(mailId);
             }
             if (callback) {
                 callback();
@@ -457,6 +458,7 @@ function updateMailList(folder, page) {
                 $('#mailList').html(data.html);
             }
             currentFolder = folder;
+            enableRestoreFunctionality();
             currentPage = page;
 
             if ($('#currentPageIndex')) {
@@ -581,6 +583,12 @@ function removeSelection() {
     }
 }
 
+function restoreSelection() {
+    for (var i = 0; i < selectionList.length; ++i) {
+        restoreMail(selectionList[i], function(){});
+    }
+}
+
 function toggleSelectionRead() {
     var read = checkMailUnread();
     for (var i = 0; i < selectionList.length; ++i) {
@@ -637,4 +645,14 @@ function resetSelectionList() {
     selectionList = new Array();
     $('#selectAllCheckbox').prop('checked', false);
     $('#multiActionsControls').css('display', 'none');
+}
+
+function enableRestoreFunctionality() {
+    if (currentFolder == 'Trash') {
+        $('#multiActionsRestore').css('display', 'block');
+        $('[id^="restoreListIcon"]').css('display', 'block');
+    } else {
+        $('#multiActionsRestore').css('display', 'none');
+        $('[id^="restoreListIcon"]').css('display', 'none');
+    }
 }

+ 1 - 1
web/templates/index.html

@@ -28,7 +28,7 @@
                     </div>
                     <div id="multiActionsControls">
                         <img id="multiActionsRead" class="iconBtn" style="width: 24px; height: 24px; margin: auto 10px auto 0; flex: 0 1 auto;" onclick="toggleSelectionRead(); event.stopPropagation(); return false;" src="/assets/unread.svg"/>
-                        <img id="multiActionsRestore" class="iconBtn" style="display: none; width: 24px; margin: auto 10px auto 0; height: 24px; flex: 0 1 auto;" onclick="event.stopPropagation(); return false;" src="/assets/restore.svg"/>
+                        <img id="multiActionsRestore" class="iconBtn" style="display: none; width: 24px; margin: auto 10px auto 0; height: 24px; flex: 0 1 auto;" onclick="restoreSelection(); event.stopPropagation(); return false;" src="/assets/restore.svg"/>
                         <img id="multiActionsRemove" class="iconBtn" style="width: 24px; height: 24px; margin: auto 10px auto 0; flex: 0 1 auto;" onclick="removeSelection(); event.stopPropagation(); return false;" src="/assets/remove.svg"/>
                     </div>
                     <div class="spacer"></div>

+ 1 - 0
web/templates/maillist.html

@@ -23,6 +23,7 @@
     <div id="mailControlPanel{{.Id}}" class="mailControlPanel">
         <div style="width: 100%; height: 100%; display: flex; flex-direction: row;">
             <img id="readListIcon{{.Id}}" class="iconBtn" style="width: 20px; margin-left: 40px; margin-right: 10px;" onclick="toggleRead('{{.Id}}'); event.stopPropagation(); return false;" src="/assets/{{if .Read}}read{{else}}unread{{end}}.svg"/>
+            <img id="restoreListIcon{{.Id}}" class="iconBtn" style="display: none; width: 24px; margin: auto 10px auto 0; height: 24px; flex: 0 1 auto;" onclick="restoreMail({{.Id}}, closeDetails); event.stopPropagation(); return false;" src="/assets/restore.svg"/>
             <img id="deleteListIcon" class="iconBtn" style="width: 20px; margin-right: 10px;" onclick="removeMail({{.Id}}, function(){}); event.stopPropagation(); return false;" src="/assets/remove.svg"/>
         </div>
     </div>