move id to cake struct
This commit is contained in:
parent
cd7c9a9d0c
commit
7515010afd
8 changed files with 20 additions and 29 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<button hx-get="edit_cakes" hx-swap="outerHTML" hx-target="closest div">edit</button>
|
||||
<div id="cakes">
|
||||
{{range $key, $value := .}}
|
||||
<button onclick="addCake('{{$key}}', '{{$value.Name}} ({{$value.Price}})')">{{$value.Name}}
|
||||
<button onclick="addCake('{{$value.ID}}', '{{$value.Name}} ({{$value.Price}})')">{{$value.Name}}
|
||||
{{$value.Price}}</button>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<div id="cake_preview">
|
||||
<ul>
|
||||
<li>ID: {{.ID}}</li>
|
||||
<li>Name: {{.Cake.Name}}</li>
|
||||
<li>Price: {{.Cake.Price}}</li>
|
||||
<li>Name: {{.Name}}</li>
|
||||
<li>Price: {{.Price}}</li>
|
||||
</ul>
|
||||
<button type="button" onClick="document.getElementById('cake_preview').remove()">close</button>
|
||||
</div>
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<form hx-post="new_cake" hx-swap="outerHTML">
|
||||
<div>
|
||||
<label for="name">Name</label>
|
||||
<input type="text" id="name" name="name" required value="{{.Cake.Name}}">
|
||||
<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="{{.Cake.Price}}">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<button hx-get="cake_editor" hx-swap="innerHTML" hx-target="#cake_editor">New</button>
|
||||
<div id="cakes">
|
||||
{{range $key, $value := .}}
|
||||
<button hx-get="cake_editor/{{$key}}" hx-swap="innerHTML" hx-target="#cake_editor">{{$value.Name}}
|
||||
<button hx-get="cake_editor/{{$value.ID}}" hx-swap="innerHTML" hx-target="#cake_editor">{{$value.Name}}
|
||||
{{$value.Price}}</button>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue