Add expand/collapse all feature in drive tree

pull/1/head
ClemDee 6 years ago
parent 73c2964241
commit 634b051d42

@ -383,6 +383,8 @@
"fc_rename": "Renommer",
"fc_open": "Ouvrir",
"fc_open_ro": "Ouvrir (lecture seule)",
"fc_expandAll": "Développer tout",
"fc_collapseAll": "Réduire tout",
"fc_delete": "Déplacer vers la corbeille",
"fc_delete_owned": "Supprimer du serveur",
"fc_restore": "Restaurer",

@ -387,6 +387,8 @@
"fc_rename": "Rename",
"fc_open": "Open",
"fc_open_ro": "Open (read-only)",
"fc_expandAll": "Expand All",
"fc_collapseAll": "Collapse All",
"fc_delete": "Move to trash",
"fc_delete_owned": "Delete from the server",
"fc_restore": "Restore",

@ -293,6 +293,14 @@ define([
'tabindex': '-1',
'data-icon': faReadOnly,
}, Messages.fc_open_ro)),
h('li', h('a.cp-app-drive-context-expandall.dropdown-item', {
'tabindex': '-1',
'data-icon': "expandAll",
}, Messages.fc_expandAll)),
h('li', h('a.cp-app-drive-context-collapseall.dropdown-item', {
'tabindex': '-1',
'data-icon': "collapseAll",
}, Messages.fc_collapseAll)),
h('li', h('a.cp-app-drive-context-download.dropdown-item', {
'tabindex': '-1',
'data-icon': faDownload,
@ -878,6 +886,10 @@ define([
paths.forEach(function (p) {
var path = p.path;
var $element = p.element;
if (!$element.closest("#cp-app-drive-tree").length) {
hide.push('expandall');
hide.push('collapseall');
}
if (path.length === 1) {
// Can't rename or delete root elements
hide.push('delete');
@ -908,6 +920,8 @@ define([
if (containsFolder) {
// More than 1 folder selected: cannot create a new subfolder
hide.push('newfolder');
hide.push('expandall');
hide.push('collapseall');
}
containsFolder = true;
hide.push('openro');
@ -918,6 +932,8 @@ define([
if (containsFolder) {
// More than 1 folder selected: cannot create a new subfolder
hide.push('newfolder');
hide.push('expandall');
hide.push('collapseall');
}
containsFolder = true;
hide.push('openro');
@ -970,7 +986,7 @@ define([
show = ['newfolder', 'newsharedfolder', 'newdoc'];
break;
case 'tree':
show = ['open', 'openro', 'download', 'share', 'rename', 'delete', 'deleteowned', 'removesf',
show = ['open', 'openro', 'expandall', 'collapseall', 'download', 'share', 'rename', 'delete', 'deleteowned', 'removesf',
'newfolder', 'properties', 'hashtag'];
break;
case 'default':
@ -3336,6 +3352,32 @@ define([
openFile(null, href);
});
}
else if ($(this).hasClass('cp-app-drive-context-expandall') ||
$(this).hasClass('cp-app-drive-context-collapseall')) {
if (paths.length !== 1) { return; }
var opened = $(this).hasClass('cp-app-drive-context-expandall');
var openRecursive = function (path) {
setFolderOpened(path, opened);
var folderContent = manager.find(path);
var subfolders = [];
for (var k in folderContent) {
if (manager.isFolder(folderContent[k])) {
if (manager.isSharedFolder(folderContent[k])) {
subfolders.push([k].concat(manager.user.userObject.ROOT));
}
else {
subfolders.push(k);
}
}
}
subfolders.forEach(function (p) {
var subPath = path.concat(p);
openRecursive(subPath);
});
};
openRecursive(paths[0].path);
refresh();
}
else if ($(this).hasClass('cp-app-drive-context-download')) {
if (paths.length !== 1) { return; }
el = manager.find(paths[0].path);

Loading…
Cancel
Save