removed order_infoe endpoint

This commit is contained in:
bronku 2025-04-06 11:33:00 +02:00
parent f26498c756
commit 8fddf65e5a
2 changed files with 8 additions and 24 deletions

View file

@ -47,7 +47,6 @@ func New(store *store.Store) *Server {
server.routes = map[string]route{ server.routes = map[string]route{
"GET /order/": {server.order, "order", "layout"}, "GET /order/": {server.order, "order", "layout"},
"GET /order_info/": {server.order, "orders", "order_info"},
"GET /orders": {server.orders, "orders", "layout"}, "GET /orders": {server.orders, "orders", "layout"},
"GET /orders/search/": {server.ordersSearch, "orders", "orders-table"}, "GET /orders/search/": {server.ordersSearch, "orders", "orders-table"},
"GET /cake/": {server.cake, "cake", "layout"}, "GET /cake/": {server.cake, "cake", "layout"},

View file

@ -29,25 +29,13 @@ Zamówienia
} }
</style> </style>
<script> <script>
function toggleDetails(row,event) { function toggleDetails(row) {
// Access the next row (details row)
const detailsRow=row.nextElementSibling; const detailsRow=row.nextElementSibling;
// Check if the details row is hidden
if(detailsRow.classList.contains('hidden')) { if(detailsRow.classList.contains('hidden')) {
// If hidden, show it (HTMX will populate it)
detailsRow.classList.remove('hidden'); detailsRow.classList.remove('hidden');
row.classList.add('active'); return;
} else {
// If visible, hide it
detailsRow.classList.add('hidden');
row.classList.remove('active');
// Prevent HTMX from making a request when we're just hiding
if(event) {
event.stopPropagation();
}
} }
detailsRow.classList.add('hidden');
} }
</script> </script>
{{end}} {{end}}
@ -65,9 +53,8 @@ Zamówienia
</thead> </thead>
<tbody> <tbody>
{{range .}} {{range .}}
<tr class="clickable" hx-get="/order_info/{{.ID}}" hx-target="next tr" hx-swap="innerHTML" <tr class="clickable" onclick="toggleDetails(this)">
onclick="toggleDetails(this, event)"> <th><a href="/order/{{.ID}}">#{{.ID}}</a></th>
<th><a href="/order/{{.ID}}">{{.ID}}</a></th>
<th>{{.Surname}} {{.Name}} {{.Phone}}</th> <th>{{.Surname}} {{.Name}} {{.Phone}}</th>
<th>{{.Location}}</th> <th>{{.Location}}</th>
<th>{{.Date.Format "2006-01-02"}}</th> <th>{{.Date.Format "2006-01-02"}}</th>
@ -75,15 +62,15 @@ Zamówienia
<th>{{.Status}}</th> <th>{{.Status}}</th>
</tr> </tr>
<tr class="hidden"> <tr class="hidden">
<td colspan="6" class="details-content"></td> <td colspan="6" class="details-content">
{{template "order_info" .}}
</td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
{{end}} {{end}}
{{define "order_info"}} {{define "order_info"}}
{{with .Order}}
<td colspan="6" class="details-content">
<table> <table>
{{range .Cakes}} {{range .Cakes}}
<tr> <tr>
@ -93,6 +80,4 @@ Zamówienia
</tr> </tr>
{{end}} {{end}}
</table> </table>
</td>
{{end}}
{{end}} {{end}}