Browse Source

accomplished direct linking of items

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
module/stock
Stephan Richter 5 days ago
parent
commit
57a18b5957
  1. 40
      frontend/src/routes/stock/Index.svelte
  2. 3
      stock/src/main/java/de/srsoftware/umbrella/stock/StockModule.java

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

@ -18,17 +18,22 @@ @@ -18,17 +18,22 @@
let draggedItem = $state(null)
let draggedLocation = $state(null)
let { item_id, location_id, owner, owner_id } = $props();
let skip_location = false; // disable effect on setting location within loadItem()
$effect(() => {
// This effect runs whenever `location` changes
if (location !== null) {
if (!skip_location && location !== null) {
item = null;
setLocationUrl();
}
});
$effect(() => {
if (item !== null) setItemUrl();
// This effect runs whenever `item` changes
if (item !== null) {
setItemUrl();
skip_location = false;
}
});
let properties = $state(null);
let top_level = $state(null);
@ -96,6 +101,27 @@ @@ -96,6 +101,27 @@
if (!item_id) return;
const url = api(`stock/${owner}/${owner_id}/item/${item_id}`);
const res = await get(url);
if (res.ok){
yikes();
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;
skip_location = true;
location = json.location;
break;
}
}
}
for (let i of json.items){
if (i.owner_number == +item_id) item = i;
}
} else {
error(res);
return null;
}
}
async function loadPath(){
@ -146,9 +172,9 @@ @@ -146,9 +172,9 @@
async function load(){
await loadUserLocations();
loadItem();
loadPath();
loadProperties();
await loadPath();
await loadProperties();
await loadItem();
}
function moveToTop(loc){
@ -240,7 +266,7 @@ @@ -240,7 +266,7 @@
<div class="properties">
<ItemProps {item} {properties} />
</div>
{#if item}
{#if item && data && data.users}
<div class="tags">
<span>{t('tags')}</span>
<Tags module="stock" id={item.id} user_list={data.users} />
@ -255,6 +281,6 @@ @@ -255,6 +281,6 @@
<div>
<pre>
{JSON.stringify({owner,owner_id,item_id},null,2)}
{JSON.stringify({item_id,location},null,2)}
</pre>
</div>

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

@ -181,8 +181,7 @@ public class StockModule extends BaseHandler implements StockService { @@ -181,8 +181,7 @@ public class StockModule extends BaseHandler implements StockService {
try {
var itemId = Long.parseLong(path.pop());
var item = stockDb.loadItem(owner.dbCode(),itemId);
stockDb.loadProperties(item);
yield sendContent(ex,item);
yield getLocationEntities(item.location(),ex);
} catch (NumberFormatException e) {
yield super.doGet(path,ex);
}

Loading…
Cancel
Save