fix(admin): expandable sidebar section + library manage toggle

- Admin section in sidebar now uses same expandable panel pattern as
  Appearance and User sections (toggle button with chevron, auto-opens
  when on /admin pages)
- Library Manage button toggles open/close instead of only opening
  (uses htmx.ajax for open, clears panel for close)
This commit is contained in:
2026-08-07 23:29:01 -04:00
parent 006cc0c2c9
commit a42232e67a
5 changed files with 283 additions and 262 deletions
+14 -3
View File
@@ -142,6 +142,18 @@ templ AdminLibrary(user User, libraries []LibraryData, users []User) {
</div>
</div>
<script>
function toggleLibraryPanel(btn) {
var libId = btn.dataset.libId;
var panel = document.getElementById('library-panel-' + libId);
if (panel.innerHTML.trim() !== '') {
panel.innerHTML = '';
} else {
htmx.ajax('GET', '/admin/library/' + libId + '/panel', {
target: '#library-panel-' + libId,
swap: 'innerHTML'
});
}
}
function openEditModal(id, name, description) {
document.getElementById('edit-library-form').setAttribute('hx-put', '/admin/library/' + id);
document.getElementById('edit-library-name').value = name;
@@ -219,9 +231,8 @@ templ LibraryList(user User, libraries []LibraryData, users []User) {
Scan
</button>
<button
hx-get={ "/admin/library/" + library.ID + "/panel" }
hx-target={ "#library-panel-" + library.ID }
hx-swap="innerHTML"
data-lib-id={ library.ID }
onclick="toggleLibraryPanel(this)"
class="btn btn-secondary text-xs px-3 py-1.5"
>
@Icon("chevron-down", "h-4 w-4")