This commit is contained in:
bronku 2025-02-06 14:22:09 +01:00
parent 9208e62f1a
commit 9e2861ecba
14 changed files with 1 additions and 311 deletions

View file

@ -1,4 +0,0 @@
<div id="alert">
<h3>{{.}}</h3>
<button type="button" onClick="document.getElementById('alert').remove()">close</button>
</div>

View file

@ -1,43 +0,0 @@
<h3>Add cakes to order</h3>
<button hx-get="edit_cakes" hx-swap="innerHTML" hx-target="closest div">edit</button>
<div id="cakes">
{{range $key, $value := .}}
<button onclick="addCake('{{$value.ID}}', '{{$value.Name}} ({{$value.Price}})')" type="button">{{$value.Name}}
{{$value.Price}}</button>
{{end}}
</div>
<script>
function addCake(id, name) {
const existing = document.getElementById("cake[" + id + "]")
if (existing != null) {
existing.value++
return
}
const label = document.createElement('label')
label.innerText = name
label.setAttribute("for", "cake[" + id + "]")
const input = document.createElement('input')
input.setAttribute("type", "number")
input.setAttribute("id", "cake[" + id + "]")
input.setAttribute("name", "cake[" + id + "]")
input.setAttribute("value", 1)
const selected = document.createElement('div')
selected.appendChild(label)
selected.appendChild(input)
const deleteButton = document.createElement('button')
deleteButton.setAttribute("type", "button")
deleteButton.innerText = "delete"
deleteButton.addEventListener("click", function () {
selected.remove()
})
selected.appendChild(deleteButton)
const parent = document.getElementById("basket")
parent.appendChild(selected)
}
</script>

View file

@ -1,14 +0,0 @@
<h3>Edit cakes</h3>
<form hx-post="new_cake" hx-swap="outerHTML">
<div>
<label for="name">Name</label>
<input type="text" id="name" name="name" required value="{{.Name}}">
</div>
<div>
<label for="price">Price</label>
<input type="number" id="price" name="price" step="0.01" min="0" required value="{{.Price}}">
</div>
<input value="{{.ID}}" name="id" hidden></input>
<button type="submit">Submit</button>
<button hx-get="edit_cakes" hx-swap="innerHTML" hx-target="closest div">back</button>
</form>

View file

@ -1,4 +0,0 @@
<div>
<h3>{{.Status}}</h3>
<button hx-get="new_order_form.html" hx-swap="outerHTML" hx-target="closest div">Close</button>
</div>

View file

@ -1,9 +0,0 @@
<h3>Edit cakes</h3>
<button hx-get="available_cakes" hx-swap="innerHTML" hx-target="closest div">back</button>
<button hx-get="cake_editor" hx-swap="innerHTML" hx-target="closest #cake_selector">New</button>
<div id="cakes">
{{range $key, $value := .}}
<button hx-get="cake_editor/{{$value.ID}}" hx-swap="innerHTML" hx-target="closest #cake_selector">{{$value.Name}}
{{$value.Price}}</button>
{{end}}
</div>

View file

@ -1,7 +0,0 @@
<h3>Added cake</h3>
<ul>
<li>ID: {{.ID}}</li>
<li>Name: {{.Name}}</li>
<li>Price: {{.Price}}</li>
</ul>
<button hx-get="edit_cakes" hx-swap="innerHTML" hx-target="closest div">back</button>