working on loading item by id
This commit is contained in:
@@ -103,7 +103,8 @@
|
||||
<Route path="/search" component={Search} />
|
||||
<Route path="/stock" component={Stock} />
|
||||
<Route path="/stock/location/:location_id" component={Stock} />
|
||||
<Route path="/stock/:owner/:owner_id/item/:item_id" component={Stock} />
|
||||
<Route path="/stock/item/:item_id/view" component={Stock} />
|
||||
<Route path="/stock/:owner/:owner_id/item/:owner_number" component={Stock} />
|
||||
<Route path="/tags" component={TagList} />
|
||||
<Route path="/tags/use/:tag" component={TagUses} />
|
||||
<Route path="/task" component={TaskList} />
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
let location = $state(null);
|
||||
let draggedItem = $state(null)
|
||||
let draggedLocation = $state(null)
|
||||
let { item_id, location_id, owner, owner_id } = $props();
|
||||
let { item_id, location_id, owner, owner_id, owner_number } = $props();
|
||||
let skip_location = false; // disable effect on setting location within loadItem()
|
||||
|
||||
$effect(() => {
|
||||
@@ -98,8 +98,8 @@
|
||||
}
|
||||
|
||||
async function loadItem(){
|
||||
if (!item_id) return;
|
||||
const url = api(`stock/${owner}/${owner_id}/item/${item_id}`);
|
||||
if (!item_id && !owner_number) return;
|
||||
const url = item_id ? api(`stock/item/${item_id}`) : api(`stock/${owner}/${owner_id}/item/${owner_number}`);
|
||||
const res = await get(url);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
@@ -116,7 +116,7 @@
|
||||
}
|
||||
}
|
||||
for (let i of json.items){
|
||||
if (i.owner_number == +item_id) item = i;
|
||||
if (i.owner_number == +owner_number) item = i;
|
||||
}
|
||||
} else {
|
||||
error(res);
|
||||
|
||||
@@ -74,6 +74,15 @@ Code: <LineEditor type="span" editable={true} value={item.code} onSet={v => patc
|
||||
</div>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
{t('ID')}
|
||||
</td>
|
||||
<td>
|
||||
{item.id}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{#each item.properties.toSorted(byName) as prop}
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user