fix moving nodes via context menu
authorCornelius Weiß <c.weiss@metaways.de>
Wed, 26 Jul 2017 10:28:14 +0000 (12:28 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Wed, 26 Jul 2017 10:24:44 +0000 (12:24 +0200)
Change-Id: Icd66a401806dd1eebe4cef4645fea5da5abda0a4
Reviewed-on: http://gerrit.tine20.com/customers/5317
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Filemanager/js/Model.js
tine20/Filemanager/js/NodeTreePanel.js
tine20/Filemanager/js/nodeActions.js
tine20/Tinebase/js/extFixes.js

index 2eadc04..368e0d3 100644 (file)
@@ -223,6 +223,9 @@ Tine.Filemanager.FileRecordBackend = Ext.extend(Tine.Tinebase.data.RecordProxy,
                 targetPath = target.attributes.path + '/';
                 treeIsTarget = true;
             }
+            else if (target.path) {
+                targetPath = target.path + (target.type == 'folder' ? '/' : '');
+            }
 
             for(var i=0; i<items.length; i++) {
                 var item = items[i];
index 79a0650..4724e73 100644 (file)
@@ -106,18 +106,21 @@ Tine.Filemanager.NodeTreePanel = Ext.extend(Tine.widgets.container.TreePanel, {
             }
 
             // add / remount node
-            me.expandPath(parentPath, '', function(sucess, parentNode) {
-                var childNode = parentNode.findChild('name', data.name);
-                if (! childNode) {
-                    parentNode.appendChild(node || me.loader.createNode(data));
-                } else if (childNode != node) {
-                    // node got duplicated by expand load
-                    try {
-                        node.cancelExpand();
-                        node.remove(true);
-                    } catch (e) {}
-                }
-            });
+            try {
+                me.expandPath(parentPath, '', function (sucess, parentNode) {
+                    var childNode = parentNode.findChild('name', data.name);
+                    if (!childNode) {
+                        parentNode.appendChild(node || me.loader.createNode(data));
+                    } else if (childNode != node) {
+                        // node got duplicated by expand load
+                        try {
+                            node.cancelExpand();
+                            node.remove(true);
+                        } catch (e) {
+                        }
+                    }
+                });
+            } catch (e) {}
         }
     },
 
index 76cbb19..5be9050 100644 (file)
@@ -270,11 +270,11 @@ Tine.Filemanager.nodeActions.Move = {
 
         filePickerDialog.on('selected', function(nodes) {
             var node = nodes[0];
-            Tine.Filemanager.fileRecordBackend.copyNodes(records, node.path, true);
+            Tine.Filemanager.fileRecordBackend.copyNodes(records, node, true);
         });
 
         filePickerDialog.openWindow();
-    },
+    }
 };
 
 /**
index 2540d18..34dfeb8 100644 (file)
@@ -846,3 +846,18 @@ Ext.override(Ext.menu.DateMenu, {
         }
     }
 });
+
+Ext.override(Ext.tree.TreePanel, {
+    /**
+     * Gets a node in this tree by its id
+     * @param {String} id
+     * @return {Node}
+     */
+    getNodeById : function(id){
+        try {
+            return this.nodeHash[id];
+        } catch(e) {
+            return null;
+        }
+    }
+});