code cleanup

This commit is contained in:
2025-07-30 15:35:19 +02:00
parent 631a527a5d
commit fccec9865a
27 changed files with 442 additions and 428 deletions

View File

@@ -1,29 +1,34 @@
<script>
import { onMount } from 'svelte';
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 error = $state(null);
let { module = null, entity_id = null } = $props();
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);
let {
module = null,
entity_id = null
} = $props();
async function saveNote(){
const url = api(`notes/${module}/${entity_id}`);
const url = api(`notes/${module}/${entity_id}`);
const resp = await fetch(url,{
credentials:'include',
method:'POST',
body:note.source
credentials : 'include',
method : 'POST',
body : note.source
});
if (resp.ok){
let newNote = await resp.json();
authors[user.id] = user;
let newNote = await resp.json();
authors[user.id] = user;
notes[newNote.id] = newNote;
note = {source:'',rendered:''};
error = null;
note = {source:'',rendered:''};
error = null;
return true;
} else {
error = await resp.text();
@@ -32,12 +37,12 @@
}
async function load(){
const url = api(`notes/${module}/${entity_id}`);
const url = api(`notes/${module}/${entity_id}`);
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
const data = await resp.json();
notes = data.notes;
authors = data.authors;
notes = data.notes;
authors = data.authors;
} else {
error = await resp.text();
}
@@ -51,10 +56,10 @@
position: relative;
}
legend.time{
position: absolute;
top: -19px;
right: 20px;
background: black;
position : absolute;
top : -19px;
right : 20px;
background : black;
}
</style>