preparing search in stock items

This commit is contained in:
2025-12-03 09:34:46 +01:00
parent fdffad6022
commit 4cb9c6bd2f
4 changed files with 61 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
<script>
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api, target } from '../../urls.svelte.js';
import { api, post, target } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
import { display } from '../../time.svelte';
@@ -18,6 +18,7 @@
let notes = $state(null);
let pages = $state(null);
let projects = $state(null);
let stock = $state(null);
let tasks = $state(null);
let times = $state(null);
@@ -38,19 +39,16 @@
window.history.replaceState(history.state, '', url);
const data = { key : key, fulltext : fulltext };
const options = {
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
};
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);
fetch(api('time/search'),options).then(handleTimes);
fetch(api('wiki/search'),options).then(handleWikiPages);
post(api('bookmark/search'),data).then(handleBookmarks);
post(api('company/search '),data).then(handleCompanies);
post(api('document/search'),data).then(handleDocuments);
post(api('notes/search' ),data).then(handleNotes);
post(api('project/search' ),data).then(handleProjects);
post(api('task/search' ),data).then(handleTasks);
post(api('stock/search' ),data).then(handleStock);
post(api('time/search' ),data).then(handleTimes);
post(api('wiki/search' ),data).then(handleWikiPages);
}
function onclick(e){
@@ -107,6 +105,15 @@
}
}
async function handleStock(resp){
if (resp.ok){
const res = await resp.json();
stock = Object.keys(res).length ? res : null;
} else {
error(resp);
}
}
async function handleTasks(resp){
if (resp.ok){
const res = await resp.json();