extended search to projects

This commit is contained in:
2025-08-19 09:53:17 +02:00
parent dbc091cc3c
commit 990e8253e2
5 changed files with 75 additions and 16 deletions

View File

@@ -13,6 +13,7 @@
let fulltext = false;
let key = $state(router.getQueryParam('key'));
let input = $state(router.getQueryParam('key'));
let projects = $state(null);
let tasks = $state(null);
async function setKey(ev){
@@ -38,6 +39,7 @@
body: JSON.stringify(data)
};
fetch(api('bookmark/search'),options).then(handleBookmarks);
fetch(api('project/search'),options).then(handleProjects);
fetch(api('task/search'),options).then(handleTasks);
}
@@ -55,6 +57,15 @@
}
}
async function handleProjects(resp){
if (resp.ok){
const res = await resp.json();
projects = Object.keys(res).length ? res : null;
} else {
error = await resp.text();
}
}
async function handleTasks(resp){
if (resp.ok){
const res = await resp.json();
@@ -85,6 +96,20 @@
<button type="submit">{t('go')}</button>
</form>
</fieldset>
{#if projects}
<fieldset>
<legend>
{t('projects')}
</legend>
<ul>
{#each Object.values(projects) as project}
<li>
<a href="#" onclick={e=>go(`/project/${project.id}/view`)} >{project.name}</a>
</li>
{/each}
</ul>
</fieldset>
{/if}
{#if tasks}
<fieldset>
<legend>