Browse Source

Ressources: allow drag & drop ressources

lviguier 1 year ago
parent
commit
c7433832de
2 changed files with 12 additions and 1 deletions
  1. 0 1
      hide/Ide.hx
  2. 12 0
      hide/view/FileTree.hx

+ 0 - 1
hide/Ide.hx

@@ -235,7 +235,6 @@ class Ide extends hide.tools.IdeData {
 		new Element(window.window.document).on("dnd_move.vakata.jstree", function(e, data:Dynamic) {
 		new Element(window.window.document).on("dnd_move.vakata.jstree", function(e, data:Dynamic) {
 			var el = (data.helper:hide.Element);
 			var el = (data.helper:hide.Element);
 			var drag = treeDragFun(data,false);
 			var drag = treeDragFun(data,false);
-			trace(drag);
 			var icon = el.find(new Element(".jstree-icon"));
 			var icon = el.find(new Element(".jstree-icon"));
 			el.css(drag ? { filter : "brightness(120%)", opacity : 1 } : { filter : "", opacity : 0.5 });
 			el.css(drag ? { filter : "brightness(120%)", opacity : 1 } : { filter : "", opacity : 0.5 });
 			icon.toggleClass("jstree-er", !drag);
 			icon.toggleClass("jstree-er", !drag);

+ 12 - 0
hide/view/FileTree.hx

@@ -159,6 +159,8 @@ class FileTree extends FileView {
 			]);
 			]);
 		});
 		});
 		tree.onDblClick = onOpenFile;
 		tree.onDblClick = onOpenFile;
+		tree.onAllowMove = onAllowMove;
+		tree.onMove = doMove;
 		tree.init();
 		tree.init();
 	}
 	}
 
 
@@ -366,6 +368,16 @@ class FileTree extends FileView {
 		return true;
 		return true;
 	}
 	}
 
 
+	function onAllowMove(e: String, to : String) {
+		var destAbsPath = Ide.inst.getPath(to);
+		return sys.FileSystem.isDirectory(destAbsPath);
+	}
+
+	function doMove(e : String, to : String, index : Int) {
+		var dest = "/" + to + "/" + e.split("/").pop();
+		doRename(e, dest);
+	}
+
 	function onExploreFile( path : String ) {
 	function onExploreFile( path : String ) {
 		Ide.showFileInExplorer(path);
 		Ide.showFileInExplorer(path);
 	}
 	}