templates: fix error report with multiple messages

Fix the definition of javascript code to generate a correct
message window for multiple error messages.
The error is cause by a redefinition of 'let bgclass' in multiple
lines when the html template receives multiple error messages.
Each iteration to generate the code for the error messages tries
to redefine the variable bgclass and it causes the js to fail.
master
Alejandro Sirgo Rica 2024-06-11 10:24:48 +02:00
parent c2fd182fb6
commit 651589d690
1 changed files with 4 additions and 2 deletions

View File

@ -115,8 +115,9 @@
<script>
// error messages
$(document).ready(function() {
{% for category, message in get_flashed_messages(with_categories=True) %}
let bgclass = 'bg-success';
var bgclass = 'bg-success';
{% if category == 'info' %}
bgclass = 'bg-info';
{% elif category == 'error' %}
@ -129,9 +130,10 @@
position: 'bottomRight',
autohide: true,
delay: 30000,
title: '{{ message }}',
title: {{ message|tojson|safe }},
})
{% endfor %}
});
</script>
{% block extrabody %}{% endblock %}