implemented deleting of notes
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user