|
|
|
|
@ -1,7 +1,20 @@
@@ -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 @@
@@ -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> |
|
|
|
|
|