mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Change the document title according to the title of the main frame.
This commit is contained in:
parent
ea6357c259
commit
fa5f5bce28
3 changed files with 32 additions and 17 deletions
12
assets/controllers/turbo/title_controller.js
Normal file
12
assets/controllers/turbo/title_controller.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
//If we encounter an element with this, then change the title of our document according to data-title
|
||||||
|
this.changeTitle(this.element.dataset.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTitle(title) {
|
||||||
|
document.title = title;
|
||||||
|
}
|
||||||
|
}
|
18
templates/_turbo_control.html.twig
Normal file
18
templates/_turbo_control.html.twig
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{# Insert flashes #}
|
||||||
|
<div class="toasts-global d-none">
|
||||||
|
{% for label, messages in app.flashes() %}
|
||||||
|
{% for message in messages %}
|
||||||
|
{{ include('_toast.html.twig', {
|
||||||
|
'label': label,
|
||||||
|
'message': message
|
||||||
|
}) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Allow pages to request a fully reload of everything #}
|
||||||
|
{% if global_reload_needed is defined and global_reload_needed %}
|
||||||
|
<div {{ stimulus_controller('turbo/global_reload') }}></div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="d-none" data-title="{% apply title %}{{ page_title }}{% endapply %}" {{ stimulus_controller('turbo/title') }}></div>
|
|
@ -25,6 +25,7 @@
|
||||||
<link rel="mask-icon" href="{{ asset('icon/safari-pinned-tab.svg') }}" color="#5bbad5">
|
<link rel="mask-icon" href="{{ asset('icon/safari-pinned-tab.svg') }}" color="#5bbad5">
|
||||||
|
|
||||||
<title>{% apply trim %}{% block title %}{{ partdb_title}}{% endblock %}{% endapply %}</title>
|
<title>{% apply trim %}{% block title %}{{ partdb_title}}{% endblock %}{% endapply %}</title>
|
||||||
|
{% set page_title = block("title") %}
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{# Include the main bootstrap theme based on user/global setting #}
|
{# Include the main bootstrap theme based on user/global setting #}
|
||||||
|
|
||||||
|
@ -58,13 +59,11 @@
|
||||||
<turbo-frame id="navbar-frame" target="content" data-turbo-action="advance">
|
<turbo-frame id="navbar-frame" target="content" data-turbo-action="advance">
|
||||||
{% include "_navbar.html.twig" %}
|
{% include "_navbar.html.twig" %}
|
||||||
</turbo-frame>
|
</turbo-frame>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
{% include "_toast_container.html.twig" %}
|
{% include "_toast_container.html.twig" %}
|
||||||
|
|
||||||
<div class="collapse d-md-block bg-light" id="sidebar-container">
|
<div class="collapse d-md-block bg-light" id="sidebar-container">
|
||||||
|
@ -87,21 +86,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<div class="toasts-global d-none">
|
{% include "_turbo_control.html.twig" %}
|
||||||
{% for label, messages in app.flashes() %}
|
|
||||||
{% for message in messages %}
|
|
||||||
{{ include('_toast.html.twig', {
|
|
||||||
'label': label,
|
|
||||||
'message': message
|
|
||||||
}) }}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{# Allow pages to request a fully reload of everything #}
|
|
||||||
{% if global_reload_needed is defined and global_reload_needed %}
|
|
||||||
<div {{ stimulus_controller('turbo/global_reload') }}></div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</turbo-frame>
|
</turbo-frame>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue