implemented deleting of notes

This commit is contained in:
2025-07-30 20:37:08 +02:00
parent e08bcf17a5
commit 3dab95691b
7 changed files with 43 additions and 13 deletions

View File

@@ -16,6 +16,21 @@
entity_id = null
} = $props();
async function drop(nid){
if (!confirm(t('confirm_delete',{element:t('note')}))) return;
const url = api(`notes/${nid}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'DELETE'
});
if (resp.ok) {
error = false;
delete notes[nid];
} else {
error = await resp.text();
}
}
async function load(){
const url = api(`notes/${module}/${entity_id}`);
const resp = await fetch(url,{credentials:'include'});
@@ -85,7 +100,12 @@
{#each Object.entries(notes) as [nid,note]}
<fieldset>
<legend class="author">{authors[note.user_id].name}</legend>
<legend class="time">{note.timestamp.replace('T',' ')}</legend>
<legend class="time">
{note.timestamp.replace('T',' ')}
{#if user.id == note.user_id}
<button class="symbol" onclick={() => drop(nid)}></button>
{/if}
</legend>
<Editor value={note.text} onSet={(newVal) => update(nid,newVal)} editable={user.id == note.user_id} />
</fieldset>
{/each}