mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Implemented lazy loading for TreeViewNode state.
This commit is contained in:
parent
fdfe75fad1
commit
f45441352e
1 changed files with 13 additions and 3 deletions
|
@ -40,7 +40,7 @@ class TreeViewNode
|
||||||
protected $href;
|
protected $href;
|
||||||
protected $nodes;
|
protected $nodes;
|
||||||
|
|
||||||
protected $state;
|
protected $state = null;
|
||||||
|
|
||||||
protected $tags;
|
protected $tags;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class TreeViewNode
|
||||||
$this->href = $href;
|
$this->href = $href;
|
||||||
$this->nodes = $nodes;
|
$this->nodes = $nodes;
|
||||||
|
|
||||||
$this->state = new TreeViewNodeState();
|
//$this->state = new TreeViewNodeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +121,7 @@ class TreeViewNode
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getState() : TreeViewNodeState
|
public function getState() : ?TreeViewNodeState
|
||||||
{
|
{
|
||||||
return $this->state;
|
return $this->state;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,11 @@ class TreeViewNode
|
||||||
|
|
||||||
public function setDisabled(?bool $disabled) : self
|
public function setDisabled(?bool $disabled) : self
|
||||||
{
|
{
|
||||||
|
//Lazy loading of state, so it does not need to get serialized and transfered, when it is empty.
|
||||||
|
if ($this->state == null) {
|
||||||
|
$this->state = new TreeViewNodeState();
|
||||||
|
}
|
||||||
|
|
||||||
$this->state->setDisabled($disabled);
|
$this->state->setDisabled($disabled);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -141,6 +146,11 @@ class TreeViewNode
|
||||||
|
|
||||||
public function setSelected(?bool $selected) : self
|
public function setSelected(?bool $selected) : self
|
||||||
{
|
{
|
||||||
|
//Lazy loading of state, so it does not need to get serialized and transfered, when it is empty.
|
||||||
|
if ($this->state == null) {
|
||||||
|
$this->state = new TreeViewNodeState();
|
||||||
|
}
|
||||||
|
|
||||||
$this->state->setSelected($selected);
|
$this->state->setSelected($selected);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue