@onehat/ui 0.3.377 → 0.3.379
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -50,6 +50,7 @@ import Input from '../Form/Field/Input.js';
|
|
|
50
50
|
import Xmark from '../Icons/Xmark.js';
|
|
51
51
|
import Dot from '../Icons/Dot.js';
|
|
52
52
|
import Collapse from '../Icons/Collapse.js';
|
|
53
|
+
import Expand from '../Icons/Expand.js';
|
|
53
54
|
import FolderClosed from '../Icons/FolderClosed.js';
|
|
54
55
|
import FolderOpen from '../Icons/FolderOpen.js';
|
|
55
56
|
import MagnifyingGlass from '../Icons/MagnifyingGlass.js';
|
|
@@ -354,16 +355,17 @@ function TreeComponent(props) {
|
|
|
354
355
|
|
|
355
356
|
buildRowToDatumMap();
|
|
356
357
|
},
|
|
357
|
-
onCollapseAll = (
|
|
358
|
-
// Go through whole tree and collapse all nodes
|
|
358
|
+
onCollapseAll = () => {
|
|
359
359
|
const newTreeNodeData = _.clone(getTreeNodeData());
|
|
360
360
|
collapseNodes(newTreeNodeData);
|
|
361
|
-
|
|
362
|
-
|
|
361
|
+
setTreeNodeData(newTreeNodeData);
|
|
362
|
+
},
|
|
363
|
+
onExpandAll = () => {
|
|
364
|
+
confirm('Are you sure you want to expand the whole tree? This may take a while.', async () => {
|
|
365
|
+
const newTreeNodeData = _.clone(getTreeNodeData());
|
|
366
|
+
await expandNodes(newTreeNodeData);
|
|
363
367
|
setTreeNodeData(newTreeNodeData);
|
|
364
|
-
}
|
|
365
|
-
buildRowToDatumMap();
|
|
366
|
-
return newTreeNodeData;
|
|
368
|
+
});
|
|
367
369
|
},
|
|
368
370
|
onSearchTree = async (q) => {
|
|
369
371
|
let found = [];
|
|
@@ -655,6 +657,10 @@ function TreeComponent(props) {
|
|
|
655
657
|
|
|
656
658
|
try {
|
|
657
659
|
|
|
660
|
+
if (depth === 'all') {
|
|
661
|
+
depth = 9999;
|
|
662
|
+
}
|
|
663
|
+
|
|
658
664
|
const children = await datum.item.loadChildren(depth);
|
|
659
665
|
datum.children = buildTreeNodeData(children);
|
|
660
666
|
datum.isExpanded = true;
|
|
@@ -685,6 +691,25 @@ function TreeComponent(props) {
|
|
|
685
691
|
}
|
|
686
692
|
});
|
|
687
693
|
},
|
|
694
|
+
expandNodes = async (nodes) => {
|
|
695
|
+
await expandNodesRecursive(nodes);
|
|
696
|
+
buildRowToDatumMap();
|
|
697
|
+
},
|
|
698
|
+
expandNodesRecursive = async (nodes) => {
|
|
699
|
+
// TODO: instead of doing everything sequentially,
|
|
700
|
+
// load the tree in parallel, using aync functions
|
|
701
|
+
// Every time a node loads, it should update the tree.
|
|
702
|
+
|
|
703
|
+
for (const node of nodes) {
|
|
704
|
+
if (node.item.hasChildren && !node.item.areChildrenLoaded) {
|
|
705
|
+
await loadChildren(node, 'all');
|
|
706
|
+
}
|
|
707
|
+
node.isExpanded = true;
|
|
708
|
+
if (!_.isEmpty(node.children)) {
|
|
709
|
+
await expandNodesRecursive(node.children);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
},
|
|
688
713
|
expandPath = async (cPath, highlight = true) => {
|
|
689
714
|
// First, close the whole tree.
|
|
690
715
|
let newTreeNodeData = _.clone(getTreeNodeData());
|
|
@@ -789,12 +814,19 @@ function TreeComponent(props) {
|
|
|
789
814
|
isDisabled: !treeSearchValue.length,
|
|
790
815
|
},
|
|
791
816
|
{
|
|
792
|
-
key: '
|
|
817
|
+
key: 'collapseAllBtn',
|
|
793
818
|
text: 'Collapse whole tree',
|
|
794
819
|
handler: onCollapseAll,
|
|
795
820
|
icon: Collapse,
|
|
796
821
|
isDisabled: false,
|
|
797
822
|
},
|
|
823
|
+
{
|
|
824
|
+
key: 'expandAllBtn',
|
|
825
|
+
text: 'Expand whole tree',
|
|
826
|
+
handler: onExpandAll,
|
|
827
|
+
icon: Expand,
|
|
828
|
+
isDisabled: false,
|
|
829
|
+
},
|
|
798
830
|
];
|
|
799
831
|
if (canNodesReorder) {
|
|
800
832
|
buttons.push({
|