From 59bb578b89b232847da724e626b5bafdc5fbe4ad Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sat, 25 Dec 2021 17:13:23 +0100 Subject: [PATCH] web client: allow to move files between folders Fixes #653 --- templates/webclient/files.html | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/templates/webclient/files.html b/templates/webclient/files.html index 67dea949..0781b65c 100644 --- a/templates/webclient/files.html +++ b/templates/webclient/files.html @@ -124,6 +124,13 @@ +
+ + + + Setting a directory other than the current one will move the item there. This directory must exists + +
@@ -736,14 +743,23 @@ var itemType = getTypeFromMeta(selected); var itemName = getNameFromMeta(selected); var targetName = replaceSlash($("#rename_new_name").val()); + var targetDir = $("#rename_new_dir").val(); + if (targetDir != "/") { + targetDir = targetDir.endsWith('/') ? targetDir.slice(0, -1) : targetDir; + } + if (targetDir.trim() == ""){ + targetDir = "{{.CurrentDir}}"; + } else { + targetDir = encodeURIComponent(targetDir); + } var path; if (itemType == "1"){ path = '{{.DirsURL}}'; } else { path = '{{.FilesURL}}'; } - path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+itemName)+'&target={{.CurrentDir}}'+encodeURIComponent("/"+targetName); - $('renameModal').modal('hide'); + path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+itemName)+'&target='+targetDir+encodeURIComponent("/"+targetName); + $('#renameModal').modal('hide'); $.ajax({ url: path, type: 'PATCH', @@ -833,6 +849,7 @@ var selected = table.column(0).checkboxes.selected()[0]; var itemName = getNameFromMeta(selected); $("#rename_old_name").val(itemName); + $("#rename_new_dir").val(decodeURIComponent("{{.CurrentDir}}".replace(/\+/g, '%20'))); $("#rename_new_name").val(""); $('#renameModal').modal('show'); },