mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Can select nav based on URL query parameter
This commit is contained in:
parent
3786454e4c
commit
352a58b373
@ -781,7 +781,7 @@ input[type="submit"] {
|
||||
}
|
||||
|
||||
.sidenav .list-group-item.active {
|
||||
background-color: #ddd;
|
||||
background-color: #bbab8b;
|
||||
border-color: #ccc;
|
||||
}
|
||||
|
||||
|
@ -4678,7 +4678,7 @@ input[type="submit"].btn.btn-mini {
|
||||
|
||||
.navbar .btn-navbar:active,
|
||||
.navbar .btn-navbar.active {
|
||||
background-color: #cccccc \9;
|
||||
background-color: #ba8;
|
||||
}
|
||||
|
||||
.navbar .btn-navbar .icon-bar {
|
||||
|
@ -3,6 +3,14 @@
|
||||
|
||||
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
|
||||
function getCookie(name) {
|
||||
var cookieValue = null;
|
||||
|
@ -23,8 +23,12 @@ function attachNavCallbacks(options={}) {
|
||||
|
||||
var panelClass = options.name || 'unknown';
|
||||
|
||||
// Look for a default panel to initialize
|
||||
var defaultPanel = localStorage.getItem(`inventree-selected-panel-${panelClass}`) || options.default;
|
||||
/* 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);
|
||||
@ -63,6 +67,9 @@ function activatePanel(panelName, options={}) {
|
||||
console.log("found match -", panel_name);
|
||||
panelName = panel_name;
|
||||
}
|
||||
|
||||
panel = `#panel-${panelName}`;
|
||||
select = `#select-${panelName}`;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user