spellcheck, and refreshing cake list
This commit is contained in:
parent
2c90e19eba
commit
ea81abb718
9 changed files with 20 additions and 24 deletions
|
|
@ -1,15 +1,13 @@
|
|||
# iroon
|
||||
## todo:
|
||||
- [x] extract order creation form into it's own element
|
||||
- [ ] organize html structure
|
||||
- [x] option to add additional cakes
|
||||
- [x] saving orders on server
|
||||
- [ ] displaying orders
|
||||
- [x] move id to cake struct
|
||||
- [ ] refresh the list on submission
|
||||
- [ ] peristent storage
|
||||
- [x] refresh the list on submission
|
||||
- [ ] persistent storage
|
||||
- [x] rudimentary css
|
||||
- [ ] organize the cake editor
|
||||
## ux design
|
||||
### adding an order:
|
||||
1. user selects the _add order_ button
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func (c *controller) newCake(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
c.cakes[in.ID] = in
|
||||
_ = c.tmpl["cake"].Execute(w, in)
|
||||
_ = c.tmpl["new_cake"].Execute(w, in)
|
||||
}
|
||||
|
||||
func (c *controller) postNewOrder(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
7
main.go
7
main.go
|
|
@ -3,15 +3,14 @@ package main
|
|||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
//go:embed public
|
||||
var public embed.FS
|
||||
//var public embed.FS
|
||||
|
||||
//go:embed templates
|
||||
var templates embed.FS
|
||||
|
|
@ -23,7 +22,7 @@ func main() {
|
|||
c.LoadRouter(publicfs)
|
||||
c.cakes = make(map[int]Cake)
|
||||
c.cakes[0] = Cake{"Sernik", 120, 0}
|
||||
c.cakes[1] = Cake{"Malinowa chmórka", 120, 1}
|
||||
c.cakes[1] = Cake{"Malinowa chmurka", 120, 1}
|
||||
c.cakes[2] = Cake{"Beza Pavlova", 8, 2}
|
||||
|
||||
err := http.ListenAndServe(":8080", c)
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@
|
|||
<div id="basket">
|
||||
<h3>Baset</h3>
|
||||
</div>
|
||||
<div hx-get="available_cakes" hx-swap="innerHTML" hx-trigger="load"></div>
|
||||
<div id="cake_selector" hx-get="available_cakes" hx-swap="innerHTML" hx-trigger="load"></div>
|
||||
</form>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<div id="cake_preview">
|
||||
<ul>
|
||||
<li>ID: {{.ID}}</li>
|
||||
<li>Name: {{.Name}}</li>
|
||||
<li>Price: {{.Price}}</li>
|
||||
</ul>
|
||||
<button type="button" onClick="document.getElementById('cake_preview').remove()">close</button>
|
||||
</div>
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
<h3>Edit cakes</h3>
|
||||
<form hx-post="new_cake" hx-swap="outerHTML">
|
||||
<div>
|
||||
<label for="name">Name</label>
|
||||
|
|
@ -9,5 +10,5 @@
|
|||
</div>
|
||||
<input value="{{.ID}}" name="id" hidden></input>
|
||||
<button type="submit">Submit</button>
|
||||
<button type="button" onclick="document.getElementById('cake_editor').innerText=''">Cancel</button>
|
||||
<button hx-get="edit_cakes" hx-swap="innerHTML" hx-target="closest div">back</button>
|
||||
</form>
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
<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="#cake_editor">New</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="#cake_editor">{{$value.Name}}
|
||||
<button hx-get="cake_editor/{{$value.ID}}" hx-swap="innerHTML" hx-target="closest #cake_selector">{{$value.Name}}
|
||||
{{$value.Price}}</button>
|
||||
{{end}}
|
||||
</div>
|
||||
<div id="cake_editor"></div>
|
||||
7
templates/new_cake.html
Normal file
7
templates/new_cake.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<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>
|
||||
2
util.go
2
util.go
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func unwrap[T any](output T, err error) T {
|
||||
func _[T any](output T, err error) T {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue