implemented search within time tracks

This commit is contained in:
2025-09-03 08:47:18 +02:00
parent bee33e84a0
commit d3c63fadff
4 changed files with 108 additions and 47 deletions

View File

@@ -3,6 +3,7 @@
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import { display } from '../../time.svelte';
import Bookmark from '../bookmark/Template.svelte';
@@ -16,6 +17,7 @@
let notes = $state(null);
let projects = $state(null);
let tasks = $state(null);
let times = $state(null);
async function setKey(ev){
if (ev) ev.preventDefault();
@@ -44,6 +46,7 @@
fetch(api('notes/search'),options).then(handleNotes);
fetch(api('project/search'),options).then(handleProjects);
fetch(api('task/search'),options).then(handleTasks);
fetch(api('time/search'),options).then(handleTimes);
}
function onclick(e){
@@ -100,6 +103,15 @@
}
}
async function handleTimes(resp){
if (resp.ok){
const res = await resp.json();
times = Object.keys(res).length ? res : null;
} else {
error = await resp.text();
}
}
$effect(() => doSearch(key))
</script>
@@ -197,3 +209,21 @@
</ul>
</fieldset>
{/if}
{#if times}
<fieldset>
<legend>
{t('timetracks')}
</legend>
<ul>
{#each Object.values(times) as time}
<li>
<a href="/time/{time.id}/view" {onclick} >
{display(time.start_time)}{#if time.end_time}{display(time.end_time)}{/if}
{time.subject}<br/>
{@html time.description.rendered}
</a>
</li>
{/each}
</ul>
</fieldset>
{/if}