]> git.agnieray.net Git - galette.git/blobdiff - galette/templates/default/elements/js/messages.js.twig
Merge branch 'hotfix/1.0.3'
[galette.git] / galette / templates / default / elements / js / messages.js.twig
index ffd0cc36d4ae7dfe7f1a83386fb5dbec5a4d42de..e1c9ca8b4665e5af071d89116bb0b8931b492d3e 100644 (file)
@@ -14,19 +14,24 @@ $('.message.with-transition')
 ;
 
 {# Let's see if there are success messages to show #}
-{% set successes = flash.getMessage('success_detected') %}
+{% set success = flash.getMessage('success_detected') ?? [] %}
+{% set success = success|merge(flash.getMessage('success') ?? []) %}
 {% if success_detected is defined and success_detected is iterable %}
-    {% for s in success_detected %}
-        {% set successes = successes|merge([s]) %}
+    {% for entry in success_detected %}
+        {% set success = success|merge([entry]) %}
     {% endfor %}
 {% endif %}
-{% if successes is iterable and successes|length > 0 %}
-    {% for success in successes %}
+{% if success is iterable and success|length > 0 %}
+    {% for entry in success %}
         $('body')
           .toast({
             displayTime: 'auto',
-            position: 'bottom right',
-            message: '{{ success|e('js') }}',
+            minDisplayTime: 5000,
+            wordsPerMinute: 80,
+            showProgress: 'bottom',
+            closeIcon: true,
+            position: 'top attached',
+            message: '{{ entry|e('js') }}',
             showIcon: 'check circle outline',
             class: 'success'
           })
@@ -34,6 +39,94 @@ $('.message.with-transition')
     {% endfor %}
 {% endif %}
 
+{# Let's see if there are info messages to show #}
+{% set info = flash.getMessage('info_detected') ?? [] %}
+{% set info = info|merge(flash.getMessage('info') ?? []) %}
+{% if info_detected is defined and info_detected is iterable %}
+    {% for entry in info_detected %}
+        {% set info = info|merge([entry]) %}
+    {% endfor %}
+{% endif %}
+{% if info is iterable and info|length > 0 %}
+    {% for entry in info %}
+        {% set info_title = '' %}
+        {% set info_message = entry %}
+        {% if entry is iterable %}
+            {% set info_title = entry.title %}
+            {% set info_message = entry.message %}
+        {% endif %}
+        $('body')
+          .toast({
+            displayTime: 'auto',
+            minDisplayTime: 5000,
+            wordsPerMinute: 80,
+            showProgress: 'bottom',
+            closeIcon: true,
+            position: 'top attached',
+            title: '{{ info_title|e('js') }}',
+            message: '{{ info_message|e('js') }}',
+            showIcon: 'info',
+            class: 'info'
+          })
+        ;
+    {% endfor %}
+{% endif %}
+
+{# Let's see if there are loginfault messages to show #}
+{% set loginfaults = flash.getMessage('loginfault') %}
+{% if loginfault_detected is defined and loginfault_detected is iterable %}
+    {% for l in loginfault_detected %}
+        {% set loginfaults = loginfaults|merge([l]) %}
+    {% endfor %}
+{% endif %}
+
+{# Let's see if there are error messages to show #}
+{% set errors = flash.getMessage('error_detected') ?? [] %}
+{% set errors = errors|merge(flash.getMessage('error') ?? []) %}
+{% set errors = errors|merge(loginfaults ?? []) %}
+{% if error_detected is defined and error_detected is iterable %}
+    {% for e in error_detected %}
+        {% set errors = errors|merge([e]) %}
+    {% endfor %}
+{% endif %}
+{% if errors is iterable and errors|length > 0 %}
+    {% for error in errors %}
+        $('body')
+          .toast({
+            displayTime: 0,
+            closeIcon: true,
+            position: 'top attached',
+            message: '{{ error|e('js') }}',
+            showIcon: 'exclamation circle',
+            class: 'error'
+          })
+        ;
+    {% endfor %}
+{% endif %}
+
+{# Let's see if there are warning messages to show #}
+{% set warnings = flash.getMessage('warning_detected') ?? [] %}
+{% set warnings = warnings|merge(flash.getMessage('warning') ?? []) %}
+{% if warning_detected is defined and warning_detected is iterable %}
+    {% for w in warning_detected %}
+        {% set warnings = warnings|merge([w]) %}
+    {% endfor %}
+{% endif %}
+{% if warnings is iterable and warnings|length > 0 %}
+    {% for warning in warnings %}
+        $('body')
+          .toast({
+            displayTime: 0,
+            closeIcon: true,
+            position: 'top attached',
+            message: '{{ warning|e('js') }}',
+            showIcon: 'exclamation triangle',
+            class: 'warning'
+          })
+        ;
+    {% endfor %}
+{% endif %}
+
 {# Renew telemetry #}
 {% if renew_telemetry is defined and renew_telemetry %}
     $('body')