From 27ee1a271248e9f1de8ecb981a6cabfa8e498b1b Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Fri, 6 Feb 2026 14:53:47 -1000 Subject: Fix missing settings button, disappeared events, and tab refresh bug - Add settings gear icon link to dashboard header - Fix GetTasksByDateRange/GetCardsByDateRange to include overdue items (changed from BETWEEN to <= end, filter completed tasks) - Fix refresh replacing active tab with tasks tab by using htmx.trigger(body, 'refresh-tasks') instead of innerHTML+htmx.process - Add refresh-tasks hx-trigger to meals, shopping, conditions tabs - Add tests for overdue inclusion/exclusion, settings link, template data Co-Authored-By: Claude Opus 4.6 --- web/static/js/app.js | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'web/static') diff --git a/web/static/js/app.js b/web/static/js/app.js index 5dffacc..954dc8c 100644 --- a/web/static/js/app.js +++ b/web/static/js/app.js @@ -218,16 +218,9 @@ async function refreshData() { if (!refreshResponse.ok) throw new Error('Refresh failed'); - // Reload current tab from cache - const tabResponse = await fetch(`/tabs/${currentTab}`); - - if (!tabResponse.ok) throw new Error('Tab reload failed'); - - // Get HTML response and update tab content - const html = await tabResponse.text(); - const tabContent = document.getElementById('tab-content'); - tabContent.innerHTML = html; - htmx.process(tabContent); + // Trigger HTMX refresh on the current tab — each tab template + // has hx-trigger="refresh-tasks from:body" to handle its own reload + htmx.trigger(document.body, 'refresh-tasks'); // Update timestamp updateLastUpdatedTime(); @@ -275,17 +268,11 @@ async function autoRefresh() { if (!refreshResponse.ok) throw new Error('Refresh failed'); - // Reload current tab from cache - const tabResponse = await fetch(`/tabs/${currentTab}`); - - if (tabResponse.ok) { - const html = await tabResponse.text(); - const tabContent = document.getElementById('tab-content'); - tabContent.innerHTML = html; - htmx.process(tabContent); - updateLastUpdatedTime(); - console.log('Auto-refresh successful'); - } + // Trigger HTMX refresh on the current tab — each tab template + // has hx-trigger="refresh-tasks from:body" to handle its own reload + htmx.trigger(document.body, 'refresh-tasks'); + updateLastUpdatedTime(); + console.log('Auto-refresh successful'); } catch (error) { console.error('Auto-refresh failed:', error); } -- cgit v1.2.3