mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-19 05:38:54 +01:00
Show the count of the sub categories in the entity admin treeview.
This commit is contained in:
@@ -513,6 +513,11 @@ span.highlight {
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
|
||||
.treeview .badge {
|
||||
margin-left: auto;
|
||||
line-height: 1.42857143;
|
||||
}
|
||||
|
||||
/*****************************
|
||||
* Pagination bar
|
||||
*****************************/
|
||||
|
||||
@@ -140,6 +140,11 @@ $(document).on("ajaxUI:start ajaxUI:reload", function() {
|
||||
enableLinks: false,
|
||||
showIcon: false,
|
||||
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",
|
||||
onNodeSelected: function(event, data) {
|
||||
if(data.href) {
|
||||
|
||||
@@ -42,6 +42,8 @@ class TreeViewNode
|
||||
|
||||
protected $state;
|
||||
|
||||
protected $tags;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
@@ -144,4 +146,21 @@ class TreeViewNode
|
||||
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);
|
||||
|
||||
if($children_nodes != null) {
|
||||
$tree_node->addTag((string) count($children_nodes));
|
||||
}
|
||||
|
||||
//Check if we need to select the current part
|
||||
if ($selectedElement !== null && $element->getID() === $selectedElement->getID()) {
|
||||
$tree_node->setSelected(true);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
|
||||
|
||||
<div class="treeview-sm" id="tree" data-tree-data="{{ generateTreeData(entity) }}">
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user