mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #2451 from sintech/tree_improvement
Subcategory treeview improvements
This commit is contained in:
commit
51543dff21
@ -175,7 +175,6 @@ function enableBreadcrumbTree(options) {
|
|||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
node = data[i];
|
node = data[i];
|
||||||
node.nodes = [];
|
|
||||||
nodes[node.pk] = node;
|
nodes[node.pk] = node;
|
||||||
node.selectable = false;
|
node.selectable = false;
|
||||||
|
|
||||||
@ -193,10 +192,17 @@ function enableBreadcrumbTree(options) {
|
|||||||
node = data[i];
|
node = data[i];
|
||||||
|
|
||||||
if (node.parent != null) {
|
if (node.parent != null) {
|
||||||
nodes[node.parent].nodes.push(node);
|
if (nodes[node.parent].nodes) {
|
||||||
|
nodes[node.parent].nodes.push(node);
|
||||||
|
} else {
|
||||||
|
nodes[node.parent].nodes = [node];
|
||||||
|
}
|
||||||
|
|
||||||
if (node.state.expanded) {
|
if (node.state.expanded) {
|
||||||
nodes[node.parent].state.expanded = true;
|
while (node.parent != null) {
|
||||||
|
nodes[node.parent].state.expanded = true;
|
||||||
|
node = nodes[node.parent];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -212,7 +218,6 @@ function enableBreadcrumbTree(options) {
|
|||||||
collapseIcon: 'fa fa-chevron-down',
|
collapseIcon: 'fa fa-chevron-down',
|
||||||
});
|
});
|
||||||
|
|
||||||
setBreadcrumbTreeState(label, state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -220,26 +225,11 @@ function enableBreadcrumbTree(options) {
|
|||||||
$('#breadcrumb-tree-toggle').click(function() {
|
$('#breadcrumb-tree-toggle').click(function() {
|
||||||
// Add callback to "collapse" and "expand" the sidebar
|
// Add callback to "collapse" and "expand" the sidebar
|
||||||
|
|
||||||
// By default, the menu is "expanded"
|
// Toggle treeview visibilty
|
||||||
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
|
$('#breadcrumb-tree-collapse').toggle();
|
||||||
|
|
||||||
// We wish to "toggle" the state!
|
|
||||||
setBreadcrumbTreeState(label, state == 'expanded' ? 'collapsed' : 'expanded');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set the initial state (default = expanded)
|
|
||||||
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
|
|
||||||
|
|
||||||
function setBreadcrumbTreeState(label, state) {
|
|
||||||
|
|
||||||
if (state == 'collapsed') {
|
|
||||||
$('#breadcrumb-tree-collapse').hide(100);
|
|
||||||
} else {
|
|
||||||
$('#breadcrumb-tree-collapse').show(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem(`inventree-tree-state-${label}`, state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user