Browse Source

implemented references to locations

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
module/stock
Stephan Richter 1 week ago
parent
commit
a4488a2fae
  1. 19
      frontend/src/routes/stock/Index.svelte
  2. 2
      stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java
  3. 2
      stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java

19
frontend/src/routes/stock/Index.svelte

@ -98,8 +98,17 @@
const res = await get(url); const res = await get(url);
if (res.ok){ if (res.ok){
yikes(); yikes();
var path = res.json(); const json = await res.json();
const path = json.path;
for (let owner of top_level){
for (let loc of owner.locations){
if (loc.id == path.id) {
loc.locations = path.locations;
location = json.location;
break;
}
}
}
} else { } else {
error(res); error(res);
return null; return null;
@ -129,8 +138,8 @@
} else error(res); } else error(res);
} }
function load(){ async function load(){
loadUserLocations(); await loadUserLocations();
loadPath(); loadPath();
loadProperties(); loadProperties();
} }
@ -235,4 +244,4 @@
</div> </div>
{/if} {/if}
{/await} {/await}
</div> </div>

2
stock/src/main/java/de/srsoftware/umbrella/stock/SqliteDb.java

@ -300,7 +300,7 @@ public class SqliteDb extends BaseDb implements StockDb {
var current = new HashMap<String,Object>(); var current = new HashMap<String,Object>();
current.put(NAME,parent.name()); current.put(NAME,parent.name());
current.put(ID,parent.id()); current.put(ID,parent.id());
current.put(PATH,root); current.put(LOCATIONS,List.of(root));
root = current; root = current;
location = parent; location = parent;
} }

2
stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java

@ -166,7 +166,7 @@ public class StockModule extends BaseHandler implements StockService {
case null, default -> throw unprocessable("Unprocessable owner type: {0}",owner.type()); case null, default -> throw unprocessable("Unprocessable owner type: {0}",owner.type());
}; };
var pathToLocation = stockDb.pathToLocation(location); var pathToLocation = stockDb.pathToLocation(location);
return sendContent(ex,Map.of(ITEMS,items,USERS,userIds,PATH,pathToLocation)); return sendContent(ex,Map.of(ITEMS,items,USERS,userIds,PATH,pathToLocation,LOCATION,location.resolve().toMap()));
} }
private boolean getLocations(Path path, UmbrellaUser user, HttpExchange ex) throws IOException { private boolean getLocations(Path path, UmbrellaUser user, HttpExchange ex) throws IOException {

Loading…
Cancel
Save