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 ++++++++--------------------- web/templates/index.html | 16 ++++++++++++---- web/templates/partials/conditions-tab.html | 6 +++++- web/templates/partials/meals-tab.html | 6 +++++- web/templates/partials/shopping-tab.html | 6 +++++- 5 files changed, 35 insertions(+), 28 deletions(-) (limited to 'web') 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); } diff --git a/web/templates/index.html b/web/templates/index.html index 7e9a38f..9c90570 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -38,10 +38,18 @@ {{.LastUpdated.Format "3:04 PM"}} -
- - -
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/partials/conditions-tab.html b/web/templates/partials/conditions-tab.html index 94c2f99..3ded125 100644 --- a/web/templates/partials/conditions-tab.html +++ b/web/templates/partials/conditions-tab.html @@ -1,5 +1,9 @@ {{define "conditions-tab"}} -
+

diff --git a/web/templates/partials/meals-tab.html b/web/templates/partials/meals-tab.html index 5900368..97c3a4e 100644 --- a/web/templates/partials/meals-tab.html +++ b/web/templates/partials/meals-tab.html @@ -1,5 +1,9 @@ {{define "meals-tab"}} -
+
{{template "plantoeat-meals" .}}
diff --git a/web/templates/partials/shopping-tab.html b/web/templates/partials/shopping-tab.html index 345549b..e3742d9 100644 --- a/web/templates/partials/shopping-tab.html +++ b/web/templates/partials/shopping-tab.html @@ -1,5 +1,9 @@ {{define "shopping-tab"}} -
+
-- cgit v1.2.3