Skip to content

Commit

Permalink
Expand root node by default
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 3, 2025
1 parent 4264da8 commit 0b698e9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/aiidalab_qe/app/result/components/status/process_tree/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def render(self):
self.collapse_button.on_click(self._collapse_all)
root = self._model.fetch_process_node()
self.trunk = WorkChainTreeNode(node=root, on_inspect=self._on_inspect)
self.trunk.expand()
self.rendered = True
self._update()
self.children = [
Expand All @@ -68,7 +69,7 @@ def _update(self):
self.trunk.update()

def _collapse_all(self, _):
self.trunk.collapse()
self.trunk.collapse(recursive=True)


class TreeNode(ipw.VBox):
Expand Down Expand Up @@ -175,12 +176,21 @@ def update(self, node=None):
for branch in self.branches.children:
branch.update()

def collapse(self):
def expand(self, recursive=False):
if self.collapsed:
self.toggle.click()
if recursive:
for branch in self.branches.children:
if isinstance(branch, WorkChainTreeNode):
branch.expand(recursive=True)

def collapse(self, recursive=False):
if not self.collapsed:
self.toggle.click()
for branch in self.branches.children:
if isinstance(branch, WorkChainTreeNode):
branch.collapse()
if recursive:
for branch in self.branches.children:
if isinstance(branch, WorkChainTreeNode):
branch.collapse(recursive=True)

def _build_header(self, node, level):
super()._build_header(node, level)
Expand Down

0 comments on commit 0b698e9

Please sign in to comment.