mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	add sidetree toggler function
This commit is contained in:
		@@ -4,6 +4,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% settings_value 'PART_SHOW_IMPORT' as show_import %}
 | 
					{% settings_value 'PART_SHOW_IMPORT' as show_import %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% include "sidebar_toggle.html" with target="sidetree" %}
 | 
				
			||||||
 | 
					<a class="m-1"></a>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% trans "Subcategories" as text %}
 | 
					{% trans "Subcategories" as text %}
 | 
				
			||||||
{% include "sidebar_item.html" with label="subcategories" text=text icon="fa-sitemap" %}
 | 
					{% include "sidebar_item.html" with label="subcategories" text=text icon="fa-sitemap" %}
 | 
				
			||||||
{% trans "Parts" as text %}
 | 
					{% trans "Parts" as text %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,9 @@
 | 
				
			|||||||
{% settings_value "PART_INTERNAL_PRICE" as show_internal_price %}
 | 
					{% settings_value "PART_INTERNAL_PRICE" as show_internal_price %}
 | 
				
			||||||
{% settings_value 'PART_SHOW_RELATED' as show_related %}
 | 
					{% 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 %}
 | 
					{% trans "Parameters" as text %}
 | 
				
			||||||
{% include "sidebar_item.html" with label="part-parameters" text=text icon="fa-th-list" %}
 | 
					{% include "sidebar_item.html" with label="part-parameters" text=text icon="fa-th-list" %}
 | 
				
			||||||
{% if part.is_template %}
 | 
					{% if part.is_template %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,7 +74,7 @@
 | 
				
			|||||||
<div class='main body wrapper container-fluid inventree-body'>
 | 
					<div class='main body wrapper container-fluid inventree-body'>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div class='row flex-nowrap 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;'>
 | 
					            <div id='sidetree' class='collapse collapse-horizontal show border-end' style='display: none;'>
 | 
				
			||||||
            {% block sidetree %}
 | 
					            {% block sidetree %}
 | 
				
			||||||
            {% endblock %}
 | 
					            {% endblock %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -168,16 +168,27 @@ function enableSidetree(label) {
 | 
				
			|||||||
        var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
 | 
					        var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // We wish to "toggle" the state!
 | 
					        // We wish to "toggle" the state!
 | 
				
			||||||
        setSidebarState(label, state == 'expanded' ? 'collapsed' : 'expanded');
 | 
					        setSidetreeState(label, state == 'expanded' ? 'collapsed' : 'expanded');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set the initial state (default = expanded)
 | 
					    // Set the initial state (default = expanded)
 | 
				
			||||||
    var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
 | 
					    var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // setSidebarState(label, state);
 | 
					    setSidetreeState(label, state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Finally, show the sidebar
 | 
					    // Finally, show the sidebar
 | 
				
			||||||
    $('#sidetree').show();
 | 
					    $('#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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user