Select entry on context menu in filemanager

This commit is contained in:
Johannes Zellner
2022-09-29 17:29:42 +02:00
parent 90ed8be1a0
commit 5a02ab8aba
2 changed files with 18 additions and 27 deletions
+11 -20
View File
@@ -319,34 +319,25 @@ function FileTreeController($scope, $translate, $timeout, Client) {
openPath(sanitize(path));
};
$scope.select = function ($event, entry) {
// we don't stop propagation for context menu closing, but if targets don't match we got the whole list click event
$scope.onClearSelection = function ($event) {
// we don't stop propagation if targets don't match we got the whole list click event
if ($event.currentTarget !== $event.target) return;
if (!entry) {
$scope.selected = [];
return;
}
$scope.selected = [];
};
$scope.onMousedown = 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 (multi) {
if (i === -1) {
if (multi) $scope.selected.push(entry);
else $scope.selected = [ entry ];
$scope.selected.push(entry);
} else if ($event.button === 0) { // only do this on left click
$scope.selected.splice(i, 1);
}
} else {
$scope.selected = [ entry ];
}
};