implemented search in wiki pages
This commit is contained in:
@@ -7,18 +7,19 @@
|
||||
|
||||
import Bookmark from '../bookmark/Template.svelte';
|
||||
|
||||
const router = useTinyRouter();
|
||||
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'));
|
||||
let input = $state(router.getQueryParam('key'));
|
||||
let notes = $state(null);
|
||||
let projects = $state(null);
|
||||
let tasks = $state(null);
|
||||
let times = $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 pages = $state(null);
|
||||
let projects = $state(null);
|
||||
let tasks = $state(null);
|
||||
let times = $state(null);
|
||||
|
||||
async function setKey(ev){
|
||||
if (ev) ev.preventDefault();
|
||||
@@ -49,6 +50,7 @@
|
||||
fetch(api('project/search'),options).then(handleProjects);
|
||||
fetch(api('task/search'),options).then(handleTasks);
|
||||
fetch(api('time/search'),options).then(handleTimes);
|
||||
fetch(api('wiki/search'),options).then(handleWikiPages);
|
||||
}
|
||||
|
||||
function onclick(e){
|
||||
@@ -122,6 +124,15 @@
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleWikiPages(resp){
|
||||
if (resp.ok){
|
||||
const res = await resp.json();
|
||||
pages = Object.keys(res).length ? res : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => doSearch(key))
|
||||
</script>
|
||||
@@ -260,3 +271,19 @@
|
||||
</ul>
|
||||
</fieldset>
|
||||
{/if}
|
||||
{#if pages}
|
||||
<fieldset>
|
||||
<legend>
|
||||
{t('wiki_pages')}
|
||||
</legend>
|
||||
<ul>
|
||||
{#each Object.values(pages) as page}
|
||||
<li>
|
||||
<a href="/wiki/{page.id}/view" {onclick} >
|
||||
{page.title}
|
||||
</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user