Эх сурвалжийг харах

Fixed File operation dialog bug

Toby Chui 3 жил өмнө
parent
commit
2659a4ba2b

+ 19 - 6
web/SystemAO/file_system/file_operation.html

@@ -9,6 +9,9 @@
         <script type="text/javascript" src="../../script/ao_module.js"></script>
         <script type="text/javascript" src="../../script/applocale.js"></script>
         <style>
+            body{
+                overflow: hidden;
+            }
             .banner{
                 background-color:#4287f5;
                 height:50px;
@@ -55,17 +58,17 @@
         <div class="ui modal" id="duplicateAction">
             <div class="content">
                 <div class="description" style="padding: 0px !important;">
-                    <p><i class="big exclamation triangle icon"></i> <span>At least one file has the same filename with another existsing file. <b>Which action should be taken?</b></span></p><br>
+                    <p><i class="big exclamation triangle icon"></i> <span locale="dup/question">File with same name already exists. <b>Which action should be taken?</b></span></p><br>
                 </div>
             </div>
             <div class="actions">
-                <div class="ui labeled button" onclick="continueProcess('overwrite');">
+                <div locale="dup/overwrite" class="ui labeled button" onclick="continueProcess('overwrite');">
                     Overwrite
                 </div>
-                <div class="ui labeled button" onclick="continueProcess('skip');">
+                <div locale="dup/skip" class="ui labeled button" onclick="continueProcess('skip');">
                     Skip
                 </div>
-                <div class="ui labeled button" style="color: #2fb55c;" onclick="continueProcess('keep');">
+                <div locale="dup/renameAndKeep" class="ui labeled button" style="color: #2fb55c;" onclick="continueProcess('keep');">
                     Rename & Keep
                 </div>
               
@@ -153,10 +156,18 @@
                                 data: {dir: operationConfig.dest},
                                 success: function(filelist){
                                     //Check for duplication
+                                    var srcFilenameList = [];
+                                    operationConfig.src.forEach(srcpath => {
+                                        var filename = srcpath.split("/").pop();
+                                        srcFilenameList.push(filename);
+                                    })
                                     var duplicateFound = filelist.some(function(file){
-                                        return operationConfig.src.includes(file);
+                                        return srcFilenameList.includes(file.Filename);
                                     }); 
 
+                                    console.log(filelist);
+                                    console.log(operationConfig.src);
+
                                     if (duplicateFound){
                                         //Duplication found. 
                                         $("#duplicateAction").modal({
@@ -660,7 +671,9 @@
 
                             //If the target or src is desktop, refresh desktop as well
                             if(pathIsOnDesktop(operationConfig.dest) || pathIsOnDesktop(operationConfig.src[0])){
-                                parent.refresh(undefined, true);
+                                if (ao_module_virtualDesktop){
+                                    parent.refresh(undefined, true);
+                                }
                             }
 
                             if (!enterErrorMode){

+ 1 - 1
web/SystemAO/file_system/trashbin.html

@@ -185,7 +185,7 @@
                     ws.onclose = function() { 
                         console.log("TrashBin WebSocket transfer completed");
                         if (previousTrashbinFilelist.length == 0){
-                            $("#trashList").append(`<tr><td colspan="4"><i class="checkmark icon"></i> There are no files or folders in Trashbin.</td></tr>`);
+                            $("#trashList").append(`<tr><td colspan="4"><i class="checkmark icon"></i> ${applocale.getString("list/notrash", "There are no files or folders in Trashbin.")}</td></tr>`);
                         }
                         $("#scanning").hide();
                     };

+ 3 - 1
web/SystemAO/locale/trashbin.json

@@ -16,6 +16,7 @@
                 "list/details":"詳細資料",
                 "list/restore":"恢復檔案",
                 "list/scanning":"正在從所有虛擬磁碟區掃描回收檔案",
+                "list/notrash":"垃圾箱內並沒有任何檔案或資料夾",
                 
 
                 "opr/move":"移動",
@@ -67,6 +68,7 @@
                 "list/details":"詳細資料",
                 "list/restore":"恢復檔案",
                 "list/scanning":"正在從所有虛擬磁碟區掃描回收檔案",
+                "list/notrash":"垃圾箱內並沒有任何檔案或資料夾",
                 
 
                 "opr/move":"移動",
@@ -118,7 +120,7 @@
                 "list/details":"详细资料",
                 "list/restore":"恢复文件",
                 "list/scanning":"正在从所有虚拟磁碟区扫描回收文件",
-                
+                "list/notrash":"垃圾箱内并没有任何文件或资料夹",
 
                 "opr/move":"移动",
                 "opr/file":"文件",

+ 72 - 23
web/desktop.system

@@ -40,6 +40,7 @@
             -moz-transition: opacity 2s ease-in-out;
             -o-transition: opacity 2s ease-in-out;
             transition: opacity 2s ease-in-out;
+
         }
         
         .background-wrapper {
@@ -4474,7 +4475,7 @@
 
                 
                
-            }else if (keycode == "112"){
+            }else if (keycode == "112" ){
                 //Enter key
                 if (!renameMode){
                     //Open selected object by emulating double click
@@ -4488,6 +4489,76 @@
                     exitRenameMode();
                 }
             
+            }else if (keycode == "67" && ctrlHold){
+                //Ctrl + C, copy
+                var clipboard = [];
+                $(".launchIconWrapper.selected").each(function(){
+                    var object = $(this).parent();
+                    var fd = JSON.parse(decodeURIComponent($(object).attr("filedata")));
+                    clipboard.push(fd.Filepath);
+                });
+
+                localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
+                localStorage.setItem("ao/file_system/cutmode","false");
+             }else if (keycode == "88" && ctrlHold){
+                //Ctrl + X, cut
+                var clipboard = [];
+                $(".launchIconWrapper.selected").each(function(){
+                    var object = $(this).parent();
+                    var fd = JSON.parse(decodeURIComponent($(object).attr("filedata")));
+                    clipboard.push(fd.Filepath);
+                });
+
+                localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
+                localStorage.setItem("ao/file_system/cutmode","true");
+            }else if (keycode == "86" && ctrlHold){
+                //Ctrl + V, Paste
+
+                //Check if there are files in clipboard
+                var crossFrameClipboard = localStorage.getItem("ao/file_system/clipboard");
+                var useCutMode = localStorage.getItem("ao/file_system/cutmode");
+                var fileList = [];
+                if (crossFrameClipboard !== "" && crossFrameClipboard !== undefined && crossFrameClipboard !== null){
+                    fileList = JSON.parse(crossFrameClipboard);
+                }
+                if (useCutMode !== "" && useCutMode !== undefined && useCutMode !== null){
+                    thisOprCutMode = (useCutMode == "true");
+                }
+
+                var mode = "copy";
+                var title = "Copying "
+                if (thisOprCutMode){
+                    mode = "move";
+                    title = "Moving "
+                }
+
+                if (fileList.length > 0){
+                    //There are something to move. Start the file operation dialog
+                    var oprConfig = {
+                        opr: mode,
+                        src: fileList,
+                        dest: "user:/Desktop/",
+                        overwriteMode: "ask"
+                    }
+                    var configHash = encodeURIComponent(JSON.stringify(oprConfig));
+
+                    //Genreate window title
+                    var title = title + fileList.length;
+                    if (fileList.length > 1){
+                        title += " files";
+                    }else{
+                        title += " file";
+                    }
+
+                    newFloatWindow({
+                        url: "SystemAO/file_system/file_operation.html#" + configHash,
+                        width: 400,
+                        height: 220,
+                        appicon: "SystemAO/file_system/img/selector.png",
+                        title: title
+                    });
+                }
+
             }else{
                 //console.log(event.which);
             }
@@ -5222,11 +5293,6 @@
             </div>`);
         }
 
-        function downloadURL() {
-            alert("WIP");
-            hideAllContextMenus();
-        }
-
         function background(target, evt) {
             $("#subcontextmenu").html('<div class="item"><i class="loading spinning icon"></i> Loading</div>');
             $.get("system/desktop/theme", function(data) {
@@ -5309,23 +5375,6 @@
                 });
             });
 
-            /*
-            //Open new folder creation window
-            var existsingFileList = [];
-            for (var i =0; i < desktopFileList.length; i++){
-                existsingFileList.push({
-                    filename: desktopFileList[i],
-                    filepath: "user:/Desktop/" + desktopFileList[i]
-                });
-            }
-            newFloatWindow({
-                url: "SystemAO/file_system/newFolder.html#" + encodeURIComponent(JSON.stringify(existsingFileList)),
-                appicon: "SystemAO/file_system/img/new folder.png",
-                width:560,
-                height:340,
-                title: "New Folder"
-            });
-            */
             hideAllContextMenus();
         }