From 63b76e157909b12299120b2a10ac1ab05f5f4d03 Mon Sep 17 00:00:00 2001 From: null Date: Tue, 5 Mar 2024 08:05:31 +0100 Subject: [PATCH] fix reload after submit --- routes/conditions.py | 2 +- static/favicon.ico | 0 static/js/main.js | 6 +++++- templates/conditions/create.html | 4 ++-- templates/conditions/update.html | 4 ++-- templates/index.html | 1 + 6 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 static/favicon.ico diff --git a/routes/conditions.py b/routes/conditions.py index ed6f48c..2cc3f04 100644 --- a/routes/conditions.py +++ b/routes/conditions.py @@ -25,7 +25,7 @@ def create_conditions_routes(app): data = request.form.to_dict() result = r.table(table_name).insert(data).run(get_connection()) - return redirect(request.referrer or url_for('index')) + return render_template(route + '/create.html') # Read operation @app.route('/' + route, methods=['GET']) diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/static/js/main.js b/static/js/main.js index 87f7fad..6aa5c32 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -3,8 +3,12 @@ document.addEventListener('DOMContentLoaded', documentReady, false); function documentReady() { const iframe = document.querySelector("iframe"); const dialog = document.querySelector("dialog"); - iframe.onload = () => { + iframe.onload = (event) => { dialog.style.height = iframe.contentWindow.document.body.getBoundingClientRect().height + "px"; + if (event.target.contentWindow.location.search.includes("submitted")) { + dialog.close(); + window.location.href=window.location.href + } } } diff --git a/templates/conditions/create.html b/templates/conditions/create.html index faef62b..7a7a6c6 100644 --- a/templates/conditions/create.html +++ b/templates/conditions/create.html @@ -14,7 +14,7 @@

Create a condition

-
+
@@ -31,7 +31,7 @@
- +
diff --git a/templates/conditions/update.html b/templates/conditions/update.html index 40dc92f..b7c31c9 100644 --- a/templates/conditions/update.html +++ b/templates/conditions/update.html @@ -14,7 +14,7 @@

Update a condition

-
+
{{ data.id }}
@@ -36,7 +36,7 @@
-
+
diff --git a/templates/index.html b/templates/index.html index fa5875a..9f56933 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,6 +5,7 @@ Trading Zone Website +