implemented adding/updating of item properties

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-15 09:26:16 +02:00
parent 846ef4a27a
commit 832be23e8c
7 changed files with 49 additions and 23 deletions

View File

@@ -35,6 +35,7 @@
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 = null;
properties = Object.values(dict).sort((a,b) => a.name.localeCompare(b.name));
yikes();
} else error(res);

View File

@@ -14,6 +14,10 @@
}
});
function byName(a,b){
return a.name.localeCompare(b.name);
}
async function onclick(){
const url = api('stock/property');
const data = {
@@ -29,6 +33,10 @@
body:JSON.stringify(data)
});
if (res.ok){
const prop = await res.json();
const id = prop.id;
item.properties = item.properties.filter(p => p.id != id);
item.properties.push(prop);
yikes();
} else error(res);
}
@@ -39,7 +47,7 @@
<table>
<tbody>
{#each item.properties as prop}
{#each item.properties.toSorted(byName) as prop}
<tr>
<td>
{prop.name}