mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 09:53:35 +02:00
Mark sidebar and navbar as permanent between Turbo history navigations.
This commit is contained in:
parent
5ec87f911b
commit
e26f6e5394
3 changed files with 22 additions and 2 deletions
|
@ -10,6 +10,11 @@ export default class extends TreeController {
|
||||||
_storage_key;
|
_storage_key;
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
|
//Check if the tree is already initialized, if so then skip initialization (useful when going back) to in history using Turbo
|
||||||
|
if(this._isInitialized()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const default_mode = this.element.dataset.defaultMode;
|
const default_mode = this.element.dataset.defaultMode;
|
||||||
|
|
||||||
this._storage_key = 'tree_' + this.element.id;
|
this._storage_key = 'tree_' + this.element.id;
|
||||||
|
|
|
@ -97,6 +97,21 @@ export default class extends Controller {
|
||||||
$(tree).treeview('search', [data]);
|
$(tree).treeview('search', [data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the tree is already initialized (meaning bootstrap treeview was called on the object)
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_isInitialized() {
|
||||||
|
const $tree = $(this.treeTarget).treeview(true);
|
||||||
|
|
||||||
|
//If the tree is not initialized yet, we just get an empty jquery object with the treeview functions missing
|
||||||
|
if(typeof $tree.findNodes === 'undefined' ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
_getData() {
|
_getData() {
|
||||||
//Use lambda function to preserve this context
|
//Use lambda function to preserve this context
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<body data-base-url="{{ url('homepage', {'_locale': app.request.locale}) }}" data-locale="{{ app.request.locale|default("en")|slice(0,2) }}">
|
<body data-base-url="{{ url('homepage', {'_locale': app.request.locale}) }}" data-locale="{{ app.request.locale|default("en")|slice(0,2) }}">
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<header>
|
<header>
|
||||||
<turbo-frame id="navbar-frame" target="content" data-turbo-action="advance">
|
<turbo-frame id="navbar-frame" target="content" data-turbo-action="advance" data-turbo-permanent>
|
||||||
{% include "_navbar.html.twig" %}
|
{% include "_navbar.html.twig" %}
|
||||||
</turbo-frame>
|
</turbo-frame>
|
||||||
</header>
|
</header>
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
<div class="collapse d-md-block bg-light" id="sidebar-container">
|
<div class="collapse d-md-block bg-light" id="sidebar-container">
|
||||||
<nav class="fixed-sidebar col-md-3 col-lg-2 " id="fixed-sidebar">
|
<nav class="fixed-sidebar col-md-3 col-lg-2 " id="fixed-sidebar">
|
||||||
<turbo-frame id="sidebar" target="content" data-turbo-action="advance">
|
<turbo-frame id="sidebar" target="content" data-turbo-action="advance" data-turbo-permanent>
|
||||||
{% include "_sidebar.html.twig" %}
|
{% include "_sidebar.html.twig" %}
|
||||||
</turbo-frame>
|
</turbo-frame>
|
||||||
<noscript><b>{% trans %}vendor.base.javascript_hint{% endtrans %}</b></noscript>
|
<noscript><b>{% trans %}vendor.base.javascript_hint{% endtrans %}</b></noscript>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue