finished location tree
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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} />
|
||||
|
||||
Reference in New Issue
Block a user