finished location tree

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-13 17:02:09 +02:00
parent 2cd022451a
commit 26d2f7c1f4
8 changed files with 60 additions and 15 deletions

View File

@@ -1,9 +1,25 @@
<script>
import { t } from '../../translations.svelte';
import { api } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
let { locations } = $props();
console.log(locations);
async function toggleChildren(ev, location){
ev.preventDefault();
ev.stopPropagation();
if (location.locations) {
delete location.locations;
} else {
const url = api(`stock/locations/below/${location.id}`);
const res = await fetch(url,{credentials:'include'});
if (res.ok){
yikes();
location.locations = await res.json();
} else error(res);
}
return false;
}
</script>
<ul>
@@ -13,7 +29,7 @@
</a>
</li>
{#each locations as location}
<li>
<li onclick={e => toggleChildren(e, location)} class={location.locations?'expanded':'collapsed'}>
{location.name}
{#if location.locations}
<svelte:self locations={location.locations} />