diff --git a/assets/controllers/common/toast_controller.js b/assets/controllers/common/toast_controller.js
new file mode 100644
index 00000000..8dc7914c
--- /dev/null
+++ b/assets/controllers/common/toast_controller.js
@@ -0,0 +1,17 @@
+import { Controller } from '@hotwired/stimulus';
+import { Toast } from 'bootstrap';
+
+export default class extends Controller {
+ connect() {
+ //Move all toasts from the page into our toast container and show them
+
+ const toastContainer = document.getElementById('toast-container');
+ if (this.element.parentNode !== toastContainer) {
+ toastContainer.appendChild(this.element);
+ return;
+ }
+
+ const toast = new Toast(this.element);
+ toast.show();
+ }
+}
\ No newline at end of file
diff --git a/assets/js/register_events.js b/assets/js/register_events.js
index 9039f682..0250a447 100644
--- a/assets/js/register_events.js
+++ b/assets/js/register_events.js
@@ -12,7 +12,6 @@ import "bootstrap-fileinput";
const RegisterEventHelper = class {
constructor() {
- this.registerToasts();
this.registerTooltips();
this.registerJumpToTopBtn();
@@ -28,10 +27,6 @@ const RegisterEventHelper = class {
document.addEventListener('turbo:load', fn);
}
- registerToasts() {
- this.registerLoadHandler(() => $(".toast").toast('show'));
- }
-
registerTooltips() {
this.registerLoadHandler(() => {
$(".tooltip").remove();
diff --git a/templates/_flash.html.twig b/templates/_flash.html.twig
deleted file mode 100644
index 633477b4..00000000
--- a/templates/_flash.html.twig
+++ /dev/null
@@ -1,31 +0,0 @@
-{# The container to show the flash messages #}
-
-
- {% for label, messages in app.flashes() %}
- {% for message in messages %}
- {% set flash_title = label|replace({'success': 'flash.success', 'error': 'flash.error'
- , 'warning': 'flash.warning', 'notice': 'flash.notice', 'info': 'flash.info'}) %}
- {% set flash_symbol = label|replace({'success': 'fa-check-circle', 'error': 'fa-exclamation-triangle'
- , 'warning': 'fa-exclamation-circle', 'notice': 'fa-flag', 'info': 'fa-flag'}) %}
-
- {% set flash_bg = label|replace({'success': 'bg-success text-white',
- 'error': 'bg-danger text-white', 'warning': 'bg-warning text-white',
- 'notice': 'bg-info text-white', 'info': 'bg-light'})%}
-
-
-
-
- {{ message | trans }}
-
-
- {% endfor %}
- {% endfor %}
-
\ No newline at end of file
diff --git a/templates/_toast.html.twig b/templates/_toast.html.twig
new file mode 100644
index 00000000..786019d4
--- /dev/null
+++ b/templates/_toast.html.twig
@@ -0,0 +1,23 @@
+{% set flash_title = label|replace({'success': 'flash.success', 'error': 'flash.error'
+ , 'warning': 'flash.warning', 'notice': 'flash.notice', 'info': 'flash.info'}) %}
+ {% set flash_symbol = label|replace({'success': 'fa-check-circle', 'error': 'fa-exclamation-triangle'
+ , 'warning': 'fa-exclamation-circle', 'notice': 'fa-flag', 'info': 'fa-flag'}) %}
+
+ {% set flash_bg = label|replace({'success': 'bg-success text-white',
+ 'error': 'bg-danger text-white', 'warning': 'bg-warning text-white',
+ 'notice': 'bg-info text-white', 'info': 'bg-light'})%}
+
+
+
+
+ {{ message | trans }}
+
+
\ No newline at end of file
diff --git a/templates/_toast_container.html.twig b/templates/_toast_container.html.twig
new file mode 100644
index 00000000..0aaa543d
--- /dev/null
+++ b/templates/_toast_container.html.twig
@@ -0,0 +1,4 @@
+{# The container to show the flash messages #}
+
+
+
\ No newline at end of file
diff --git a/templates/base.html.twig b/templates/base.html.twig
index 1d33c02d..469ff421 100644
--- a/templates/base.html.twig
+++ b/templates/base.html.twig
@@ -55,20 +55,19 @@
{% block body %}
-
-
{% include "_navbar.html.twig" %}
- {% include "_flash.html.twig" %}
-
+
+ {% include "_toast_container.html.twig" %}
+