mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add sidetree toggler function
This commit is contained in:
parent
b5ae9edc2e
commit
f375ba96ae
@ -4,6 +4,9 @@
|
||||
|
||||
{% settings_value 'PART_SHOW_IMPORT' as show_import %}
|
||||
|
||||
{% include "sidebar_toggle.html" with target="sidetree" %}
|
||||
<a class="m-1"></a>
|
||||
|
||||
{% trans "Subcategories" as text %}
|
||||
{% include "sidebar_item.html" with label="subcategories" text=text icon="fa-sitemap" %}
|
||||
{% trans "Parts" as text %}
|
||||
|
@ -5,7 +5,9 @@
|
||||
{% settings_value "PART_INTERNAL_PRICE" as show_internal_price %}
|
||||
{% settings_value 'PART_SHOW_RELATED' as show_related %}
|
||||
|
||||
{% include "sidebar_toggle.html" with target="#sidetree" %}
|
||||
{% include "sidebar_toggle.html" with target="sidetree" %}
|
||||
<a class="m-1"></a>
|
||||
|
||||
{% trans "Parameters" as text %}
|
||||
{% include "sidebar_item.html" with label="part-parameters" text=text icon="fa-th-list" %}
|
||||
{% if part.is_template %}
|
||||
|
@ -74,7 +74,7 @@
|
||||
<div class='main body wrapper container-fluid inventree-body'>
|
||||
|
||||
<div class='row flex-nowrap inventree-body'>
|
||||
<div class='col-auto px-1 sidetree-wrapper'>
|
||||
<div class='col-auto px-1 sidetree-wrapper' style='display: none;'>
|
||||
<div id='sidetree' class='collapse collapse-horizontal show border-end' style='display: none;'>
|
||||
{% block sidetree %}
|
||||
{% endblock %}
|
||||
|
@ -154,7 +154,7 @@ function enableSidetree(label) {
|
||||
'core': {
|
||||
'data': {
|
||||
'url': '/api/part/category/tree/',
|
||||
'data': function(node){return {'id': node.id }; }
|
||||
'data': function(node) {return {'id': node.id}; }
|
||||
}
|
||||
}
|
||||
}).bind('select_node.jstree', function(e, data) {
|
||||
@ -168,16 +168,27 @@ function enableSidetree(label) {
|
||||
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
|
||||
|
||||
// We wish to "toggle" the state!
|
||||
setSidebarState(label, state == 'expanded' ? 'collapsed' : 'expanded');
|
||||
setSidetreeState(label, state == 'expanded' ? 'collapsed' : 'expanded');
|
||||
});
|
||||
|
||||
// Set the initial state (default = expanded)
|
||||
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
|
||||
|
||||
// setSidebarState(label, state);
|
||||
setSidetreeState(label, state);
|
||||
|
||||
// Finally, show the sidebar
|
||||
$('#sidetree').show();
|
||||
|
||||
function setSidetreeState(label, state) {
|
||||
if (state == 'collapsed') {
|
||||
$('.sidetree-wrapper').hide(100);
|
||||
$(`#sidetree-toggle-icon`).removeClass('fa-chevron-left').addClass('fa-chevron-right');
|
||||
} else {
|
||||
$('.sidetree-wrapper').show(100);
|
||||
$(`#sidetree-toggle-icon`).removeClass('fa-chevron-right').addClass('fa-chevron-left');
|
||||
}
|
||||
localStorage.setItem(`inventree-tree-state-${label}`, state);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user