2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Change "sidetree" to "breadcrumb-tree"

This commit is contained in:
Oliver
2021-12-10 22:53:19 +11:00
parent 8c018cf987
commit 7dcd166d50
5 changed files with 32 additions and 29 deletions

View File

@ -105,23 +105,22 @@
{% endblock %}
{% block breadcrumb_list %}
<div class='container-fluid navigation'>
<div class='container-fluid navigation' id='breadcrumb-div'>
<nav aria-label='breadcrumb'>
<ol class='breadcrumb'>
<ol class='breadcrumb' id='breadcrumb-list'>
{% block breadcrumbs %}
{% endblock %}
</ol>
</nav>
</div>
{% endblock %}
<div class='col-auto px-1 sidebar-wrapper'>
<div id='sidetree' class='collapse collapse-horizontal show border' style='display: none;'>
{% block sidetree %}
{% endblock %}
<div id='breadcrumb-tree-collapse' class='collapse collapse-horizontal show border' style='display: none;'>
{% block breadcrumb_tree %}
{% endblock %}
</div>
</div>
{% endblock %}
{% block content %}
<!-- Each view fills in here.. -->
{% endblock %}

View File

@ -6,8 +6,8 @@
addSidebarHeader,
addSidebarItem,
addSidebarLink,
enableBreadcrumbTree,
enableSidebar,
enableSidetree,
onPanelLoad,
*/
@ -147,10 +147,10 @@ function enableSidebar(label, options={}) {
}
/**
* Enable support for a sidetree on this page
* Enable support for breadcrumb tree navigation on this page
*/
function enableSidetree(label) {
$('#tree').jstree({
function enableBreadcrumbTree(label) {
$('#breadcrumb-tree').jstree({
'core': {
'data': {
'url': '/api/part/category/tree/',
@ -167,29 +167,29 @@ function enableSidetree(label) {
window.location.href = data.node.a_attr.href;
});
$('#sidetree-toggle').click(function() {
$('#breadcrumb-tree-toggle').click(function() {
// Add callback to "collapse" and "expand" the sidebar
// By default, the menu is "expanded"
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
// We wish to "toggle" the state!
setSidetreeState(label, state == 'expanded' ? 'collapsed' : 'expanded');
setBreadcrumbTreeState(label, state == 'expanded' ? 'collapsed' : 'expanded');
});
// Set the initial state (default = expanded)
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
setSidetreeState(label, state);
setBreadcrumbTreeState(label, state);
function setBreadcrumbTreeState(label, state) {
function setSidetreeState(label, state) {
if (state == 'collapsed') {
$('#sidetree').hide(100);
$(`#sidetree-toggle-icon`).removeClass('fa-chevron-left').addClass('fa-chevron-right');
$('#breadcrumb-tree-collapse').hide(100);
} else {
$('#sidetree').show(100);
$(`#sidetree-toggle-icon`).removeClass('fa-chevron-right').addClass('fa-chevron-left');
$('#breadcrumb-tree-collapse').show(100);
}
localStorage.setItem(`inventree-tree-state-${label}`, state);
}
}