Support internal dragndrop of multiple selected entries

This commit is contained in:
Johannes Zellner
2022-09-13 11:11:04 +02:00
parent 2d901b2e2b
commit 890f089722
2 changed files with 15 additions and 10 deletions
+10 -5
View File
@@ -143,8 +143,8 @@ function FileTreeController($scope, $translate, $timeout, Client) {
}
$scope.dragStart = function ($event, entry) {
var filePath = sanitize($scope.cwd + '/' + entry.fileName);
$event.originalEvent.dataTransfer.setData('application/cloudron-filemanager', filePath);
var filePaths = $scope.selected.map(function (entry) { return sanitize($scope.cwd + '/' + entry.fileName); });
$event.originalEvent.dataTransfer.setData('application/cloudron-filemanager', JSON.stringify(filePaths));
};
$scope.dragEnter = function ($event, entry) {
@@ -191,11 +191,16 @@ function FileTreeController($scope, $translate, $timeout, Client) {
if (dragContent) {
var moved = 0;
// FIXME only one currently supported
var arr = [ dragContent ];
// we expect a JSON.stringified Array here
try {
dragContent = JSON.parse(dragContent);
} catch (e) {
console.error('Wrong drag content.', e);
return;
}
// move files
async.eachLimit(arr, 5, function (oldFilePath, callback) {
async.eachLimit(dragContent, 5, function (oldFilePath, callback) {
var fileName = oldFilePath.split('/').slice(-1);
var newFilePath = sanitize(targetFolder + '/' + fileName);