Add option to disable "toggle" for sidebar

This commit is contained in:
Oliver 2021-10-29 11:48:46 +11:00
parent 890fd0f1a0
commit 6a3c9ead17
3 changed files with 21 additions and 10 deletions

View File

@ -354,6 +354,11 @@ loadSalesOrderTable("#table-so-overdue", {
{% endif %}
enableSidebar('index');
enableSidebar(
'index',
{
hide_toggle: true,
}
);
{% endblock %}

View File

@ -115,15 +115,20 @@ function enableSidebar(label, options={}) {
activatePanel(label, panel_name);
}
// Add callback to "collapse" and "expand" the sidebar
$('#sidebar-toggle').click(function() {
if (options.hide_toggle) {
// Hide the toggle button if specified
$('#sidebar-toggle').remove();
} else {
$('#sidebar-toggle').click(function() {
// Add callback to "collapse" and "expand" the sidebar
// By default, the menu is "expanded"
var state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded';
// We wish to "toggle" the state!
setSidebarState(label, state == "expanded" ? "collapsed" : "expanded");
});
// By default, the menu is "expanded"
var state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded';
// We wish to "toggle" the state!
setSidebarState(label, state == "expanded" ? "collapsed" : "expanded");
});
}
// Set the initial state (default = expanded)
var state = localStorage.getItem(`inventree-menu-state-${label}`) || 'expanded';
@ -132,6 +137,7 @@ function enableSidebar(label, options={}) {
// Finally, show the sidebar
$('#sidebar').show();
}

View File

@ -1,3 +1,3 @@
<a href="#" id='sidebar-toggle' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-toggle" data-bs-parent="#sidebar">
<a href="#" id='sidebar-toggle' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-toggle" data-bs-parent="#sidebar" style='display: none;'>
<i class="bi bi-bootstrap"></i><span id='sidebar-toggle-icon' class='sidebar-item-icon fas fa-chevron-left'></span>
</a>