templates, handlers, CSS, JS: special cakes UI, HTMX nav, dashboard overhaul

Special cakes UI: overlay drawer, basket integration, catalogue tag
filter, form parsing, JS save/edit/remove.
HTMX navigation: MainContent component, nav links with hx-get,
handlers return partial on HX-Request.
Dashboard: metrics grid, CakeBreakdown, OrderRow with status select,
CakeCounts/OrderCounts, torty filter, tort badge, results-pane.
Collapsible sidebar: toggle button, localStorage, CSS transitions.
Location field: dropdown replaced with pill toggle.
Inline style cleanup: moved to CSS classes (tag-grid, grow, icon.sm,
header-actions, toggle-group, success-icon, etc.).
Dead CSS removal: pagination, status-chip, badge-pill, login-page.
Helpers: exported CakeTitle/OrderTitle, added tagNames, tagIDsComma,
orderItemsDesc, specialCakeDetail, removed unused helpers.
This commit is contained in:
bronkuu 2026-06-15 18:50:21 +02:00
parent 17b92a706a
commit 5a5372b831
18 changed files with 1153 additions and 422 deletions

View file

@ -6,147 +6,181 @@ import (
"git.bronku.xyz/bronku/cake-order-tracker/models"
)
templ OrdersPage(first, last, today, tomorrow string, orders []models.Order) {
@Layout("Panel główny", DateForm(first, last, today, tomorrow), OrdersMain(orders))
templ OrdersPage(first, last, today, tomorrow, special string, counts models.OrderCounts, cakeCounts []models.CakeCount, orders []models.Order) {
@Layout("Panel główny", DateForm(first, last, today, tomorrow, special), OrdersMain(counts, cakeCounts, orders, first, last, special))
}
templ DateForm(first, last, today, tomorrow string) {
templ DateForm(first, last, today, tomorrow, special string) {
<div class="horizontal-group" style="gap:0.5rem;flex-wrap:wrap">
<div class="preset-group">
<a href={ templ.URL("/orders?from=" + today + "&to=" + today) } class="preset-btn">Dzisiaj</a>
<a href={ templ.URL("/orders?from=" + tomorrow + "&to=" + tomorrow) } class="preset-btn">Jutro</a>
<a href="/orders" class="preset-btn">W tym tygodniu</a>
<a href={ templ.URL("/orders?from=" + today + "&to=" + today + "&special=" + special) } hx-get={ templ.URL("/orders?from=" + today + "&to=" + today + "&special=" + special) } hx-target="#results-pane" class="preset-btn">Dzisiaj</a>
<a href={ templ.URL("/orders?from=" + tomorrow + "&to=" + tomorrow + "&special=" + special) } hx-get={ templ.URL("/orders?from=" + tomorrow + "&to=" + tomorrow + "&special=" + special) } hx-target="#results-pane" class="preset-btn">Jutro</a>
<a href={ templ.URL("/orders?special=" + special) } hx-get={ templ.URL("/orders?special=" + special) } hx-target="#results-pane" class="preset-btn">W tym tygodniu</a>
</div>
<form method="GET" action="/orders" class="horizontal-group" style="align-items:center;gap:0.25rem">
<form method="GET" action="/orders" class="horizontal-group" style="align-items:center;gap:0.25rem" hx-get="/orders" hx-target="#results-pane" hx-trigger="change, keyup delay:500ms">
<label>Od</label>
<input type="date" name="from" value={ first }/>
<label>Do</label>
<input type="date" name="to" value={ last }/>
<button type="submit" class="btn primary sm">Filtruj</button>
<input type="hidden" name="special" value={ special }/>
</form>
</div>
}
templ OrdersMain(orders []models.Order) {
templ OrdersMain(counts models.OrderCounts, cakeCounts []models.CakeCount, orders []models.Order, first, last, special string) {
<div class="metrics-grid">
<div>
<span class="label">
<span class="material-symbols-outlined">receipt_long</span>
Zamówienia dzisiaj
</span>
<span class="value">{ len(orders) }</span>
<span class="change positive">
<span class="material-symbols-outlined">arrow_upward</span>
Wszystkie aktywne
Aktywne
</span>
<span class="value">{ strconv.Itoa(counts.Active) }</span>
<span class="change">Wszystkie niezrealizowane</span>
</div>
<div>
<span class="label">
<span class="material-symbols-outlined">cake</span>
Do realizacji
</span>
<span class="value">{ strconv.Itoa(countPending(orders)) }</span>
<span class="change warning">
<span class="material-symbols-outlined">priority_high</span>
Oczekujące
</span>
</div>
<div>
<span class="label">
<span class="material-symbols-outlined">check_circle</span>
Gotowe do odbioru
</span>
<span class="value">{ strconv.Itoa(countDone(orders)) }</span>
<span class="change">Zrealizowane</span>
</div>
<div>
<span class="label">
<span class="material-symbols-outlined">payments</span>
Przychód (szac.)
</span>
<span class="value">{ estimateRevenue(orders).String() } PLN</span>
<span class="change positive">
<span class="material-symbols-outlined">trending_up</span>
W bieżącym miesiącu
<span class="material-symbols-outlined">today</span>
Na dziś
</span>
<span class="value">{ strconv.Itoa(counts.DueToday) }</span>
<span class="change">Do zrobienia</span>
</div>
</div>
<div id="results-pane">
@OrdersContent(orders, cakeCounts, first, last, special)
</div>
}
templ OrdersContent(orders []models.Order, cakeCounts []models.CakeCount, first, last, special string) {
<section class="card">
<header>
<h2>
<span class="material-symbols-outlined">list_alt</span>
Aktywne zamówienia
</h2>
<div style="position:relative;width:11.25rem">
<span class="material-symbols-outlined" style="position:absolute;left:0.5rem;top:50%;transform:translateY(-50%);font-size:1rem;color:var(--on-surface-variant);pointer-events:none">search</span>
<input type="text" style="height:1.75rem;padding-left:1.75rem;padding-right:0.5rem;font-size:0.75rem;border:1px solid var(--outline-variant);border-radius:var(--border-radius-sm);background:var(--surface-container-lowest);color:var(--on-surface);outline:none;width:100%" placeholder="Szukaj..." oninput="filterOrders(this)"/>
<div class="header-actions">
<div class="preset-group">
<a href={ templ.URL("/orders?special=true&from=" + first + "&to=" + last) } hx-get={ templ.URL("/orders?special=true&from=" + first + "&to=" + last) } hx-target="#results-pane"
class={ "preset-btn", templ.KV("active", special == "true") }>Torty</a>
<a href={ templ.URL("/orders?from=" + first + "&to=" + last) } hx-get={ templ.URL("/orders?from=" + first + "&to=" + last) } hx-target="#results-pane"
class={ "preset-btn", templ.KV("active", special != "true") }>Wszystkie</a>
</div>
<div class="search-wrapper">
<span class="material-symbols-outlined search-icon">search</span>
<input type="text" class="search-input" placeholder="Szukaj..." oninput="filterOrders(this)"/>
</div>
</div>
</header>
<div class="table-container" id="results-table">
@OrdersTable(orders)
<div class="table-container">
<table class="data-table">
<thead>
<tr>
<th>ID zamówienia</th>
<th>Klient</th>
<th>Data odbioru</th>
<th>Pozycje</th>
<th class="right">Suma</th>
<th class="center">Status</th>
<th class="center"></th>
</tr>
</thead>
<tbody>
for _, o := range orders {
@OrderRow(o)
}
</tbody>
</table>
</div>
</section>
<script>
function filterOrders(input) {
var q = input.value.toLowerCase();
var rows = document.querySelectorAll('#results-table tbody tr');
for (var i = 0; i < rows.length; i++) {
var id = rows[i].children[0].textContent.toLowerCase();
var customer = rows[i].children[1].textContent.toLowerCase();
rows[i].style.display = id.includes(q) || customer.includes(q) ? '' : 'none';
}
}
</script>
@CakeBreakdown(cakeCounts)
}
templ OrdersTable(orders []models.Order) {
<table class="data-table">
<thead>
<tr>
<th>ID zamówienia</th>
<th>Klient</th>
<th>Data odbioru</th>
<th>Pozycje</th>
<th class="right">Suma</th>
<th class="center">Status</th>
<th class="center"></th>
</tr>
</thead>
<tbody>
for _, o := range orders {
<tr>
<td><a href={ templ.URL("/order/" + strconv.Itoa(o.ID)) } class="order-id">#{ strconv.Itoa(o.ID) }</a></td>
<td class="customer">{ o.Surname } { o.Name }<br/><span class="text-muted" style="font-size:0.75rem;font-weight:400">{ o.Phone }</span></td>
<td class="text-muted">{ o.Date.Format("2006-01-02 15:04") }</td>
<td>
<span class="truncate" title={ cakeItemsDesc(o.Cakes) }>
for i, c := range o.Cakes {
if i > 0 {
{ ", " }
}
{ c.Name } (x{ strconv.Itoa(c.Amount) })
}
</span>
</td>
<td class="text-right" style="font-weight:700">{ o.Total().String() } PLN</td>
<td class="text-center">
<span class={ "status-chip " + o.Status }>
if o.Status == "accepted" {
Przyjęte
} else if o.Status == "done" {
Gotowe
} else {
Oczekujące
}
</span>
</td>
<td class="text-center">
<a href={ templ.URL("/order/" + strconv.Itoa(o.ID)) } class="action-btn">
<span class="material-symbols-outlined">edit</span>
</a>
</td>
</tr>
templ OrderRow(order models.Order) {
<tr>
<td><a href={ templ.URL("/order/" + strconv.Itoa(order.ID)) } class="order-id">#{ strconv.Itoa(order.ID) }</a></td>
<td class="customer">{ order.Surname } { order.Name }<br/><span class="text-muted">{ order.Phone }</span></td>
<td class="text-muted">{ order.Date.Format("2006-01-02 15:04") }</td>
<td>
if len(order.SpecialCakes) > 0 {
<span class="tort-badge" title="Tort specjalny">
<span class="material-symbols-outlined">cake</span>
</span>
}
</tbody>
</table>
<span class="truncate" title={ orderItemsDesc(order) }>
for i, c := range order.Cakes {
if i > 0 {
{ ", " }
}
{ c.Name } (x{ strconv.Itoa(c.Amount) })
}
for _, s := range order.SpecialCakes {
{ ", " }
{ s.Name }*
}
</span>
</td>
<td class="text-right font-bold">{ order.Total().String() } PLN</td>
<td class="text-center">
<select name="status" class="status-select"
hx-post={ templ.URL("/order/" + strconv.Itoa(order.ID) + "/status") }
hx-trigger="change"
hx-target="closest tr"
hx-swap="outerHTML">
<option value="pending"
if order.Status == "pending" {
selected
}
>Oczekujące</option>
<option value="accepted"
if order.Status == "accepted" {
selected
}
>Przyjęte</option>
<option value="production"
if order.Status == "production" {
selected
}
>W realizacji</option>
<option value="ready"
if order.Status == "ready" {
selected
}
>Do odbioru</option>
<option value="picked_up"
if order.Status == "picked_up" {
selected
}
>Wydane</option>
</select>
</td>
<td class="text-center">
<a href={ templ.URL("/order/" + strconv.Itoa(order.ID)) } class="action-btn">
<span class="material-symbols-outlined">edit</span>
</a>
</td>
</tr>
}
templ CakeBreakdown(cakeCounts []models.CakeCount) {
<section class="card">
<header>
<h2>
<span class="material-symbols-outlined">cake</span>
Zapotrzebowanie
</h2>
</header>
<div>
<ul class="breakdown-list">
for _, cc := range cakeCounts {
<li class="breakdown-item">
<span>{ cc.Name }</span>
<span class="breakdown-amount">{ strconv.Itoa(cc.Amount) }</span>
</li>
}
if len(cakeCounts) == 0 {
<li class="breakdown-empty">Brak ciast w tym okresie</li>
}
</ul>
</div>
</section>
}