implemented editing of item base data

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-15 20:59:46 +02:00
parent 3c733a75ee
commit a001074783
3 changed files with 80 additions and 27 deletions

View File

@@ -42,25 +42,30 @@
} else error(res);
}
async function updateTitle(newVal){
async function patch(key,newVal){
const url = api('stock');
const data = {
id : item.id,
owner : item.owner,
title : newVal
}
};
data[key] = newVal;
const res = await fetch(url,{
credentials:'include',
method:'PATCH',
body:JSON.stringify(data)
});
if (res.ok){
yikes();
return true;
}
error(res);
return false;
}
</script>
{#if item}
<LineEditor type="h3" editable={true} value={item.name} onSet={updateTitle}/>
<LineEditor type="h3" editable={true} value={item.name} onSet={v => patch('name',v)} />
Code: <LineEditor type="span" editable={true} value={item.code} onSet={v => patch('code',v)} />
<table>
<tbody>
{#each item.properties.toSorted(byName) as prop}