diff --git a/scipost_django/scipost/static/scipost/assets/css/_messages.scss b/scipost_django/scipost/static/scipost/assets/css/_messages.scss index 163fff905cf2989791c7faf58b749e41147dd8bf..3061f3da44f27e6340a0c40e6d12a22d60aaf398 100644 --- a/scipost_django/scipost/static/scipost/assets/css/_messages.scss +++ b/scipost_django/scipost/static/scipost/assets/css/_messages.scss @@ -3,8 +3,7 @@ padding-right: 10px; position: fixed; bottom: 0px; - left: 0px; - width: 100%; + right: 0px; z-index: 9999; } diff --git a/scipost_django/scipost/templates/scipost/_hx_messages.html b/scipost_django/scipost/templates/scipost/_hx_messages.html new file mode 100644 index 0000000000000000000000000000000000000000..c19a73bb7e488e4d3a4ca3effe7cd2809119edd5 --- /dev/null +++ b/scipost_django/scipost/templates/scipost/_hx_messages.html @@ -0,0 +1,10 @@ +{% for message in messages %} + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> + <button type="button" + class="btn-close" + style="top: unset !important" + data-bs-dismiss="alert" + aria-label="Close"></button> + {{ message|safe|escape }} + </div> +{% endfor %} diff --git a/scipost_django/scipost/templates/scipost/bare_base.html b/scipost_django/scipost/templates/scipost/bare_base.html index 1840faaf4bfc8abfbc37d2930df7b9bd2c21affd..ae45a6e61f6cb0cd6f41926cebd45cbb4f1ba28e 100644 --- a/scipost_django/scipost/templates/scipost/bare_base.html +++ b/scipost_django/scipost/templates/scipost/bare_base.html @@ -34,6 +34,7 @@ {% block breadcrumb %}{% endblock breadcrumb %} {% block secondary_navbar %}{% endblock secondary_navbar %} + {% include 'scipost/messages.html' %} diff --git a/scipost_django/scipost/templates/scipost/messages.html b/scipost_django/scipost/templates/scipost/messages.html index c48de0b27d90372952551f88ecd9e8288b6e40ca..47813aaf728064c46747a8992b6c379a6f0cd7b0 100644 --- a/scipost_django/scipost/templates/scipost/messages.html +++ b/scipost_django/scipost/templates/scipost/messages.html @@ -1,10 +1,6 @@ -<div class="alert-fixed-container"> - {% for message in messages %} - <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> - <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - {{ message|safe|escape }} - </div> - {% endfor %} -</div> +<div id="global-message-container" + class="alert-fixed-container" + hx-get="{% url 'scipost:_hx_messages' %}" + hx-trigger="load, htmx:trigger from:body delay:1000" + hx-swap="beforeend" + hx-sync="body:drop"></div> diff --git a/scipost_django/scipost/urls.py b/scipost_django/scipost/urls.py index d82f43b8f9f6a6c9f3d54f78b55cba6fbd7b20a1..dabfb75dbd0459ac99b6b054773c2be2f303e0f6 100644 --- a/scipost_django/scipost/urls.py +++ b/scipost_django/scipost/urls.py @@ -156,6 +156,7 @@ urlpatterns = [ TemplateView.as_view(template_name="scipost/acknowledgement.html"), name="acknowledgement", ), + path("messages", views._hx_messages, name="_hx_messages"), # ####### # Info diff --git a/scipost_django/scipost/views.py b/scipost_django/scipost/views.py index 26ac38be5652e7e4e9be70434ac21efbc41978b2..bf845417437ea581abc049e0710d8efbda7213ca 100644 --- a/scipost_django/scipost/views.py +++ b/scipost_django/scipost/views.py @@ -175,6 +175,10 @@ def trigger_error(request): division_by_zero = 1 / 0 +def _hx_messages(request): + return render(request, "scipost/_hx_messages.html") + + ############# # Main view #############