implemented searching in notes

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-02 22:46:11 +02:00
parent cff4360a37
commit bee33e84a0
5 changed files with 77 additions and 13 deletions

View File

@@ -7,13 +7,13 @@
import Bookmark from '../bookmark/Template.svelte';
const router = useTinyRouter();
console.log(router);
let bookmarks = $state(null);
let companies = $state(null);
let error = $state(null);
let fulltext = false;
let key = $state(router.getQueryParam('key'));
let input = $state(router.getQueryParam('key'));
let notes = $state(null);
let projects = $state(null);
let tasks = $state(null);
@@ -41,12 +41,17 @@
};
fetch(api('bookmark/search'),options).then(handleBookmarks);
fetch(api('company/search'),options).then(handleCompanies);
fetch(api('notes/search'),options).then(handleNotes);
fetch(api('project/search'),options).then(handleProjects);
fetch(api('task/search'),options).then(handleTasks);
}
function go(path){
router.navigate(path);
function onclick(e){
e.preventDefault();
var target = e.target;
while (target && !target.href) target=target.parentNode;
let href = target.getAttribute('href');
if (href) router.navigate(href);
return false;
}
@@ -68,6 +73,15 @@
}
}
async function handleNotes(resp){
if (resp.ok){
const json = await resp.json();
notes = Object.keys(json).length ? json : null;
} else {
error = await resp.text();
}
}
async function handleProjects(resp){
if (resp.ok){
const res = await resp.json();
@@ -118,7 +132,7 @@
<ul>
{#each Object.values(projects) as project}
<li>
<a href="#" onclick={e=>go(`/project/${project.id}/view`)} >{project.name}</a>
<a href="/project/{project.id}/view" {onclick} >{project.name}</a>
</li>
{/each}
</ul>
@@ -132,7 +146,7 @@
<ul>
{#each Object.values(tasks) as task}
<li>
<a href="#" onclick={e=>go(`/task/${task.id}/view`)} >{task.name}</a>
<a href="/task/{task.id}/view" {onclick} >{task.name}</a>
</li>
{/each}
</ul>
@@ -160,7 +174,24 @@
<ul>
{#each Object.values(companies) as company}
<li>
<a href="#" onclick={e=>go(`/company/${company.id}/view`)} >{company.name}</a>
<a href="/company/{company.id}/view" {onclick} >{company.name}</a>
</li>
{/each}
</ul>
</fieldset>
{/if}
{#if notes}
<fieldset>
<legend>
{t('notes')}
</legend>
<ul>
{#each Object.values(notes) as note}
<li>
<a href="/{note.module}/{note.entity_id}/view" {onclick} >
<b>{t(note.module)} {note.entity_id}:</b>
{@html note.text.rendered}
</a>
</li>
{/each}
</ul>