mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
Refactor sidebar for "stock item" page
This commit is contained in:
@ -8,41 +8,6 @@
|
||||
onPanelLoad,
|
||||
*/
|
||||
|
||||
/*
|
||||
* Attach callbacks to navigation bar elements.
|
||||
*
|
||||
* Searches for elements with the class 'nav-toggle'.
|
||||
* A callback is added to each element,
|
||||
* to display the matching panel.
|
||||
*
|
||||
* The 'id' of the .nav-toggle element should be of the form "select-<x>",
|
||||
* and point to a matching "panel-<x>"
|
||||
*/
|
||||
function attachNavCallbacksX(options={}) {
|
||||
|
||||
$('.nav-toggle').click(function() {
|
||||
var el = $(this);
|
||||
|
||||
// Find the matching "panel" element
|
||||
var panelName = el.attr('id').replace('select-', '');
|
||||
|
||||
activatePanel(panelName, options);
|
||||
});
|
||||
|
||||
var panelClass = options.name || 'unknown';
|
||||
|
||||
/* Look for a default panel to initialize
|
||||
* First preference = URL parameter e.g. ?display=part-stock
|
||||
* Second preference = localStorage
|
||||
* Third preference = default
|
||||
*/
|
||||
var defaultPanel = $.urlParam('display') || localStorage.getItem(`inventree-selected-panel-${panelClass}`) || options.default;
|
||||
|
||||
if (defaultPanel) {
|
||||
activatePanel(defaultPanel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Activate (display) the selected panel
|
||||
*/
|
||||
@ -52,6 +17,8 @@ function activatePanel(label, panel_name, options={}) {
|
||||
$('.panel-visible').hide();
|
||||
$('.panel-visible').removeClass('panel-visible');
|
||||
|
||||
console.log('active panel:', label, panel_name);
|
||||
|
||||
// Find the target panel
|
||||
var panel = `#panel-${panel_name}`;
|
||||
var select = `#select-${panel_name}`;
|
||||
|
Reference in New Issue
Block a user