labels
This commit is contained in:
parent
c32ecbff8f
commit
3136739f4e
53 changed files with 129 additions and 1892 deletions
|
|
@ -27,7 +27,7 @@ func (h *Server) postCake(r *http.Request) (any, int, error) {
|
|||
return nil, http.StatusBadRequest, err
|
||||
}
|
||||
n.Category = r.FormValue("category")
|
||||
n.Availability = r.FormValue("availibility")
|
||||
n.Availability = r.FormValue("availability")
|
||||
n.ID, err = h.s.SaveCake(n)
|
||||
fmt.Println(err)
|
||||
return n, http.StatusAccepted, err
|
||||
|
|
|
|||
|
|
@ -6,20 +6,26 @@ Cake {{.ID}}
|
|||
<form method="post">
|
||||
<div>
|
||||
<h2>Info</h2>
|
||||
<input hidden="true" name="id" value="{{.ID}}">
|
||||
<label>
|
||||
<input hidden="hidden" name="id" value="{{.ID}}">
|
||||
</label>
|
||||
<label>name</label>
|
||||
<input type="text" name="name" value="{{.Name}}">
|
||||
<label>
|
||||
<input type="text" name="name" value="{{.Name}}">
|
||||
</label>
|
||||
<label>price</label>
|
||||
<input type="number" name="price" min="0" value="{{.Price}}">
|
||||
<label>
|
||||
<input type="number" name="price" min="0" value="{{.Price}}">
|
||||
</label>
|
||||
<label>category</label>
|
||||
<select name="category" id="category" >
|
||||
<label for="category"></label><select name="category" id="category" >
|
||||
<option {{ if eq .Category "common" }}selected{{ end }} value="common">common</option>
|
||||
<option {{ if eq .Category "christmas" }}selected{{ end }} value="christmas">christmas</option>
|
||||
<option {{ if eq .Category "easter" }}selected{{ end }} value="easter">easter</option>
|
||||
<option {{ if eq .Category "donuts" }}selected{{ end }} value="donuts">donuts</option>
|
||||
</select>
|
||||
<label>availability</label>
|
||||
<select name="availibility" id="availibility" >
|
||||
<label for="availability"></label><select name="availability" id="availability" >
|
||||
<option {{ if eq .Availability "available" }}selected{{ end }} value="available">available</option>
|
||||
<option {{ if eq .Availability "unavailable" }}selected{{ end }} value="unavailable">unavailable</option>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
{{define "layout"}}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>{{template "title" .}}</title>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<script src="/static/htmx2.04.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -2,89 +2,105 @@
|
|||
Order {{.Order.ID}}
|
||||
{{end}}
|
||||
{{define "main"}}
|
||||
<main>
|
||||
<form method="post">
|
||||
{{with .Order}}
|
||||
<div>
|
||||
<h2>Info</h2>
|
||||
<input hidden="true" name="id" value="{{.ID}}">
|
||||
<label>name</label>
|
||||
<input type="text" name="name" value="{{.Name}}">
|
||||
<label>surname</label>
|
||||
<input type="text" name="surname" value="{{.Surname}}">
|
||||
<label>phone</label>
|
||||
<input type="tel" name="phone" value="{{.Phone}}">
|
||||
<label>location</label>
|
||||
<select name="location">
|
||||
<option {{ if eq .Location "Kartuzy" }}selected{{ end }} value="Kartuzy">Kartuzy</option>
|
||||
<option {{ if eq .Location "Somonino" }}selected{{ end }} value="Somonino">Somonino</option>
|
||||
</select>
|
||||
<label>date</label>
|
||||
<input type="date" name="date" value="{{.Date.Format "2006-01-02"}}">
|
||||
<label>status</label>
|
||||
<select name="status" id="status" >
|
||||
<option {{ if eq .Status "accepted" }}selected{{ end }} value="accepted">accepted</option>
|
||||
<option {{ if eq .Status "done" }}selected{{ end }} value="done">done</option>
|
||||
</select>
|
||||
<label>paid</label>
|
||||
<input type="number" name="paid" min="0" value="{{.Paid}}">
|
||||
</div>
|
||||
<div>
|
||||
<h2>Basket</h2>
|
||||
<ul id="basket">
|
||||
</ul>
|
||||
</div>
|
||||
{{end}}
|
||||
{{with .Catalogue}}
|
||||
<div>
|
||||
<h2>Catalogue</h2>
|
||||
<ul>
|
||||
{{range .}}
|
||||
<li>
|
||||
{{.Name}} {{.Price}} <button type=button onClick="addCake({{.ID}},'{{.Name}} {{.Price}}', 1)">add</button>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
{{end}}
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
</main>
|
||||
<script>
|
||||
function addCake(id, name, amount){
|
||||
var cake = document.getElementById("cake["+id+"]")
|
||||
if (cake != null){
|
||||
var value = Number(cake.getAttribute("value"))
|
||||
cake.setAttribute("value", value+1)
|
||||
return;
|
||||
<main>
|
||||
<form method="post">
|
||||
{{with .Order}}
|
||||
<div>
|
||||
<h2>Info</h2>
|
||||
<label>
|
||||
<input hidden="hidden" name="id" value="{{.ID}}">
|
||||
</label>
|
||||
<label>name</label>
|
||||
<label>
|
||||
<input type="text" name="name" value="{{.Name}}">
|
||||
</label>
|
||||
<label>surname</label>
|
||||
<label>
|
||||
<input type="text" name="surname" value="{{.Surname}}">
|
||||
</label>
|
||||
<label>phone</label>
|
||||
<label>
|
||||
<input type="tel" name="phone" value="{{.Phone}}">
|
||||
</label>
|
||||
<label>location</label>
|
||||
<label>
|
||||
<select name="location">
|
||||
<option {{ if eq .Location "Kartuzy" }}selected{{ end }} value="Kartuzy">Kartuzy</option>
|
||||
<option {{ if eq .Location "Somonino" }}selected{{ end }} value="Somonino">Somonino</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>date</label>
|
||||
<label>
|
||||
<input type="date" name="date" value="{{.Date.Format "2006-01-02"}}">
|
||||
</label>
|
||||
<label>status</label>
|
||||
<label for="status"></label><select name="status" id="status">
|
||||
<option {{ if eq .Status "accepted" }}selected{{ end }} value="accepted">accepted</option>
|
||||
<option {{ if eq .Status "done" }}selected{{ end }} value="done">done</option>
|
||||
</select>
|
||||
<label>paid</label>
|
||||
<label>
|
||||
<input type="number" name="paid" min="0" value="{{.Paid}}">
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Basket</h2>
|
||||
<ul id="basket">
|
||||
</ul>
|
||||
</div>
|
||||
{{end}}
|
||||
{{with .Catalogue}}
|
||||
<div>
|
||||
<h2>Catalogue</h2>
|
||||
<ul>
|
||||
{{range .}}
|
||||
<li>
|
||||
{{.Name}} {{.Price}}
|
||||
<button type=button onClick="addCake({{.ID}},'{{.Name}} {{.Price}}', 1)">add</button>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
{{end}}
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
</main>
|
||||
<!--suppress JSUnusedGlobalSymbols, JSCheckFunctionSignatures -->
|
||||
<script>
|
||||
function addCake(id, name, amount) {
|
||||
const cake = document.getElementById("cake[" + id + "]");
|
||||
if (cake != null) {
|
||||
const value = Number(cake.getAttribute("value"));
|
||||
cake.setAttribute("value", value + 1)
|
||||
return;
|
||||
}
|
||||
const label = document.createElement("label");
|
||||
label.innerText = name
|
||||
const input = document.createElement("input");
|
||||
input.setAttribute("id", "cake[" + id + "]")
|
||||
input.setAttribute("type", "number")
|
||||
input.setAttribute("min", "0")
|
||||
input.setAttribute("name", "cake[" + id + "]")
|
||||
input.setAttribute("value", amount)
|
||||
const button = document.createElement("button");
|
||||
button.setAttribute("type", "button")
|
||||
button.setAttribute("onClick", "removeCake(" + id + ")")
|
||||
button.innerText = "delete"
|
||||
const li = document.createElement("li");
|
||||
li.appendChild(label)
|
||||
li.appendChild(input)
|
||||
li.appendChild(button)
|
||||
li.setAttribute("id", "li[" + id + "]")
|
||||
const ul = document.getElementById("basket");
|
||||
ul.appendChild(li)
|
||||
}
|
||||
var label = document.createElement("label")
|
||||
label.innerText = name
|
||||
var input = document.createElement("input")
|
||||
input.setAttribute("id","cake["+id+"]")
|
||||
input.setAttribute("type", "number")
|
||||
input.setAttribute("min", "0")
|
||||
input.setAttribute("name", "cake["+id+"]")
|
||||
input.setAttribute("value", amount)
|
||||
var button = document.createElement("button")
|
||||
button.setAttribute("type", "button")
|
||||
button.setAttribute("onClick", "removeCake("+id+")")
|
||||
button.innerText= "delete"
|
||||
var li = document.createElement("li")
|
||||
li.appendChild(label)
|
||||
li.appendChild(input)
|
||||
li.appendChild(button)
|
||||
li.setAttribute("id", "li["+id+"]")
|
||||
var ul = document.getElementById("basket")
|
||||
ul.appendChild(li)
|
||||
}
|
||||
|
||||
function removeCake(id){
|
||||
document.getElementById("li["+id+"]").remove()
|
||||
}
|
||||
function removeCake(id) {
|
||||
document.getElementById("li[" + id + "]").remove()
|
||||
}
|
||||
|
||||
{{range .Order.Cakes}}
|
||||
{{range .Order.Cakes}}
|
||||
addCake({{.ID}}, '{{.Name}} {{.Price}}', {{.Amount}})
|
||||
{{end}}
|
||||
</script>
|
||||
{{end}}
|
||||
</script>
|
||||
{{end}}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@
|
|||
{{end}}
|
||||
{{define "main"}}
|
||||
<main>
|
||||
<form class="search-container" hx-get="/orders/search" hx-target="#results-table", hx-trigger="keyup delay:500ms, change">
|
||||
<input type="search" name="q" placeholder="Search orders...">
|
||||
<form class="search-container" hx-get="/orders/search" hx-target="#results-table" hx-trigger="keyup delay:500ms, change">
|
||||
<label>
|
||||
<input type="search" name="q" placeholder="Search orders...">
|
||||
</label>
|
||||
|
||||
<label for="from">form</label>
|
||||
<input type="date" value="{{.Today}}" id="from" name="from">
|
||||
<label for="from">to</label>
|
||||
<input type="date" value="{{.Today}}" id="to" name="to">
|
||||
<label for="to"></label><input type="date" value="{{.Today}}" id="to" name="to">
|
||||
|
||||
<div class="htmx-indicator">
|
||||
Searching...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue