mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Show the count of the sub categories in the entity admin treeview.
This commit is contained in:
parent
650b388a1d
commit
d04a8626cb
5 changed files with 34 additions and 0 deletions
|
@ -513,6 +513,11 @@ span.highlight {
|
||||||
padding-bottom: 3px;
|
padding-bottom: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.treeview .badge {
|
||||||
|
margin-left: auto;
|
||||||
|
line-height: 1.42857143;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
* Pagination bar
|
* Pagination bar
|
||||||
*****************************/
|
*****************************/
|
||||||
|
|
|
@ -140,6 +140,11 @@ $(document).on("ajaxUI:start ajaxUI:reload", function() {
|
||||||
enableLinks: false,
|
enableLinks: false,
|
||||||
showIcon: false,
|
showIcon: false,
|
||||||
showBorder: true,
|
showBorder: true,
|
||||||
|
showTags: true,
|
||||||
|
//@ts-ignore
|
||||||
|
wrapNode: true,
|
||||||
|
//@ts-ignore
|
||||||
|
tagsClass: 'badge badge-secondary badge-pill pull-right',
|
||||||
expandIcon: "fas fa-plus fa-fw fa-treeview", collapseIcon: "fas fa-minus fa-fw fa-treeview",
|
expandIcon: "fas fa-plus fa-fw fa-treeview", collapseIcon: "fas fa-minus fa-fw fa-treeview",
|
||||||
onNodeSelected: function(event, data) {
|
onNodeSelected: function(event, data) {
|
||||||
if(data.href) {
|
if(data.href) {
|
||||||
|
|
|
@ -42,6 +42,8 @@ class TreeViewNode
|
||||||
|
|
||||||
protected $state;
|
protected $state;
|
||||||
|
|
||||||
|
protected $tags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new TreeView node with the given parameters.
|
* 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)
|
* @param string $text The text that is shown in the node. (e.g. the name of the node)
|
||||||
|
@ -144,4 +146,21 @@ class TreeViewNode
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTags() : ?array
|
||||||
|
{
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTag(string $new_tag) : self
|
||||||
|
{
|
||||||
|
//Lazy loading tags
|
||||||
|
if ($this->tags == null) {
|
||||||
|
$this->tags = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tags[] = $new_tag;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,10 @@ class TreeBuilder
|
||||||
|
|
||||||
$tree_node = new TreeViewNode($element->getName(), $href, $children_nodes);
|
$tree_node = new TreeViewNode($element->getName(), $href, $children_nodes);
|
||||||
|
|
||||||
|
if($children_nodes != null) {
|
||||||
|
$tree_node->addTag((string) count($children_nodes));
|
||||||
|
}
|
||||||
|
|
||||||
//Check if we need to select the current part
|
//Check if we need to select the current part
|
||||||
if ($selectedElement !== null && $element->getID() === $selectedElement->getID()) {
|
if ($selectedElement !== null && $element->getID() === $selectedElement->getID()) {
|
||||||
$tree_node->setSelected(true);
|
$tree_node->setSelected(true);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
|
||||||
|
|
||||||
<div class="treeview-sm" id="tree" data-tree-data="{{ generateTreeData(entity) }}">
|
<div class="treeview-sm" id="tree" data-tree-data="{{ generateTreeData(entity) }}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue