Put sidebar trees under a root node.

This commit is contained in:
Jan Böhmer 2020-10-03 13:56:30 +02:00
parent e05d707918
commit c6970505c7
5 changed files with 44 additions and 10 deletions

View file

@ -204,6 +204,18 @@ final class TreeViewNode implements JsonSerializable
return $this;
}
public function setExpanded(?bool $selected): self
{
//Lazy loading of state, so it does not need to get serialized and transfered, when it is empty.
if (null === $this->state) {
$this->state = new TreeViewNodeState();
}
$this->state->setExpanded(true);
return $this;
}
public function getTags(): ?array
{
return $this->tags;

View file

@ -66,9 +66,10 @@ final class TreeViewNodeState implements JsonSerializable
return $this->disabled;
}
public function setDisabled(?bool $disabled): void
public function setDisabled(?bool $disabled): self
{
$this->disabled = $disabled;
return $this;
}
public function getExpanded(): ?bool
@ -76,9 +77,10 @@ final class TreeViewNodeState implements JsonSerializable
return $this->expanded;
}
public function setExpanded(?bool $expanded): void
public function setExpanded(?bool $expanded): self
{
$this->expanded = $expanded;
return $this;
}
public function getSelected(): ?bool
@ -86,9 +88,10 @@ final class TreeViewNodeState implements JsonSerializable
return $this->selected;
}
public function setSelected(?bool $selected): void
public function setSelected(?bool $selected): self
{
$this->selected = $selected;
return $this;
}
public function jsonSerialize()