preparing to create new items
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -189,7 +189,7 @@
|
||||
</h3>
|
||||
<MarkdownEditor editable={true} value={location.description} type="div" onSet={newDesc => patchLocation(location,'description',newDesc)} />
|
||||
{/if}
|
||||
<ItemList items={data?.items.sort((a,b) => a.code.localeCompare(b.code))} bind:selected={item} drag_start={drag_item} />
|
||||
<ItemList {location} items={data?.items.sort((a,b) => a.code.localeCompare(b.code))} bind:selected={item} drag_start={drag_item} />
|
||||
</div>
|
||||
<div class="properties">
|
||||
<ItemProps {item} {properties} />
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte';
|
||||
import { api, post } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
|
||||
let { items, selected = $bindable(null), drag_start = item => console.log({dragging:item}) } = $props();
|
||||
let { items, selected = $bindable(null), location = null, drag_start = item => console.log({dragging:item}) } = $props();
|
||||
let newItem = $state({name:null, code: null});
|
||||
|
||||
async function saveNewItem(){
|
||||
newItem.location = location;
|
||||
console.log(JSON.parse(JSON.stringify(newItem)));
|
||||
const url = api('stock/item');
|
||||
const res = post(url,newItem);
|
||||
if (res.ok) {
|
||||
yikes();
|
||||
} else error(res);
|
||||
}
|
||||
</script>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -19,5 +32,17 @@
|
||||
<td>{item.name}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{#if location}
|
||||
<tr>
|
||||
<td>{t('create_new_object',{object:t('item')})}</td>
|
||||
<td>
|
||||
<input type="text" bind:value={newItem.code} />
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" bind:value={newItem.name} />
|
||||
<button onclick={saveNewItem}>{t('save')}</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user