142 lines
7.9 KiB
HTML
142 lines
7.9 KiB
HTML
{{define "title"}}Solis | Locations{{end}}
|
|
|
|
{{define "content"}}
|
|
<div class="page-header">
|
|
<div class="page-title">
|
|
<h1>Locations</h1>
|
|
<p>Define physical areas and hierarchical storage places (e.g., House > Kitchen > Drawer A)</p>
|
|
</div>
|
|
</div>
|
|
|
|
<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">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Parent Path</th>
|
|
<th>Description</th>
|
|
<th style="width: 120px; text-align: right;">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{if .Locations}}
|
|
{{range .Locations}}
|
|
<tr>
|
|
<td style="font-weight: 600; color: var(--color-brand-primary);">{{.Name}}</td>
|
|
<td>
|
|
{{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;">Root</span>
|
|
{{end}}
|
|
</td>
|
|
<td style="color: var(--color-text-muted); font-size: 0.9rem;">{{.Description}}</td>
|
|
<td style="text-align: right;">
|
|
<div style="display: inline-flex; gap: 0.5rem;">
|
|
<!-- Edit Location triggers loading edit state in the right-side form -->
|
|
<a href="/admin/locations?edit={{.ID}}" class="btn btn-secondary" style="padding: 0.35rem 0.65rem; font-size: 0.8rem;">
|
|
Edit
|
|
</a>
|
|
{{if ne .ID 1}}
|
|
<form action="/admin/locations/delete/{{.ID}}" method="POST" onsubmit="return confirm('Are you sure you want to delete this location? Sub-locations and assets will be detached.')" 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;">
|
|
Delete
|
|
</button>
|
|
</form>
|
|
{{else}}
|
|
<span style="color: var(--color-text-light); font-size: 0.8rem; font-style: italic; padding: 0.35rem 0.65rem;">Locked</span>
|
|
{{end}}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{{else}}
|
|
<tr>
|
|
<td colspan="4" style="text-align: center; color: var(--color-text-light); padding: 3rem 1rem;">
|
|
No locations defined yet. Add one on the right to get started!
|
|
</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;">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">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">Parent Location (Optional)</label>
|
|
<select id="parent_id" name="parent_id" class="form-control">
|
|
<option value="">-- None (Root Location) --</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">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;">Save Changes</button>
|
|
<a href="/admin/locations" class="btn btn-secondary">Cancel</a>
|
|
</div>
|
|
</form>
|
|
{{else}}
|
|
<h3 style="font-weight: 700; margin-bottom: 1.25rem;">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">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">Parent Location (Optional)</label>
|
|
<select id="parent_id" name="parent_id" class="form-control">
|
|
<option value="">-- None (Root Location) --</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">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%;">Add Location</button>
|
|
</form>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|