fix: wrong notification update with fragments

This commit is contained in:
imperosol
2026-05-19 14:43:43 +02:00
parent 68aa4515f9
commit 75f3094dd5
4 changed files with 12 additions and 12 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
<div id="quick-notifications"
x-data='{ messages: $notifications.getAll() }'
x-init='$notifications.addMany([
{%- for message in messages -%}
{%- if not message.extra_tags -%}
@@ -8,7 +7,7 @@
{%- endfor -%}
])'
>
<template x-for="(message, index) in messages">
<template x-for="(message, index) in $notifications.getAll()">
<div class="alert" :class="`alert-${message.tag}`" x-transition>
<span class="alert-main" x-text="message.text"></span>
<span class="clickable" @click="messages = messages.filter((item, i) => i !== index)">
+7 -8
View File
@@ -226,7 +226,7 @@
<button type="button" onclick="checkbox_{{form_id}}(false);">{% trans %}Unselect All{% endtrans %}</button>
{% endmacro %}
{% macro update_notifications(messages, clear) %}
{% macro update_notifications(messages, clear = True) %}
{# Update notification area from new messages sent by django backend
This is useful when performing fragment swaps to keep messages up to date
Without this, the fragment would need to take control of the notification area and
@@ -236,15 +236,14 @@
messages: messages from django.contrib
clear : optional boolean that controls if notifications should be cleared first. True is the default
#}
{% set clear = clear|default(true) %}
{% if messages %}
<div x-init="() => {
{% if clear %}
$notifications.clear()
{% endif %}
{% for message in messages %}
$notifications.{{ message.tags }}('{{ message }}')
{% endfor %}
{%- if clear -%}
$notifications.clear();
{%- endif -%}
{%- for message in messages -%}
$notifications.{{ message.tags }}('{{ message }}');
{%- endfor -%}
}"></div>
{% endif %}
{% endmacro %}