working on adding new properties to existing items

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-15 00:21:08 +02:00
parent 48128c5bf4
commit 846ef4a27a
9 changed files with 191 additions and 57 deletions

View File

@@ -17,7 +17,7 @@
async function loadItems(){
if (!location) return null;
const url = api(`stock/items_at/${location.id}`)
const url = api(`stock/location/${location.id}`)
const res = await fetch(url,{credentials:'include'});
if (res.ok){
yikes();
@@ -28,7 +28,19 @@
}
}
async function load(){
async function loadProperties(){
const url = api('stock/properties')
const res = await fetch(url,{credentials:'include'});
if (res.ok){
var json = await res.json();
var dict = {}
for (var entry of json.sort((a,b) => b.id - a.id)) dict[entry.name+'.'+entry.unit] = entry;
properties = Object.values(dict).sort((a,b) => a.name.localeCompare(b.name));
yikes();
} else error(res);
}
async function loadUserLocations(){
const url = api('stock/locations/of_user')
const res = await fetch(url,{credentials:'include'});
if (res.ok){
@@ -37,6 +49,11 @@
} else error(res);
}
function load(){
loadUserLocations();
loadProperties();
}
onMount(load);
</script>
@@ -63,20 +80,6 @@
{/await}
</div>
<div class="properties">
<ItemProps {item} />
<ItemProps {item} {properties} />
</div>
</div>
<table>
<tbody>
<tr>
<td class="locations">
</td>
<td class="items">
</td>
<td class="properties">
</td>
</tr>
</tbody>
</table>
</div>