accomplished direct linking of items
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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 @@
|
||||
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 @@
|
||||
|
||||
async function load(){
|
||||
await loadUserLocations();
|
||||
loadItem();
|
||||
loadPath();
|
||||
loadProperties();
|
||||
await loadPath();
|
||||
await loadProperties();
|
||||
await loadItem();
|
||||
}
|
||||
|
||||
function moveToTop(loc){
|
||||
@@ -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 @@
|
||||
|
||||
<div>
|
||||
<pre>
|
||||
{JSON.stringify({owner,owner_id,item_id},null,2)}
|
||||
{JSON.stringify({item_id,location},null,2)}
|
||||
</pre>
|
||||
</div>
|
||||
Reference in New Issue
Block a user