implemented adding/updating of item properties
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user