From 9ae99d0dddaa430c6e5c70df4a85ee74706404e6 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 20 Mar 2026 11:42:45 -0400 Subject: [PATCH] feat: add functional book picker modal to collections Update CollectionDetail template to enable book picker: Enable Add Books button: - Remove disabled attribute and inline JavaScript handlers - Wire to $store.bookPicker.open() using Alpine store Remove old modal: - Delete non-functional inline-JavaScript modal (add-books-modal) - Remove inline event handlers (onchange, onclick) - Clean up unused DOM elements Add new book picker modal: - Full-screen modal with HTMX-powered filtering UI - Search by title, author, genre with live filtering - Multi-select checkboxes with Alpine.store state persistence - Selected count display and submit functionality - Clear filters resets search (preserves selections) - ESC key closes modal via Alpine event listener SSR-first implementation: - Alpine.store.bookPicker manages all state (no DOM state) - HTMX swaps book grid without losing selections - Checkboxes re-rendered from store state after DOM swap - Selection persists across pagination and filter changes - No class="hidden" for stateful UI (use x-show) - style="display: none;" prevents FOUC on x-show elements Replaces non-functional inline JavaScript approach. Matches bookshelf filtering UX for consistency. Changes to collections_templ.go are auto-generated from .templ file. --- templates/collections.templ | 162 +++++++++++++++++++++++++++------ templates/collections_templ.go | 49 +--------- 2 files changed, 138 insertions(+), 73 deletions(-) diff --git a/templates/collections.templ b/templates/collections.templ index cf22697..d15d184 100644 --- a/templates/collections.templ +++ b/templates/collections.templ @@ -154,7 +154,7 @@ templ CollectionDetail(user User, collection CollectionData, books []handlers.Bo 🗑️ Remove Selected + + +

Books in this Collection

0 selected
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "

Books in this Collection

0 selected
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -264,7 +264,7 @@ func CollectionDetail(user User, collection CollectionData, books []handlers.Boo var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(book.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collections.templ`, Line: 187, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collections.templ`, Line: 184, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -282,7 +282,7 @@ func CollectionDetail(user User, collection CollectionData, books []handlers.Boo var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(book.Author) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collections.templ`, Line: 194, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collections.templ`, Line: 191, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -305,7 +305,7 @@ func CollectionDetail(user User, collection CollectionData, books []handlers.Boo var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(book.CoverImagePath) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collections.templ`, Line: 202, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collections.templ`, Line: 199, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -326,46 +326,7 @@ func CollectionDetail(user User, collection CollectionData, books []handlers.Boo return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

Add Books to Collection

Search and select books to add to this collection.

Add Books to Collection

books selected
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

Add Books to Collection

books selected
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }