filemanager: Implement multiselect with cmd/ctrl key
This commit is contained in:
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user