Files
go-htmx-tailwind-example/templates/items/entity-edit.html

85 lines
3.1 KiB
HTML

<tr id="datarow-{{.ID}}" class="datarow border-b dark:border-neutral-500">
<td class="whitespace-nowrap px-6 py-4">
<input class="data-input-{{.ID}}" hidden disabled type="text" name="id" value="{{.ID}}" data-include-edit="{{.ID}}" />
<span>{{.ID}}</span>
</td>
<td class="whitespace-nowrap px-6 py-4">
<input
type="text"
class="data-input-{{.ID}} shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
data-include-edit="{{.ID}}"
name="name"
value="{{.Name}}"
/>
</td>
<td class="whitespace-nowrap px-6 py-4">
<select class="data-input-{{.ID}}" id="packing-stage-selector-{{.ID}}" data-include-edit="{{.ID}}" value="{{.Stage}}" name="stage">
<option value="0">Essentials</option>
<option value="1">Stage One</option>
<option value="2">Stage Two</option>
<option value="3">Stage Three</option>
<option value="4">Determine Later</option>
</select>
</td>
<td class="whitespace-nowrap px-6 py-4">
<select class="data-input-{{.ID}}" id="category-selector-{{.ID}}" data-include-edit="{{.ID}}" value="{{.Category}}" name="category">
<option value="0">Bedroom</option>
<option value="1">Bathroom</option>
<option value="2">Kitchen</option>
<option value="3">Office</option>
<option value="4">Living Room</option>
<option value="5">Other</option>
</select>
</td>
<td class="whitespace-nowrap px-6 py-4">
<input
type="text"
class="data-input-{{.ID}} shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
data-include-edit="{{.ID}}"
name="description"
value="{{.Description}}"
/>
</td>
<td class="whitespace-nowrap px-6 py-4">
<input
type="text"
class="data-input-{{.ID}} shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
data-include-edit="{{.ID}}"
name="notes"
value="{{.Notes}}"
/>
<td class="whitespace-nowrap px-1 py-1">
<a
hx-put="/items/save/{{.ID}}"
hx-target="#datarow-{{.ID}}"
hx-swap="outerHTML"
hx-indicator="#processing"
hx-include=".data-input-{{.ID}}"
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
href=""
>Save</a
>
</td>
<td class="whitespace-nowrap px-1 py-1">
<a
hx-get="/items/{{.ID}}"
hx-target="#datarow-{{.ID}}"
hx-swap="outerHTML"
hx-indicator="#processing"
class="inline-flex items-center h-8 px-4 m-2 text-sm text-red-100 transition-colors duration-150 bg-red-700 rounded-lg focus:shadow-outline hover:bg-red-800"
href=""
>Cancel</a
>
</td>
<script>
document.getElementById("category-selector-{{.ID}}").onchange = (e) => {
console.log(e.target.value);
}
document.getElementById("packing-stage-selector-{{.ID}}").onchange = (e) => {
console.log(e.target.value);
}
</script>
</tr>