diff --git a/static/css/styles.css b/static/css/styles.css index ae4b5c5..87f0892 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -20,6 +20,10 @@ h1 { font-size: 24px; } +h2 { + margin-top: 0; +} + table { width: 100%; border-collapse: collapse; @@ -88,20 +92,12 @@ fieldset { } /* Dialog box */ dialog { - width: 400px; padding: 20px; border: 1px solid #ccc; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); overflow: hidden; -} - -dialog.create { - height: 320px; -} - -dialog.update { - height: 500px; + width: 400px; } /* Labels */ @@ -126,6 +122,10 @@ input, select { width: 100%; } +form { + margin: 0; +} + form fieldset:last-child { margin-top: 20px; text-align: right; diff --git a/static/js/main.js b/static/js/main.js index 291d0f2..87f7fad 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,26 +1,25 @@ document.addEventListener('DOMContentLoaded', documentReady, false); -window.onmessage = (event) => { - if (event.data == "close") { - document.querySelector("dialog[open]").close(); + +function documentReady() { + const iframe = document.querySelector("iframe"); + const dialog = document.querySelector("dialog"); + iframe.onload = () => { + dialog.style.height = iframe.contentWindow.document.body.getBoundingClientRect().height + "px"; } } -function documentReady() { - const iframe = document.querySelector("iframe"); - iframe.onload=(event) => { - const openDialog = document.querySelector("dialog[open]"); - if (openDialog) { - openDialog.close(); - window.location.reload(); - } else { - const dialog = document.querySelector("dialog") - if (iframe.contentWindow.location.href.split("/").pop() === "create") { - dialog.className = 'create'; - } else { - dialog.className = 'update'; - } - dialog.showModal() - - } +window.onmessage = (event) => { + if (event.data == "close") { + const dialog = document.querySelector("dialog[open]"); + const iframe = document.querySelector("iframe"); + dialog.close(); + iframe.src = "about:blank" } +} + +function onOpenDialog(href) { + const iframe = document.querySelector("iframe"); + const dialog = document.querySelector("dialog"); + iframe.contentWindow.location = href; + dialog.showModal(); } \ No newline at end of file diff --git a/templates/conditions/create.html b/templates/conditions/create.html index 82425ef..faef62b 100644 --- a/templates/conditions/create.html +++ b/templates/conditions/create.html @@ -1,5 +1,6 @@ - + + @@ -9,28 +10,30 @@ overflow: hidden; } - - -

Create a condition

-
-
- - + - - + +

Create a condition

+ +
+ + - - -
+ + + + + +
+ +
+ + +
+
+ -
- - -
- - \ No newline at end of file diff --git a/templates/conditions/update.html b/templates/conditions/update.html index 1eb2a03..40dc92f 100644 --- a/templates/conditions/update.html +++ b/templates/conditions/update.html @@ -1,5 +1,6 @@ - + + @@ -9,33 +10,35 @@ overflow: hidden; } - - -

Update a condition

-
-
- -
{{ data.id }}
+ - - + +

Update a condition

+ +
+ +
{{ data.id }}
- - + + + + + + + + +
+
+ + +
+ +
+ +
+ - - -
-
- - -
- -
- -
- \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 019b882..fa5875a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -34,7 +34,7 @@ {% for item in data.conditions %} - + {% set order = ["id", "symbol", "condition", "value"] %} {% for key in order %} @@ -46,7 +46,7 @@ - +