mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-15 06:30:26 +02:00
fix: expand every folder by default in the explorer tree
The file tree opened collapsed, requiring the reviewer to click each folder before they could see what was inside. Walk the tree on first render and mark every folder open in $scope.opens. Folders the user has explicitly toggled (a previous entry already exists in $scope.opens) are left as-is, so collapsing still works. Fixes #496.
This commit is contained in:
@@ -509,6 +509,22 @@ angular
|
||||
});
|
||||
}
|
||||
|
||||
// #496 — expand every folder on first load so reviewers see the
|
||||
// whole tree without clicking through. Folders the user has
|
||||
// already toggled (state recorded in $scope.opens) are left
|
||||
// alone, so collapsing a folder still works.
|
||||
function expandAllFolders(nodes, parentPath) {
|
||||
if (!nodes) return;
|
||||
for (const f of nodes) {
|
||||
if (!f.child) continue;
|
||||
const path = `${parentPath}/${f.name}`;
|
||||
if (!(path in $scope.opens)) {
|
||||
$scope.opens[path] = true;
|
||||
}
|
||||
expandAllFolders(f.child, path);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$watch(
|
||||
"file",
|
||||
(newValue) => {
|
||||
@@ -516,6 +532,7 @@ angular
|
||||
if (newValue.length == 0) {
|
||||
return $element.html("Empty repository");
|
||||
}
|
||||
expandAllFolders(toArray(newValue), "");
|
||||
display();
|
||||
},
|
||||
true
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user