refactor: Convert template event handlers to Alpine.js
Converted all inline onclick/onsubmit handlers to Alpine.js @click/@submit directives and added x-data attributes to template body tags. Templates updated: - admin.templ: Added x-data="admin", converted scan/hide buttons - analytics.templ: Added x-data, converted loadAnalytics button - api_explorer.templ: Added x-data for API explorer page - bookshelf.templ: Added x-data, converted library/pagination handlers - collection_modal.templ: Added x-data for modal components - collection_rules.templ: Added x-data, converted all rule handlers - collections.templ: Added x-data, converted navigation/book handlers - conflicts.templ: Added x-data, converted resolve/dismiss handlers - header.templ: Converted theme dropdown and user menu handlers - index.templ: Added x-data for theme/auth - login.templ: Added x-data for theme switching - profile.templ: Added x-data, converted delete account - profile_form.templ: Converted modal close handler - profile_modal.templ: Added x-data for modal - progress.templ: Removed script (uses header.logout) - queue.templ: Added x-data, converted queue handlers - register.templ: Added x-data for theme - restore_system_collection_modal.templ: Added x-data - toast.templ: Converted to x-init with Alpine - unlinked_books.templ: Added x-data for bulk operations Dynamic content in devices.templ uses event delegation via data attributes.
This commit is contained in:
+1
-28
@@ -2,33 +2,6 @@ package templates
|
||||
|
||||
templ ErrorToast(message string) {
|
||||
if message != "" {
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Show error toast with 8 second auto-dismiss
|
||||
window.showToast.error('{ message }', 8000);
|
||||
|
||||
// Add retry button to the toast
|
||||
setTimeout(function() {
|
||||
const toastContainer = document.getElementById('toast-container');
|
||||
if (toastContainer && toastContainer.lastElementChild) {
|
||||
const toast = toastContainer.lastElementChild;
|
||||
const retryBtn = document.createElement('button');
|
||||
retryBtn.className = 'ml-4 px-3 py-1 bg-white/20 hover:bg-white/30 rounded text-sm font-medium transition-colors';
|
||||
retryBtn.textContent = 'Retry';
|
||||
retryBtn.onclick = function() {
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
// Insert before the close button
|
||||
const closeBtn = toast.querySelector('.toast-close');
|
||||
if (closeBtn) {
|
||||
closeBtn.parentElement.insertBefore(retryBtn, closeBtn);
|
||||
} else {
|
||||
toast.appendChild(retryBtn);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
<div x-data="toastError" x-init="showErrorToast('{ message }')"></div>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user