Show a treeview in the admin menus, to select between the different elements.

This commit is contained in:
Jan Böhmer 2019-04-05 17:49:02 +02:00
parent 928b574d8c
commit 650b388a1d
16 changed files with 269 additions and 25 deletions

View file

@ -40,6 +40,8 @@ class TreeViewNode
protected $href;
protected $nodes;
protected $state;
/**
* Creates a new TreeView node with the given parameters.
* @param string $text The text that is shown in the node. (e.g. the name of the node)
@ -53,6 +55,8 @@ class TreeViewNode
$this->text = $text;
$this->href = $href;
$this->nodes = $nodes;
$this->state = new TreeViewNodeState();
}
/**
@ -115,4 +119,29 @@ class TreeViewNode
return $this;
}
public function getState() : TreeViewNodeState
{
return $this->state;
}
public function setState(TreeViewNodeState $state) : self
{
$this->state = $state;
return $this;
}
public function setDisabled(?bool $disabled) : self
{
$this->state->setDisabled($disabled);
return $this;
}
public function setSelected(?bool $selected) : self
{
$this->state->setSelected($selected);
return $this;
}
}

View file

@ -0,0 +1,98 @@
<?php
/**
*
* part-db version 0.1
* Copyright (C) 2005 Christoph Lechner
* http://www.cl-projects.de/
*
* part-db version 0.2+
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
* http://code.google.com/p/part-db/
*
* Part-DB Version 0.4+
* Copyright (C) 2016 - 2019 Jan Böhmer
* https://github.com/jbtronics
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Helpers;
class TreeViewNodeState
{
/** @var null|bool */
protected $checked = null;
/** @var null|bool */
protected $disabled = null;
/** @var null|bool */
protected $expanded = null;
/** @var null|bool */
protected $selected = null;
/**
* @return bool|null
*/
public function getDisabled(): ?bool
{
return $this->disabled;
}
/**
* @param bool|null $disabled
*/
public function setDisabled(?bool $disabled): void
{
$this->disabled = $disabled;
}
/**
* @return bool|null
*/
public function getExpanded(): ?bool
{
return $this->expanded;
}
/**
* @param bool|null $expanded
*/
public function setExpanded(?bool $expanded): void
{
$this->expanded = $expanded;
}
/**
* @return bool|null
*/
public function getSelected(): ?bool
{
return $this->selected;
}
/**
* @param bool|null $selected
*/
public function setSelected(?bool $selected): void
{
$this->selected = $selected;
}
}