190 lines
12 KiB
HTML
190 lines
12 KiB
HTML
{{define "title"}}{{T "app.title.locations"}}{{end}}
|
|
|
|
{{define "content"}}
|
|
<div class="page-header">
|
|
<div class="page-title">
|
|
<h1>{{T "locations.title"}}</h1>
|
|
<p>{{T "locations.subtitle"}}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<form action="/admin/locations" method="GET" class="filter-bar" style="margin-bottom: 1.5rem; justify-content: flex-end;">
|
|
{{if .EditingLocation}}
|
|
<input type="hidden" name="edit" value="{{.EditingLocation.ID}}">
|
|
{{end}}
|
|
<label style="display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;">
|
|
<input type="checkbox" name="show_removed" value="1" {{if .ShowRemoved}}checked{{end}} onchange="this.form.submit()">
|
|
{{T "locations.show_removed"}}
|
|
</label>
|
|
</form>
|
|
|
|
|
|
<div class="detail-grid">
|
|
<!-- Left Column: Locations List -->
|
|
<div class="detail-main">
|
|
<div class="card" style="padding: 0;">
|
|
<div class="data-table-wrapper">
|
|
<table class="data-table data-table--responsive">
|
|
<thead>
|
|
<tr>
|
|
<th>{{T "locations.col.name"}}</th>
|
|
<th>{{T "locations.col.parent"}}</th>
|
|
<th>{{T "common.description"}}</th>
|
|
<th style="width: 120px; text-align: right;">{{T "common.actions"}}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{if .Locations}}
|
|
{{range .Locations}}
|
|
<tr class="{{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}">
|
|
<td data-label="{{T "locations.col.name"}}" style="font-weight: 600;">
|
|
<a href="/{{.Slug}}" style="color: var(--color-brand-primary); text-decoration: none;">{{.Name}}</a>
|
|
{{if eq .LifecycleState "archived"}}
|
|
<span class="status-pill archived" style="margin-left: 0.5rem; font-size: 0.7rem; padding: 0.1rem 0.4rem;">{{T "common.archived"}}</span>
|
|
{{end}}
|
|
</td>
|
|
<td data-label="{{T "locations.col.parent"}}">
|
|
{{if .ParentName.Valid}}
|
|
<span style="color: var(--color-text-muted); font-size: 0.9rem;">
|
|
{{.ParentName.String}} →
|
|
</span>
|
|
{{else}}
|
|
<span style="color: var(--color-text-light); font-size: 0.85rem;">{{T "common.root"}}</span>
|
|
{{end}}
|
|
</td>
|
|
<td data-label="{{T "common.description"}}" style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
|
|
<td data-label="{{T "common.actions"}}" class="actions-cell" style="text-align: right;">
|
|
<div style="display: inline-flex; gap: 0.5rem; align-items: center;">
|
|
{{if eq .ID 1}}
|
|
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">{{T "common.locked"}}</span>
|
|
{{else if eq .LifecycleState "removed"}}
|
|
<!-- Soft removed actions -->
|
|
<form action="/admin/locations/restore/{{.ID}}" method="POST" style="margin: 0;">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; border-color: #10b981; color: #10b981;">
|
|
{{T "common.restore"}}
|
|
</button>
|
|
</form>
|
|
<form action="/admin/locations/permanent-delete/{{.ID}}" method="POST" onsubmit="return confirm('{{T "locations.confirm_delete"}}')" style="margin: 0;">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="btn btn-danger" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
|
{{T "common.delete_forever"}}
|
|
</button>
|
|
</form>
|
|
{{else}}
|
|
<!-- Active / Archived actions -->
|
|
{{if ne .LifecycleState "archived"}}
|
|
<a href="/admin/locations?edit={{.ID}}&show_removed={{if $.ShowRemoved}}1{{else}}0{{end}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
|
{{T "common.edit"}}
|
|
</a>
|
|
{{end}}
|
|
|
|
<div class="actions-dropdown">
|
|
<button class="btn btn-danger" onclick="toggleActionsDropdown(this, event)" style="padding: 0.35rem 0.65rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.25rem;">
|
|
{{T "common.delete"}} <span style="font-size: 0.65rem;">▼</span>
|
|
</button>
|
|
<div class="actions-dropdown-menu">
|
|
<form action="/admin/locations/remove/{{.ID}}" method="POST" style="margin: 0;">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="actions-dropdown-item text-danger">
|
|
🗑 {{T "common.remove"}}
|
|
</button>
|
|
</form>
|
|
{{if ne .LifecycleState "archived"}}
|
|
<form action="/admin/locations/archive/{{.ID}}" method="POST" style="margin: 0;">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="actions-dropdown-item text-warning">
|
|
📦 {{T "common.archive"}}
|
|
</button>
|
|
</form>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{{else}}
|
|
<tr>
|
|
<td colspan="4" style="text-align: center; color: var(--color-text-light); padding: 3rem 1rem;">
|
|
{{T "locations.empty"}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Right Column: Add/Edit Form -->
|
|
<div class="detail-sidebar">
|
|
<div class="card">
|
|
{{if .EditingLocation}}
|
|
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "locations.edit_location"}}</h3>
|
|
<form action="/admin/locations/edit/{{.EditingLocation.ID}}" method="POST">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
|
|
<div class="form-group">
|
|
<label for="name" class="form-label">{{T "locations.location_name"}}</label>
|
|
<input type="text" id="name" name="name" class="form-control" value="{{.EditingLocation.Name}}" {{if eq .EditingLocation.ID 1}}readonly style="background-color: var(--color-bg-base); cursor: not-allowed;"{{end}} required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="parent_id" class="form-label">{{T "locations.parent_location"}}</label>
|
|
<select id="parent_id" name="parent_id" class="form-control">
|
|
<option value="">{{T "locations.none_root"}}</option>
|
|
{{range $.Locations}}
|
|
{{if ne .ID $.EditingLocation.ID}}
|
|
<option value="{{.ID}}" {{if $.EditingLocation.ParentID.Valid}}{{if eq .ID $.EditingLocation.ParentID.Int64}}selected{{end}}{{end}}>
|
|
{{.Name}}
|
|
</option>
|
|
{{end}}
|
|
{{end}}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-bottom: 1.75rem;">
|
|
<label for="description" class="form-label">{{T "common.description"}}</label>
|
|
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. Red plastic storage box on shelf 2">{{.EditingLocation.Description}}</textarea>
|
|
</div>
|
|
|
|
<div style="display: flex; gap: 0.5rem;">
|
|
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">{{T "common.save"}}</button>
|
|
<a href="/admin/locations" class="btn btn-secondary">{{T "common.cancel"}}</a>
|
|
</div>
|
|
</form>
|
|
{{else}}
|
|
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">{{T "locations.create_location"}}</h3>
|
|
<form action="/admin/locations/new" method="POST">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
|
|
<div class="form-group">
|
|
<label for="name" class="form-label">{{T "locations.location_name"}}</label>
|
|
<input type="text" id="name" name="name" class="form-control" placeholder="e.g. Living Room, Drawer B" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="parent_id" class="form-label">{{T "locations.parent_location"}}</label>
|
|
<select id="parent_id" name="parent_id" class="form-control">
|
|
<option value="">{{T "locations.none_root"}}</option>
|
|
{{range .Locations}}
|
|
<option value="{{.ID}}">{{.Name}}</option>
|
|
{{end}}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-bottom: 1.75rem;">
|
|
<label for="description" class="form-label">{{T "common.description"}}</label>
|
|
<textarea id="description" name="description" class="form-control" rows="3" placeholder="e.g. First floor living room cupboard"></textarea>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary" style="width: 100%;">{{T "locations.add_location"}}</button>
|
|
</form>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|