implemented deletion and updating of notes

This commit is contained in:
2025-07-30 21:00:18 +02:00
parent 3dab95691b
commit 8446f1e08f
8 changed files with 71 additions and 20 deletions

View File

@@ -1,16 +1,18 @@
<script>
import { onMount } from 'svelte';
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import { user } from '../../user.svelte.js';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import { user } from '../../user.svelte.js';
import Editor from '../../Components/MarkdownEditor.svelte';
let authors = $state(null);
let error = $state(null);
let note = $state({source:null,rendered:null});
let notes = $state(null);
let authors = $state(null);
let error = $state(null);
let note = $state({source:null,rendered:null});
let notes = $state(null);
const router = useTinyRouter();
let {
module = null,
entity_id = null
@@ -31,8 +33,12 @@
}
}
function goToEntity(n){
router.navigate(`/${n.module}/${n.entity_id}/view`);
}
async function load(){
const url = api(`notes/${module}/${entity_id}`);
const url = (module == null && entity_id == null) ? api('notes') : api(`notes/${module}/${entity_id}`);
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
const data = await resp.json();
@@ -99,7 +105,11 @@
{#if notes}
{#each Object.entries(notes) as [nid,note]}
<fieldset>
{#if module}
<legend class="author">{authors[note.user_id].name}</legend>
{:else}
<legend class="entity" onclick={() => goToEntity(note)}>{t(note.module)} {note.entity_id}</legend>
{/if}
<legend class="time">
{note.timestamp.replace('T',' ')}
{#if user.id == note.user_id}

View File

@@ -186,7 +186,7 @@
{#if ready}
<div class="kanban" style="display: grid; grid-template-columns: {`repeat(${columns}, auto)`}">
<span class="filter">
<input type="text" bind:value={filter_input} />
<input type="text" bind:value={filter_input} autofocus />
{t('filter')}
</span>
<div class="head">{t('user')}</div>