implemented deletion of new documents
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
document.sender.name = '';
|
||||
if (company.name) document.sender.name += company.name+"\n";
|
||||
if (company.address) document.sender.name += company.address+"\n";
|
||||
if (company.tax_number) document.sender.tax_id = company.tax_number;
|
||||
if (company.tax_number) document.sender.tax_id = company.tax_number;
|
||||
if (company.bank_account) document.sender.bank_account = company.bank_account;
|
||||
if (company.court) document.sender.court = company.court;
|
||||
} else {
|
||||
|
||||
@@ -44,6 +44,21 @@
|
||||
router.navigate(`/document/${id}/view`);
|
||||
}
|
||||
|
||||
async function deleteDoc(ev,doc){
|
||||
if (confirm(t('document.really_delete',doc.number))){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}`;
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'DELETE'
|
||||
});
|
||||
if (resp.ok){
|
||||
load(selected_company); // relaod docs
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadCompanies);
|
||||
</script>
|
||||
|
||||
@@ -77,13 +92,18 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each Object.entries(documents).reverse() as [id,document]}
|
||||
<tr onclick={() => show(id)}>
|
||||
<td>{document.number}</td>
|
||||
<td>{document.date}</td>
|
||||
<td>{document.customer.name.split('\n')[0]}</td>
|
||||
<td>{document.sum/100 + document.currency}</td>
|
||||
<td>{t('document.type_'+document.type)}</td>
|
||||
<td>{t('document.state_'+document.state.name)}</td>
|
||||
<tr>
|
||||
<td onclick={() => show(id)}>{document.number}</td>
|
||||
<td onclick={() => show(id)}>{document.date}</td>
|
||||
<td onclick={() => show(id)}>{document.customer.name.split('\n')[0]}</td>
|
||||
<td onclick={() => show(id)}>{document.sum/100 + document.currency}</td>
|
||||
<td onclick={() => show(id)}>{t('document.type_'+document.type)}</td>
|
||||
<td onclick={() => show(id)}>{t('document.state_'+document.state.name)}</td>
|
||||
<td>
|
||||
{#if document.state.id == 1}
|
||||
<button onclick={(ev) => deleteDoc(ev,document)}>{t('document.delete')}</button>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user