mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Use stimulus for global reloading
This commit is contained in:
parent
390deca544
commit
ea6357c259
4 changed files with 22 additions and 14 deletions
8
assets/controllers/turbo/global_reload_controller.js
Normal file
8
assets/controllers/turbo/global_reload_controller.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
//If we encounter an element with global reload controller, then reload the whole page
|
||||||
|
window.location.href = window.location.href;
|
||||||
|
}
|
||||||
|
}
|
|
@ -354,7 +354,7 @@ class UserSettingsController extends AbstractController
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'settings_form' => $form,
|
'settings_form' => $form,
|
||||||
'pw_form' => $pw_form,
|
'pw_form' => $pw_form,
|
||||||
'page_need_reload' => $page_need_reload,
|
'global_reload_needed' => $page_need_reload,
|
||||||
|
|
||||||
'google_form' => $google_form,
|
'google_form' => $google_form,
|
||||||
'backup_form' => $backup_form,
|
'backup_form' => $backup_form,
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
{% trans %}user.settings.label{% endtrans %}{% endblock %}
|
{% trans %}user.settings.label{% endtrans %}{% endblock %}
|
||||||
|
|
||||||
{% block card_content %}
|
{% block card_content %}
|
||||||
{% if page_need_reload %}
|
|
||||||
<script>window.location.href = window.location.href;</script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{{ form_start(settings_form) }}
|
{{ form_start(settings_form) }}
|
||||||
|
|
||||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
<link rel="icon" type="image/png" href="{{ asset('icon/favicon-16x16.png') }}" sizes="16x16">
|
<link rel="icon" type="image/png" href="{{ asset('icon/favicon-16x16.png') }}" sizes="16x16">
|
||||||
<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>
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{# Include the main bootstrap theme based on user/global setting #}
|
{# Include the main bootstrap theme based on user/global setting #}
|
||||||
|
@ -89,17 +88,22 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<div class="toasts-global d-none">
|
<div class="toasts-global d-none">
|
||||||
{% for label, messages in app.flashes() %}
|
{% for label, messages in app.flashes() %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
{{ include('_toast.html.twig', {
|
{{ include('_toast.html.twig', {
|
||||||
'label': label,
|
'label': label,
|
||||||
'message': message
|
'message': message
|
||||||
}) }}
|
}) }}
|
||||||
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
</turbo-frame>
|
|
||||||
|
|
||||||
|
{# 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>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue