2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 20:46:47 +00:00

Can select nav based on URL query parameter

This commit is contained in:
Oliver 2021-07-15 13:41:26 +10:00
parent 3786454e4c
commit 352a58b373
4 changed files with 19 additions and 4 deletions

View File

@ -781,7 +781,7 @@ input[type="submit"] {
} }
.sidenav .list-group-item.active { .sidenav .list-group-item.active {
background-color: #ddd; background-color: #bbab8b;
border-color: #ccc; border-color: #ccc;
} }

View File

@ -4678,7 +4678,7 @@ input[type="submit"].btn.btn-mini {
.navbar .btn-navbar:active, .navbar .btn-navbar:active,
.navbar .btn-navbar.active { .navbar .btn-navbar.active {
background-color: #cccccc \9; background-color: #ba8;
} }
.navbar .btn-navbar .icon-bar { .navbar .btn-navbar .icon-bar {

View File

@ -3,6 +3,14 @@
var jQuery = window.$; var jQuery = window.$;
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results==null) {
return null;
}
return decodeURI(results[1]) || 0;
}
// using jQuery // using jQuery
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;

View File

@ -23,8 +23,12 @@ function attachNavCallbacks(options={}) {
var panelClass = options.name || 'unknown'; var panelClass = options.name || 'unknown';
// Look for a default panel to initialize /* Look for a default panel to initialize
var defaultPanel = localStorage.getItem(`inventree-selected-panel-${panelClass}`) || options.default; * 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) { if (defaultPanel) {
activatePanel(defaultPanel); activatePanel(defaultPanel);
@ -63,6 +67,9 @@ function activatePanel(panelName, options={}) {
console.log("found match -", panel_name); console.log("found match -", panel_name);
panelName = panel_name; panelName = panel_name;
} }
panel = `#panel-${panelName}`;
select = `#select-${panelName}`;
}); });
} }