Files
Solis/internal/server/templates/location_folder.html
T
lucioandClaude Fable 5 c0375f651a Add container arrays with 3D drawer grid view
Locations can now be container arrays (up to 20x20). Each drawer is a
child location with a grid position and color, shown in a 3D cabinet
view with hover/tap slide-out, content summary peek, drag (or touch
and hold) to swap, and a modal to rename, recolor, or relocate
drawers. Deleting a drawer leaves its slot empty.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-10 22:28:13 -07:00

350 lines
24 KiB
HTML

{{define "content"}}
<div class="folder-view-container">
<!-- Folder View Header -->
<div class="folder-header">
<!-- Breadcrumbs Path -->
{{if .IsAuthenticated}}
<nav class="folder-breadcrumbs" aria-label="Breadcrumbs">
<a href="{{if $.IsAuthenticated}}/admin/locations{{else}}/default-room{{end}}" class="breadcrumb-item breadcrumb-home dropzone" data-location-id="1" data-type="location">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width: 16px; height: 16px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
</svg>
<span>{{T "folder.home"}}</span>
</a>
{{range $idx, $crumb := .Breadcrumbs}}
{{if ne $crumb.ID 1}}
<span class="breadcrumb-separator">/</span>
<a href="/{{$crumb.Slug}}" class="breadcrumb-item dropzone {{if eq $crumb.ID $.CurrentLocation.ID}}active{{end}}" data-location-id="{{$crumb.ID}}" data-type="location">
{{$crumb.Name}}
</a>
{{end}}
{{end}}
</nav>
{{end}}
<div class="folder-actions-wrapper">
<h1 class="folder-title">{{.CurrentLocation.Name}}</h1>
{{if .CurrentLocation.Description}}
<p class="folder-description">{{.CurrentLocation.Description}}</p>
{{end}}
<div class="folder-controls" style="margin-top: 1rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;">
{{if .IsAuthenticated}}
<div style="display: flex; gap: 0.5rem; align-items: center;">
<label class="checkbox-container" style="display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 500; color: var(--color-text-muted); cursor: pointer;">
<input type="checkbox" id="toggle-removed-checkbox" {{if .ShowRemoved}}checked{{end}} onchange="toggleShowRemoved(this)" style="accent-color: var(--color-brand-primary); cursor: pointer;">
{{T "folder.show_removed"}}
</label>
</div>
{{end}}
{{if .IsAuthenticated}}
<div style="display: flex; gap: 0.5rem;">
<a href="/admin/locations/edit/{{.CurrentLocation.ID}}" class="btn btn-secondary" style="font-size: 0.85rem; padding: 0.5rem 1rem;">
{{T "folder.edit_location"}}
</a>
<a href="/admin/items/new?location_id={{.CurrentLocation.ID}}" class="btn btn-primary" style="font-size: 0.85rem; padding: 0.5rem 1rem;">
{{T "folder.add_asset_here"}}
</a>
</div>
{{end}}
</div>
</div>
</div>
<!-- Move Up Drop Zone (Visible when inside a nested folder & authenticated) -->
{{if .IsAuthenticated}}
{{if .CurrentLocation.ParentID.Valid}}
<div class="move-up-zone dropzone" data-location-id="{{.CurrentLocation.ParentID.Int64}}" data-type="location">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width: 20px; height: 20px; color: var(--color-brand-primary);">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 19.5v-15m0 0l-6.75 6.75M12 4.5l6.75 6.75" />
</svg>
<span>{{T "folder.drag_up"}}</span>
</div>
{{end}}
{{end}}
<!-- Container Array Drawer Grid -->
{{if and .IsAuthenticated .DrawerGrid}}
<div class="directory-section drawer-array-section">
<h2 class="section-title">{{T "drawer.section_title"}}</h2>
<p class="drawer-array-hint">{{T "drawer.hint"}}</p>
<div class="drawer-cabinet-wrapper">
<div class="drawer-cabinet" id="drawer-cabinet"
data-array-id="{{.CurrentLocation.ID}}"
style="--drawer-cols: {{.CurrentLocation.GridCols}};">
{{range $row := .DrawerGrid}}
{{range $cell := $row}}
{{if $cell.Drawer}}
<div class="drawer-cell has-drawer"
data-row="{{$cell.Row}}" data-col="{{$cell.Col}}"
data-drawer-id="{{$cell.Drawer.ID}}"
data-drawer-name="{{$cell.Drawer.Name}}"
data-drawer-color="{{$cell.Drawer.Color}}"
data-drawer-slug="{{$cell.Drawer.Slug}}">
<div class="drawer-box">
<div class="drawer-cavity"></div>
<div class="drawer-tray" {{if $cell.Drawer.Color}}style="--drawer-color: {{$cell.Drawer.Color}};"{{end}}>
<div class="drawer-front">
<span class="drawer-label">{{$cell.Drawer.Name}}</span>
<span class="drawer-handle"></span>
</div>
</div>
</div>
<div class="drawer-peek">
<strong class="drawer-peek-name">{{$cell.Drawer.Name}}</strong>
<span class="drawer-peek-count">{{$cell.Drawer.ItemCount}} {{T "drawer.items"}}</span>
{{if $cell.Drawer.ItemNames}}
<em class="drawer-peek-items">{{$cell.Drawer.ItemNames}}</em>
{{else}}
<em class="drawer-peek-items">{{T "drawer.empty_contents"}}</em>
{{end}}
<div class="drawer-peek-actions">
<a href="/{{$cell.Drawer.Slug}}" class="drawer-peek-btn">{{T "drawer.open"}}</a>
<button type="button" class="drawer-peek-btn" onclick="openDrawerModal(this.closest('.drawer-cell'))">{{T "common.edit"}}</button>
<form action="/admin/drawers/remove/{{$cell.Drawer.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('{{T "drawer.confirm_remove"}}');">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="drawer-peek-btn danger">{{T "common.delete"}}</button>
</form>
</div>
</div>
</div>
{{else}}
<div class="drawer-cell empty"
data-row="{{$cell.Row}}" data-col="{{$cell.Col}}"
role="button" tabindex="0"
aria-label="{{T "drawer.add"}}"
onclick="openDrawerModal(this)">
<div class="drawer-box">
<div class="drawer-tray empty-tray">
<div class="drawer-front">
<span class="drawer-add-icon">+</span>
</div>
</div>
</div>
</div>
{{end}}
{{end}}
{{end}}
</div>
</div>
</div>
<!-- Drawer Create / Edit Modal -->
<div class="drawer-modal-backdrop" id="drawer-modal" hidden
data-title-create="{{T "drawer.new_drawer"}}" data-title-edit="{{T "drawer.edit_drawer"}}">
<div class="drawer-modal card" role="dialog" aria-modal="true">
<h3 id="drawer-modal-title" style="font-weight: 700; margin-bottom: 1rem;">{{T "drawer.edit_drawer"}}</h3>
<form id="drawer-modal-form" method="POST" action="/admin/drawers/new">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
<input type="hidden" name="array_id" value="{{.CurrentLocation.ID}}">
<input type="hidden" name="row" id="drawer-form-row" value="">
<input type="hidden" name="col" id="drawer-form-col" value="">
<div class="form-group">
<label class="form-label" for="drawer-form-name">{{T "drawer.name"}}</label>
<input type="text" id="drawer-form-name" name="name" class="form-control" placeholder="e.g. Resistors A1">
</div>
<div class="form-group">
<label class="form-label" for="drawer-form-color">{{T "drawer.color"}}</label>
<div style="display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;">
<input type="color" id="drawer-form-color" name="color" value="#d97706" style="width: 3rem; height: 2.2rem; padding: 0.15rem; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-bg-surface); cursor: pointer;">
<button type="button" class="drawer-swatch" style="background:#d97706;" onclick="setDrawerColor('#d97706')" aria-label="amber"></button>
<button type="button" class="drawer-swatch" style="background:#ef4444;" onclick="setDrawerColor('#ef4444')" aria-label="red"></button>
<button type="button" class="drawer-swatch" style="background:#10b981;" onclick="setDrawerColor('#10b981')" aria-label="green"></button>
<button type="button" class="drawer-swatch" style="background:#3b82f6;" onclick="setDrawerColor('#3b82f6')" aria-label="blue"></button>
<button type="button" class="drawer-swatch" style="background:#8b5cf6;" onclick="setDrawerColor('#8b5cf6')" aria-label="purple"></button>
<button type="button" class="drawer-swatch" style="background:#64748b;" onclick="setDrawerColor('#64748b')" aria-label="slate"></button>
</div>
</div>
<div class="form-group" id="drawer-form-location-group" hidden>
<label class="form-label" for="drawer-form-parent">{{T "drawer.location"}}</label>
<select id="drawer-form-parent" name="parent_id" class="form-control">
<option value="{{.CurrentLocation.ID}}">{{.CurrentLocation.Name}} ({{T "drawer.current_array"}})</option>
{{range .Locations}}
{{if ne .ID $.CurrentLocation.ID}}
<option value="{{.ID}}">{{.Name}}</option>
{{end}}
{{end}}
</select>
<p style="color: var(--color-text-light); font-size: 0.8rem; margin-top: 0.35rem;">{{T "drawer.location_hint"}}</p>
</div>
<div style="display: flex; gap: 0.5rem; margin-top: 1.25rem;">
<button type="submit" class="btn btn-primary" style="flex-grow: 1;">{{T "common.save"}}</button>
<button type="button" class="btn btn-secondary" onclick="closeDrawerModal()">{{T "common.cancel"}}</button>
</div>
</form>
</div>
</div>
{{end}}
<!-- Sub-folders Section -->
{{if .IsAuthenticated}}
<div class="directory-section">
<h2 class="section-title">{{T "folder.folders"}}</h2>
<div class="folders-grid">
{{if not .ChildLocations}}
<div class="empty-state-card" style="grid-column: 1 / -1;">
<p>{{T "folder.no_subfolders"}}</p>
</div>
{{else}}
{{range .ChildLocations}}
<div class="folder-card dropzone {{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}"
{{if $.IsAuthenticated}}draggable="true"{{end}}
data-location-id="{{.ID}}"
data-type="location">
<div class="folder-card-main">
<div class="folder-icon-wrapper">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" class="folder-icon">
<path d="M19.5 21a3 3 0 003-3v-4.5a3 3 0 00-3-3h-15a3 3 0 00-3 3V18a3 3 0 003 3h15zM1.5 10.146V6a3 3 0 013-3h5.379a3 3 0 012.122.879l1.242 1.242a3 3 0 002.122.879H19.5a3 3 0 013 3v2.146a4.487 4.487 0 00-3-1.146h-15a4.487 4.487 0 00-3 1.146z" />
</svg>
</div>
<div class="folder-info">
<a href="/{{.Slug}}" class="folder-name-link">{{.Name}}</a>
<span class="folder-badge">{{if eq .LifecycleState "removed"}}{{T "folder.state.removed"}}{{else if eq .LifecycleState "archived"}}{{T "folder.state.archived"}}{{else}}{{T "folder.state.active"}}{{end}}</span>
</div>
</div>
{{if $.IsAuthenticated}}
<div class="actions-dropdown">
<button class="btn-icon" onclick="toggleActionsDropdown(this, event)" aria-label="{{T "common.actions"}}">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width:16px;height:16px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 12.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 18.75a.75.75 0 110-1.5.75.75 0 010 1.5z" />
</svg>
</button>
<div class="actions-dropdown-menu">
<a href="/admin/locations/edit/{{.ID}}" class="actions-dropdown-item">
{{T "folder.edit_folder"}}
</a>
{{if eq .LifecycleState "removed"}}
<form action="/admin/locations/restore/{{.ID}}" method="POST" style="margin:0;">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="actions-dropdown-item text-warning">{{T "folder.restore_folder"}}</button>
</form>
<form action="/admin/locations/delete/{{.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('{{T "folder.confirm_delete_location"}}');">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="actions-dropdown-item text-danger">{{T "folder.delete_permanently"}}</button>
</form>
{{else}}
<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 "folder.archive_folder"}}</button>
</form>
<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 "folder.remove_folder"}}</button>
</form>
{{end}}
</div>
</div>
{{end}}
</div>
{{end}}
{{end}}
</div>
</div>
{{end}}
<!-- Assets / Items Section -->
{{if .IsAuthenticated}}
<div class="directory-section" style="margin-top: 3rem;">
<h2 class="section-title">{{T "folder.assets"}}</h2>
<div class="items-grid">
{{if not .Items}}
<div class="empty-state-card" style="grid-column: 1 / -1; padding: 3rem 2rem;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width:48px;height:48px;color:var(--color-text-light);margin-bottom:0.75rem;">
<path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" />
</svg>
<p style="color:var(--color-text-muted);font-weight:500;">{{T "folder.no_assets"}}</p>
</div>
{{else}}
{{range .Items}}
<div class="item-card {{if eq .LifecycleState "removed"}}lifecycle-removed{{else if eq .LifecycleState "archived"}}lifecycle-archived{{end}}"
{{if $.IsAuthenticated}}draggable="true"{{end}}
data-item-id="{{.ID}}"
data-type="item">
<div class="item-card-image">
{{if .ImagePath}}
<img src="/uploads/{{.ImagePath}}" alt="{{.Name}}">
{{else}}
<div class="item-image-placeholder">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" />
</svg>
</div>
{{end}}
</div>
<div class="item-card-body">
<div class="item-card-header">
<a href="/{{$.CurrentLocation.Slug}}/{{.ShortSlug}}" class="item-card-title">{{.Name}}</a>
<span class="status-pill {{if eq .Status "In Use"}}in-use{{else if eq .Status "In Storage"}}in-storage{{else if eq .Status "Borrowed"}}borrowed{{else if eq .Status "Lost"}}lost{{else}}disposed{{end}}">{{.Status}}</span>
</div>
<p class="item-card-meta">
<span>{{T "folder.qty"}}: <strong>{{.Quantity}}</strong></span>
{{if .ModelNumber}}<span>&bull; {{T "items.model_prefix"}}: <strong>{{.ModelNumber}}</strong></span>{{end}}
</p>
<div class="item-card-tags">
{{range .Tags}}
<span class="tag-pill" style="background-color: {{.Color}};">{{.Name}}</span>
{{end}}
</div>
</div>
{{if $.IsAuthenticated}}
<div class="actions-dropdown" style="position: absolute; top: 0.75rem; right: 0.75rem; z-index: 10;">
<button class="btn-icon card-actions-btn" onclick="toggleActionsDropdown(this, event)" aria-label="{{T "common.actions"}}">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width:16px;height:16px;">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 12.75a.75.75 0 110-1.5.75.75 0 010 1.5zM12 18.75a.75.75 0 110-1.5.75.75 0 010 1.5z" />
</svg>
</button>
<div class="actions-dropdown-menu">
<a href="/admin/items/edit/{{.ID}}" class="actions-dropdown-item">
{{T "folder.edit_asset"}}
</a>
<button type="button" class="actions-dropdown-item" onclick="openQRModal('{{.ShortSlug}}', '{{.Name}}')">
{{T "folder.show_qr"}}
</button>
{{if eq .LifecycleState "removed"}}
<form action="/admin/items/restore/{{.ID}}" method="POST" style="margin:0;">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="actions-dropdown-item text-warning">{{T "folder.restore_asset"}}</button>
</form>
<form action="/admin/items/delete/{{.ID}}" method="POST" style="margin:0;" onsubmit="return confirm('{{T "folder.confirm_delete_asset"}}');">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<button type="submit" class="actions-dropdown-item text-danger">{{T "folder.delete_permanently"}}</button>
</form>
{{else}}
<form action="/admin/items/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 "folder.archive_asset"}}</button>
</form>
<form action="/admin/items/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 "folder.remove_asset"}}</button>
</form>
{{end}}
</div>
</div>
{{end}}
</div>
{{end}}
{{end}}
</div>
</div>
{{end}}
</div>
<script>
function toggleShowRemoved(checkbox) {
const url = new URL(window.location.href);
if (checkbox.checked) {
url.searchParams.set("show_removed", "1");
} else {
url.searchParams.delete("show_removed");
}
window.location.href = url.toString();
}
</script>
{{end}}