mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
b8942acfed
@ -22,6 +22,10 @@ from rest_framework import views
|
||||
|
||||
class TreeSerializer(views.APIView):
|
||||
""" JSON View for serializing a Tree object.
|
||||
|
||||
Turns a 'tree' model into a JSON object compatible with bootstrap-treview.
|
||||
|
||||
Ref: https://github.com/jonmiles/bootstrap-treeview
|
||||
"""
|
||||
|
||||
def itemToJson(self, item):
|
||||
|
@ -14,6 +14,11 @@
|
||||
color: #ffcc00;
|
||||
}
|
||||
|
||||
/* CSS overrides for treeview */
|
||||
.expand-icon {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* Force select2 elements in modal forms to be full width */
|
||||
.select-full-width {
|
||||
width: 100%;
|
||||
|
@ -11,6 +11,29 @@ function loadTree(url, tree, data) {
|
||||
data: response.tree,
|
||||
enableLinks: true
|
||||
});
|
||||
|
||||
var saved_exp = sessionStorage.getItem('inventree-sidenav-expanded-items').split(",");
|
||||
|
||||
// Automatically expand the desired notes
|
||||
for (var q = 0; q < saved_exp.length; q++) {
|
||||
$(tree).treeview('expandNode', parseInt(saved_exp[q]));
|
||||
}
|
||||
|
||||
// Setup a callback whenever a node is toggled
|
||||
$(tree).on('nodeExpanded nodeCollapsed', function(event, data) {
|
||||
|
||||
// Record the entire list of expanded items
|
||||
var expanded = $(tree).treeview('getExpanded');
|
||||
|
||||
var exp = [];
|
||||
|
||||
for (var i = 0; i < expanded.length; i++) {
|
||||
exp.push(expanded[i].nodeId);
|
||||
}
|
||||
|
||||
// Save the expanded nodes
|
||||
sessionStorage.setItem('inventree-sidenav-expanded-items', exp);
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
@ -24,6 +47,8 @@ function openSideNav() {
|
||||
document.getElementById("inventree-content").style.marginLeft = "270px";
|
||||
|
||||
sessionStorage.setItem('inventree-sidenav-state', 'open');
|
||||
|
||||
|
||||
}
|
||||
|
||||
function closeSideNav() {
|
||||
|
Loading…
Reference in New Issue
Block a user