web client: allow to move files between folders

Fixes #653
This commit is contained in:
Nicola Murino 2021-12-25 17:13:23 +01:00
parent 7d8823307f
commit 59bb578b89
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -124,6 +124,13 @@
<label for="rename_old_name" class="col-form-label">Old name</label> <label for="rename_old_name" class="col-form-label">Old name</label>
<input type="text" class="form-control" id="rename_old_name" readonly> <input type="text" class="form-control" id="rename_old_name" readonly>
</div> </div>
<div class="form-group">
<label for="rename_new_dir" class="col-form-label">New base dir</label>
<input type="text" class="form-control" id="rename_new_dir" required aria-describedby="renameNewDirHelpBlock">
<small id="renameNewDirHelpBlock" class="form-text text-muted">
Setting a directory other than the current one will move the item there. This directory must exists
</small>
</div>
<div class="form-group"> <div class="form-group">
<label for="rename_new_name" class="col-form-label">New name</label> <label for="rename_new_name" class="col-form-label">New name</label>
<input type="text" class="form-control" id="rename_new_name" required> <input type="text" class="form-control" id="rename_new_name" required>
@ -736,14 +743,23 @@
var itemType = getTypeFromMeta(selected); var itemType = getTypeFromMeta(selected);
var itemName = getNameFromMeta(selected); var itemName = getNameFromMeta(selected);
var targetName = replaceSlash($("#rename_new_name").val()); 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; var path;
if (itemType == "1"){ if (itemType == "1"){
path = '{{.DirsURL}}'; path = '{{.DirsURL}}';
} else { } else {
path = '{{.FilesURL}}'; path = '{{.FilesURL}}';
} }
path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+itemName)+'&target={{.CurrentDir}}'+encodeURIComponent("/"+targetName); path+='?path={{.CurrentDir}}'+encodeURIComponent("/"+itemName)+'&target='+targetDir+encodeURIComponent("/"+targetName);
$('renameModal').modal('hide'); $('#renameModal').modal('hide');
$.ajax({ $.ajax({
url: path, url: path,
type: 'PATCH', type: 'PATCH',
@ -833,6 +849,7 @@
var selected = table.column(0).checkboxes.selected()[0]; var selected = table.column(0).checkboxes.selected()[0];
var itemName = getNameFromMeta(selected); var itemName = getNameFromMeta(selected);
$("#rename_old_name").val(itemName); $("#rename_old_name").val(itemName);
$("#rename_new_dir").val(decodeURIComponent("{{.CurrentDir}}".replace(/\+/g, '%20')));
$("#rename_new_name").val(""); $("#rename_new_name").val("");
$('#renameModal').modal('show'); $('#renameModal').modal('show');
}, },