From 394480c5168d5fe9a85b732ac99bb571bed60860 Mon Sep 17 00:00:00 2001 From: Vibe Nuage Agent Date: Thu, 4 Jun 2026 16:53:24 +0000 Subject: [PATCH] feat: Add tea powder amount (teaspoons) to tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add new field 'Menge Tee-Pulver (Teelöffel)' to track form - Add teaspoons property to entry data model - Update addEntry() to include teaspoons (default: 1) - Update handleTrackFormSubmit() to read teaspoons from form - Display teaspoons in recent entries (e.g., '2 Tassen (1.5 TL)') - Add migration for existing entries without teaspoons field - Input allows decimal values (step=0.5) for half teaspoons Co-authored-by: trevor1969 --- app.js | 17 +++++++++++++---- index.html | 5 +++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 2336156..f2eb0e5 100644 --- a/app.js +++ b/app.js @@ -288,7 +288,10 @@ class TeeTracker { } if (entries) { - this.entries = entries; + this.entries = entries.map(entry => ({ + ...entry, + teaspoons: entry.teaspoons !== undefined ? entry.teaspoons : 1 + })); } // If Nextcloud loading failed, fall back to localStorage @@ -318,7 +321,10 @@ class TeeTracker { if (entriesData) { try { - this.entries = JSON.parse(entriesData); + this.entries = JSON.parse(entriesData).map(entry => ({ + ...entry, + teaspoons: entry.teaspoons !== undefined ? entry.teaspoons : 1 + })); } catch (error) { this.entries = []; } @@ -452,6 +458,7 @@ class TeeTracker { date: entry.date, time: entry.time || '', amount: parseInt(entry.amount) || 1, + teaspoons: entry.teaspoons ? parseFloat(entry.teaspoons) : 1, notes: entry.notes || '', createdAt: new Date().toISOString() }; @@ -1207,7 +1214,7 @@ class TeeTracker {
${tea ? tea.name : 'Unbekannter Tee'} ${tea && tea.organic ? '🌱' : ''}
${formattedDate} ${formattedTime ? `um ${formattedTime}` : ''}
-
${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}
+
${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}${entry.teaspoons ? ` (${entry.teaspoons} TL)` : ''}
`; }).join(''); @@ -1454,6 +1461,7 @@ class TeeTracker { const date = document.getElementById('track-date').value; const time = document.getElementById('track-time').value; const amount = document.getElementById('track-amount').value; + const teaspoons = document.getElementById('track-teaspoons').value; const notes = document.getElementById('track-notes').value.trim(); if (!teaId || !date || !amount) { @@ -1466,6 +1474,7 @@ class TeeTracker { date, time, amount, + teaspoons, notes }; @@ -1521,7 +1530,7 @@ class TeeTracker {
${tea ? tea.name : 'Unbekannter Tee'} ${tea && tea.organic ? '🌱' : ''}
${formattedDate} ${formattedTime ? `um ${formattedTime}` : ''}
-
${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}
+
${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}${entry.teaspoons ? ` (${entry.teaspoons} TL)` : ''}
`; }).join(''); diff --git a/index.html b/index.html index 70b7100..f9f391b 100644 --- a/index.html +++ b/index.html @@ -101,6 +101,11 @@ +
+ + +
+