From 2eb2bb25aa7b112f0f0bd5f9a1776dec85de520c Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 17 Oct 2025 15:58:29 +0200 Subject: [PATCH] working on new location creation --- frontend/src/routes/stock/Index.svelte | 2 +- frontend/src/routes/stock/Locations.svelte | 40 +++++++++++++++++-- .../umbrella/stock/StockModule.java | 4 +- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/frontend/src/routes/stock/Index.svelte b/frontend/src/routes/stock/Index.svelte index 577f669..a63990c 100644 --- a/frontend/src/routes/stock/Index.svelte +++ b/frontend/src/routes/stock/Index.svelte @@ -76,7 +76,7 @@ {#each top_level as realm,idx}

{realm.name}

{#if realm.locations} - + {/if} {/each} {/if} diff --git a/frontend/src/routes/stock/Locations.svelte b/frontend/src/routes/stock/Locations.svelte index b3e802e..a2d1435 100644 --- a/frontend/src/routes/stock/Locations.svelte +++ b/frontend/src/routes/stock/Locations.svelte @@ -3,7 +3,12 @@ import { error, yikes } from '../../warn.svelte'; import { t } from '../../translations.svelte'; - let { locations, selected = $bindable(null) } = $props(); + import LineEditor from '../../Components/LineEditor.svelte'; + + let { locations, parent = null, selected = $bindable(null) } = $props(); + + let show_location_form = $state(false); + let new_location_name = $state(null); async function toggleChildren(ev, location){ ev.preventDefault(); @@ -21,20 +26,47 @@ } return false; } + + function onsubmit(ev){ + ev.preventDefault(); + ev.stopPropagation(); + + const data = { + name: new_location_name, + parent: parent.user ? {user:parent.user} : {company:parent.company} + } + + console.log(data); + } + + function show_loc_form(ev){ + ev.preventDefault(); + ev.stopPropagation(); + show_location_form = true; + return false; + } \ No newline at end of file + + \ No newline at end of file diff --git a/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java b/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java index 364e4b7..5c2894f 100644 --- a/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java +++ b/stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java @@ -136,7 +136,7 @@ public class StockModule extends BaseHandler implements StockService { var result = new ArrayList(); var userLocations = stockDb.listUserLocations(user); result.add(Map.of( - ID, user.id(), + USER, user.id(), NAME,user.name(), LOCATIONS,userLocations.stream().map(DbLocation::toMap).toList())); @@ -144,7 +144,7 @@ public class StockModule extends BaseHandler implements StockService { companies.values().stream().sorted(comparing(a -> a.name().toLowerCase())).forEach(company -> { var locations = stockDb.listCompanyLocations(company); result.add(Map.of( - ID, company.id(), + COMPANY, company.id(), NAME,company.name(), LOCATIONS,locations.stream().sorted(comparing(a -> a.name().toLowerCase())).map(DbLocation::toMap).toList()));