mirror of
https://github.com/trevor1969/teatracker.git
synced 2026-08-09 10:41:59 +00:00
feat: Add tea powder amount (teaspoons) to tracking
- 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 <trevor1969@users.noreply.github.com>
This commit is contained in:
17
app.js
17
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 {
|
||||
<div class="activity-tea">${tea ? tea.name : 'Unbekannter Tee'} ${tea && tea.organic ? '<span class="organic-badge" title="Bio-Tee">🌱</span>' : ''}</div>
|
||||
<div class="activity-details">${formattedDate} ${formattedTime ? `um ${formattedTime}` : ''}</div>
|
||||
</div>
|
||||
<div class="activity-amount">${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}</div>
|
||||
<div class="activity-amount">${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}${entry.teaspoons ? ` (${entry.teaspoons} TL)` : ''}</div>
|
||||
</div>
|
||||
`;
|
||||
}).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 {
|
||||
<div class="activity-tea">${tea ? tea.name : 'Unbekannter Tee'} ${tea && tea.organic ? '<span class="organic-badge" title="Bio-Tee">🌱</span>' : ''}</div>
|
||||
<div class="activity-details">${formattedDate} ${formattedTime ? `um ${formattedTime}` : ''}</div>
|
||||
</div>
|
||||
<div class="activity-amount">${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}</div>
|
||||
<div class="activity-amount">${entry.amount} Tasse${entry.amount > 1 ? 'n' : ''}${entry.teaspoons ? ` (${entry.teaspoons} TL)` : ''}</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
Reference in New Issue
Block a user