Implement tag management with SQLite; update save and retrieve endpoints

This commit is contained in:
2025-02-02 19:17:35 +01:00
parent c98aea1b06
commit 37a7e5e67a
4 changed files with 80 additions and 23 deletions

View File

@@ -56,7 +56,7 @@
<label for="time">Tid (valfritt)</label>
</div>
<div class="input-field">
<input type="text" id="tags" placeholder="Taggar">
<input type="text" id="tags" placeholder="Taggar" autocomplete="off">
<label for="tags">Taggar</label>
</div>
<button class="btn waves-effect waves-light" type="submit">Spara uppgift</button>

View File

@@ -1,10 +1,13 @@
export function saveTags(tags) {
export async function saveTags(newTags) {
const existingTags = await loadTags();
const allTags = Array.from(new Set([...existingTags, ...newTags]));
return fetch('/save-tags', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ tags })
body: JSON.stringify({ tags: allTags })
});
}