working on notes
This commit is contained in:
55
frontend/src/routes/notes/List.svelte
Normal file
55
frontend/src/routes/notes/List.svelte
Normal file
@@ -0,0 +1,55 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import Editor from '../../Components/MarkdownEditor.svelte';
|
||||
|
||||
let error = $state(null);
|
||||
let { module = null, entity_id = null } = $props();
|
||||
let note = $state({source:null,rendered:null});
|
||||
let notes = $state(null);
|
||||
|
||||
async function onclick(){
|
||||
alert(note.source);
|
||||
const url = api(`notes/${module}/${entity_id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'POST',
|
||||
body:note.source
|
||||
});
|
||||
if (resp.ok){
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
async function load(){
|
||||
const url = api(`notes/${module}/${entity_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
notes = await resp.json();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(load)
|
||||
</script>
|
||||
|
||||
<h1>{t('notes')}</h1>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
|
||||
{#if notes}
|
||||
{#each Object.entries(notes) as [a,b]}
|
||||
<fieldset>
|
||||
<legend>User {b.user_id} – {b.timestamp.replace('T',' ')}</legend>
|
||||
{@html b.rendered}
|
||||
</fieldset>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<Editor simple={true} bind:value={note} />
|
||||
<button {onclick}>{t('save_note')}</button>
|
||||
@@ -8,6 +8,7 @@
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
import MemberEditor from '../../Components/MemberEditor.svelte';
|
||||
import Notes from '../notes/List.svelte';
|
||||
import StateSelector from '../../Components/StateSelector.svelte';
|
||||
import TagList from '../tags/TagList.svelte';
|
||||
import TaskList from './TaskList.svelte';
|
||||
@@ -293,6 +294,12 @@
|
||||
<TagList module="task" {id} user_list={Object.keys(task.members).map(id => +id)} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t('notes')}</th>
|
||||
<td>
|
||||
<Notes module="task" entity_id={id} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user