changeset 8d5aa78e85b1 in bugs.tryton.org:default
details: https://hg.tryton.org/bugs.tryton.org?cmd=changeset;node=8d5aa78e85b1
description:
Remove @ok_message params when closing alert
issue9745
review294801002
diffstat:
html/layout/page.html | 3 ++-
static/script.js | 7 +++++++
2 files changed, 9 insertions(+), 1 deletions(-)
diffs (31 lines):
diff -r 6ab002a97dde -r 8d5aa78e85b1 html/layout/page.html
--- a/html/layout/page.html Thu Oct 22 12:13:09 2020 +0200
+++ b/html/layout/page.html Thu Oct 22 12:14:10 2020 +0200
@@ -45,7 +45,7 @@
</div>
{% endif %}
{% if options.ok_message %}
- <div class="alert alert-success alert-dismissible fade show"
role="alert">
+ <div class="alert alert-success alert-dismissible fade show"
role="alert" data-params="@ok_message">
<ul class="mb-0">
{% for message in options.ok_message %}
<li>{{ message|safe }}</li>
@@ -70,6 +70,7 @@
<script src='@@file/jquery-1.9.0.min.js'></script>
<script src='@@file/bootstrap.min.js'></script>
+ <script src='@@file/script.js'></script>
{% block extrajs %} {% endblock %}
</body>
</html>
diff -r 6ab002a97dde -r 8d5aa78e85b1 static/script.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/static/script.js Thu Oct 22 12:14:10 2020 +0200
@@ -0,0 +1,7 @@
+$('.alert').on('close.bs.alert', function() {
+ if ($(this).data('params')) {
+ var url = new URL(window.location.href);
+ url.searchParams.delete($(this).data('params'));
+ window.history.replaceState({}, document.title, url.toString());
+ }
+});