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

first working example

This commit is contained in:
Matthias
2021-12-06 22:35:14 +01:00
parent de4d057b93
commit 70939a0cf9
6 changed files with 108 additions and 0 deletions

View File

@ -46,6 +46,7 @@
<link rel="stylesheet" href="{% static 'select2/css/select2-bootstrap-5-theme.css' %}">
<link rel="stylesheet" href="{% static 'fullcalendar/main.css' %}">
<link rel="stylesheet" href="{% static 'script/jquery-ui/jquery-ui.min.css' %}">
<link rel="stylesheet" href="{% static 'script/jstree/themes/default/style.min.css' %}">
<link rel="stylesheet" href="{% static 'css/inventree.css' %}">

View File

@ -145,6 +145,43 @@ function enableSidebar(label, options={}) {
}
/**
* Enable support for a sidetree on this page
*/
function enableSidetree(label, options={}) {
$('#tree').jstree({
'core' : {
'data' : {
'url' : function (node) {
return '/api/part/category/tree/root/'
},
'data' : function (node) {
return { 'id' : node.id };
}
}
}
}).bind("select_node.jstree",function (e, data) {
window.location.href = data.node.a_attr.href;
});
$('#sidetree-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!
setSidebarState(label, state == 'expanded' ? 'collapsed' : 'expanded');
});
// Set the initial state (default = expanded)
var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded';
// setSidebarState(label, state);
// Finally, show the sidebar
$('#sidetree').show();
}
/*
* Set the "toggle" state of the sidebar