implemented editing of item base data
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user