Merge branch 'module/contact' into dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import { api } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { name } from '../../vcard.js';
|
||||
import { t } from '../../translations.svelte';
|
||||
|
||||
|
||||
@@ -25,6 +26,26 @@
|
||||
let orgs = $derived(contact.vcard.match(/^ORG.*:.+$/gm));
|
||||
let urls = $derived(contact.vcard.match(/^URL.*:.+$/gm));
|
||||
|
||||
async function drop(){
|
||||
for (let n of names){
|
||||
n = name(n);
|
||||
n = (n.given + ' ' + n.family).trim();
|
||||
if (confirm(t('confirm_delete',{element:n}))) break;
|
||||
return
|
||||
}
|
||||
const url = api(`contact/${contact.id}`);
|
||||
const res = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'DELETE'
|
||||
});
|
||||
if (res.ok){
|
||||
yikes();
|
||||
contact = null;
|
||||
} else {
|
||||
error(res);
|
||||
}
|
||||
}
|
||||
|
||||
async function patch(from,to){
|
||||
if (from == to) return;
|
||||
const newContact = contact.id == 0;
|
||||
@@ -49,6 +70,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if contact}
|
||||
<fieldset class="vcard">
|
||||
<legend>
|
||||
{#if contact.id}
|
||||
@@ -57,6 +79,9 @@
|
||||
{t('new_contact')}
|
||||
{/if}
|
||||
<button class="symbol" onclick={toggleCode}></button>
|
||||
{#if contact.id}
|
||||
<button class="symbol" onclick={drop}></button>
|
||||
{/if}
|
||||
</legend>
|
||||
<table>
|
||||
<thead></thead>
|
||||
@@ -124,4 +149,5 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user