filemanager: Implement multiselect with cmd/ctrl key

This commit is contained in:
Johannes Zellner
2021-01-29 18:35:35 +01:00
parent 3d55cfaaca
commit 66450913b5
3 changed files with 38 additions and 7 deletions

View File

@@ -70,6 +70,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
$scope.rootDirLabel = '';
$scope.title = '';
$scope.entries = [];
$scope.selected = [];
$scope.dropToBody = false;
$scope.sortAsc = true;
$scope.sortProperty = 'fileName';
@@ -305,6 +306,30 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
}
};
$scope.select = function ($event, entry) {
var i = $scope.selected.indexOf(entry);
var multi = ($event.ctrlKey || $event.metaKey);
if ($event.button === 0) {
// left click
if (multi) {
if (i === -1) $scope.selected.push(entry);
else $scope.selected.splice(i, 1);
} else {
$scope.selected = [ entry ];
}
} else if ($event.button === 2) {
// right click
if (i === -1) {
if (multi) $scope.selected.push(entry);
else $scope.selected = [ entry ];
}
}
};
$scope.goDirectoryUp = function () {
$scope.changeDirectory($scope.cwd + '/..');
};
@@ -794,6 +819,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
$scope.menuOptions = [
{
text: tr['filemanager.list.menu.rename'],
enabled: function () { return $scope.selected.length === 1; },
click: function ($itemScope, $event, entry) { $scope.renameEntry.show(entry); }
}, {
text: tr['filemanager.list.menu.chown'],