refactor(collections): remove dead Alpine.js exports and DOMContentLoaded listeners
- Remove DOMContentLoaded listeners for setupHTMXAuth, initColorSelection, and setupHTMXModalInit
- Delete dead Alpine.data exports: addbooksToAdd, removebooksToAdd, toggleBookForRemoval,
toggleBookSelection, initCollectionDetail, initIconSelection, initColorSelection
- Add missing setupHTMXAuth to export statement (it was called but not exported)
- Remove 14 lines of auto-initialization code that's no longer needed
This fixes "X is not defined" console errors for functions that were deleted
in commit 93710a1 but were still in Alpine.data export. The collections.templ template
was also updated to remove calls to these deleted functions.
These changes align with the SSR architecture where most collection functionality
is server-rendered and client-side JavaScript is used sparingly.
This commit is contained in:
+1
-19
@@ -199,12 +199,6 @@ function setupHTMXAuth(): void {
|
||||
(evt as any).detail.headers["Authorization"] = `Bearer ${token}`;
|
||||
});
|
||||
}
|
||||
// Auto-initialize HTMX auth when DOM is ready
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", setupHTMXAuth);
|
||||
} else {
|
||||
setupHTMXAuth();
|
||||
}
|
||||
|
||||
function navigateToCollection(element: HTMLElement): void {
|
||||
// Check if the click target is a button
|
||||
@@ -288,13 +282,6 @@ function initColorSelection(): void {
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-initialize when DOM is ready
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", initColorSelection);
|
||||
} else {
|
||||
initColorSelection();
|
||||
}
|
||||
|
||||
// Initialize icon grid when modal is loaded via HTMX
|
||||
function setupHTMXModalInit(): void {
|
||||
document.body.addEventListener("htmx:afterSwap", function (evt: Event) {
|
||||
@@ -304,12 +291,6 @@ function setupHTMXModalInit(): void {
|
||||
}
|
||||
});
|
||||
}
|
||||
// Auto-initialize when DOM is ready
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", setupHTMXModalInit);
|
||||
} else {
|
||||
setupHTMXModalInit();
|
||||
}
|
||||
|
||||
// Icon data with keywords (single source of truth)
|
||||
const iconData: Record<string, string[]> = {
|
||||
@@ -446,6 +427,7 @@ export {
|
||||
selectIcon,
|
||||
showAddBooksModal,
|
||||
showAllIcons,
|
||||
setupHTMXAuth,
|
||||
testRule,
|
||||
toggleBookForRemoval,
|
||||
toggleBookSelection,
|
||||
|
||||
Reference in New Issue
Block a user