From acf756765bf05b64e44b8522e8502e271517eba0 Mon Sep 17 00:00:00 2001 From: MaxJa4 <74194322+MaxJa4@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:18:12 +0100 Subject: [PATCH] Use bootstrap-modal for single-calc. --- main.go | 1 + static/dialogs.js | 39 -------- templates/components/bottom_controls.html | 4 +- templates/index.html | 3 +- templates/modals/add_player.html | 8 -- templates/modals/single_calc.html | 115 ++++++++++++++++++++++ 6 files changed, 119 insertions(+), 51 deletions(-) create mode 100644 templates/modals/single_calc.html diff --git a/main.go b/main.go index c6b9e5b..3b70b32 100644 --- a/main.go +++ b/main.go @@ -47,6 +47,7 @@ func init() { "./templates/modals/add_player.html", "./templates/modals/delete_player.html", "./templates/modals/edit_player.html", + "./templates/modals/single_calc.html", //"./templates/modals/settings.html", "./templates/modals/full_calc.html", "./templates/components/header.html", diff --git a/static/dialogs.js b/static/dialogs.js index 057cb94..4863500 100644 --- a/static/dialogs.js +++ b/static/dialogs.js @@ -9,45 +9,6 @@ const swalClasses = { htmlContainer: 'fs-5 text-center text-secondary-emphasis', }; -function showSingleCalcDialog(btn) { - Swal.fire({ - title: 'Einzel-Abfrage', - input: 'text', - inputLabel: 'Welcher Spieler soll abgefragt werden?\nDie Abfrage kann ein paar Sekunden dauern.', - inputPlaceholder: 'Spieler-Name eingeben...', - confirmButtonText: 'Berechnen', - showCancelButton: true, - cancelButtonText: 'Abbrechen', - customClass: swalClasses, - buttonsStyling: false - }).then((result) => { - if (result.isConfirmed) { - let promise = htmx.ajax('POST', '/score/' + result.value, {target: '#' + btn.id, swap: 'none'}); - } - }); -} - -function showSingleCalcResultDialog(xhr, reqPath) { - let icon; - switch (xhr.status) { - case 200: - icon = 'success'; - break; - case 404: - icon = 'warning'; - break; - default: - icon = 'error'; - } - - Swal.fire({ - title: 'Abfrage für "' + reqPath.replace("/score/", '') + '"', - text: "Score: " + xhr.response, - icon: icon, - customClass: swalClasses - }); -} - function showAdminActionExecutedDialog(xhr, method) { Swal.fire({ title: 'Action executed', diff --git a/templates/components/bottom_controls.html b/templates/components/bottom_controls.html index bc4bd0b..6e64b77 100644 --- a/templates/components/bottom_controls.html +++ b/templates/components/bottom_controls.html @@ -69,7 +69,7 @@
- @@ -85,8 +85,6 @@ if (reqPath.startsWith("/admin/")) { showAdminActionExecutedDialog(xhr, method); - } else if (reqPath.startsWith("/score/") && method === "post") { - showSingleCalcResultDialog(xhr, reqPath); } }); diff --git a/templates/index.html b/templates/index.html index c416c72..4e4fd5b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -51,7 +51,8 @@ {{/* template "settings" . */}} -{{template "full_calc" .}} +{{ template "full_calc" . }} +{{ template "single_calc" . }} + +{{ end }} \ No newline at end of file