implemented save on empty tag commit

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-04-14 23:22:27 +02:00
parent d058fd2e57
commit 0231f965f3
3 changed files with 16 additions and 11 deletions
@@ -42,6 +42,7 @@
}
async function getAccountTags(text){
if (!text) return [];
var url = api(`accounting/${entry.account.id}/tags`)
return await getTerminal(text,url);
}
@@ -141,7 +142,7 @@
<Autocomplete bind:candidate={entry.purpose} getCandidates={getPurposes} />
<span>{t('tags')}</span>
<Tags getCandidates={getAccountTags} module={null} bind:tags={entry.tags} />
<Tags getCandidates={getAccountTags} module={null} bind:tags={entry.tags} onEmptyCommit={save} />
<span></span>
<span>
@@ -21,16 +21,17 @@
}
async function getCandidates(key){
if (!key) return;
var url = api(`accounting/${account.id}/tags`)
var res = await post(url,key);
if (res.ok){
yikes();
const input = await res.json();
return Object.values(input).map(mapDisplay);
} else {
error(res);
return {};
}
if (res.ok){
yikes();
const input = await res.json();
return Object.values(input).map(mapDisplay);
} else {
error(res);
return {};
}
}
function mapDisplay(object){
+4 -1
View File
@@ -13,6 +13,7 @@
id = null,
getCandidates = getCandidateTags,
module,
onEmptyCommit = () => {},
tags = $bindable([]),
user_list = [],
} = $props();
@@ -89,7 +90,9 @@
}
async function onCommit(wrapped){
addTag(wrapped.display);
if (!wrapped.display) {
onEmptyCommit();
} else addTag(wrapped.display);
}
function onSelect(dummy){}