implemented seach in documents

This commit is contained in:
2025-09-03 14:41:10 +02:00
parent d3c63fadff
commit 379d156fd2
4 changed files with 118 additions and 49 deletions

View File

@@ -10,6 +10,7 @@
const router = useTinyRouter();
let bookmarks = $state(null);
let companies = $state(null);
let documents = $state(null);
let error = $state(null);
let fulltext = false;
let key = $state(router.getQueryParam('key'));
@@ -43,6 +44,7 @@
};
fetch(api('bookmark/search'),options).then(handleBookmarks);
fetch(api('company/search'),options).then(handleCompanies);
fetch(api('document/search'),options).then(handleDocuments);
fetch(api('notes/search'),options).then(handleNotes);
fetch(api('project/search'),options).then(handleProjects);
fetch(api('task/search'),options).then(handleTasks);
@@ -76,6 +78,15 @@
}
}
async function handleDocuments(resp){
if (resp.ok){
const json = await resp.json();
documents = Object.keys(json).length ? json : null;
} else {
error = await resp.text();
}
}
async function handleNotes(resp){
if (resp.ok){
const json = await resp.json();
@@ -212,7 +223,7 @@
{#if times}
<fieldset>
<legend>
{t('timetracks')}
{t('timetracking')}
</legend>
<ul>
{#each Object.values(times) as time}
@@ -227,3 +238,23 @@
</ul>
</fieldset>
{/if}
{#if documents}
<fieldset>
<legend>
{t('documents')}
</legend>
<ul>
{#each Object.values(documents) as document}
<li>
<a href="/document/{document.id}/view" {onclick} >
{document.number}
({document.date})
{document.sender.name.split('\n')[0]}
{document.customer.name.split('\n')[0]}
</a>
</li>
{/each}
</ul>
</fieldset>
{/if}