diff --git a/views/js/main.js b/views/js/main.js index b0cb09c..6c83ca4 100644 --- a/views/js/main.js +++ b/views/js/main.js @@ -15,6 +15,13 @@ function tabs() { elm.classList.remove("selected"); } child.classList.add("selected"); + + for (const childElm of child.parentElement.children) { + if (childElm.classList.contains("selected")) { + childElm.classList.remove("selected") + } + } + document.querySelector(`.tabs .content[data-tab="${ child.getAttribute("data-tab") }"]`)?.classList.add("selected"); @@ -41,6 +48,55 @@ function tabs() { } } + for (const elm of document.querySelectorAll(".tabs-header")) { + let count = 0; + let selected = 0; + for (const child of elm.children[0].children) { + if (child.tagName == "BUTTON") { + count++; + if (child.classList.contains("selected")) { + selected++; + } + if (!child.getAttribute("data-armed")) { + child.addEventListener("click", () => { + if (!child.classList.contains("selected")) { + for (const elm of child.parentElement.children) { + elm.classList.remove("selected"); + } + child.classList.add("selected"); + + for (const childElm of child.parentElement.parentElement.children) { + if (childElm.classList.contains("selected")) { + childElm.classList.remove("selected") + } + } + + document.querySelector(`.tabs-header .content[data-tab="${ + child.getAttribute("data-tab") + }"]`)?.classList.add("selected"); + } + }); + child.setAttribute("data-armed", "true") + } + } + } + + if (selected > 1 || selected == 0) { + for (const child of elm.children) { + child.classList.remove("selected"); + } + for (const child of elm.children[0].children) { + if (child.tagName == "BUTTON") { + child.classList.add("selected"); + document.querySelector(`.tabs .content[data-tab="${ + child.getAttribute("data-tab") + }"]`)?.classList.add("selected"); + break; + } + } + + } + } } function load() { for (const elm of document.querySelectorAll("form > button")) { diff --git a/views/models/edit.html b/views/models/edit.html index f31134e..f55b26e 100644 --- a/views/models/edit.html +++ b/views/models/edit.html @@ -126,30 +126,40 @@ {{ if eq (len .Classes) 0 }} TODO CREATE TABLE {{else}} -
+
{{/* Handle the case where there are to many buttons */}} - {{ range .Classes }} - {{/* TODO Auto Load 1st */}} - - {{ end }} - {{ range .Classes }} -
-
+
+ {{ range .Classes }} + {{/* TODO Auto Load 1st */}} + + {{ end }} +
+ {{ range $i, $a := .Classes }} + {{ if eq $i 0}} +
+
+ {{ else }} +
+
+ {{ end }} {{ end }}
{{end}} diff --git a/views/styles/main.css b/views/styles/main.css index ce9c3c9..498b35e 100644 --- a/views/styles/main.css +++ b/views/styles/main.css @@ -391,6 +391,11 @@ table tr td .button { gap: 0 5px; } +.tabs-header .header { + display: flex; + overflow-x: scroll; +} + .tabs .content { display: none; padding: 5px;