|
|
|
|
@ -1,16 +1,18 @@
@@ -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 @@
@@ -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 @@
@@ -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} |
|
|
|
|
|