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,30 +1,30 @@
<script>
import { onMount } from 'svelte';
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { t } from '../../translations.svelte.js';
import { api } from '../../urls.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 MarkdownEditor from '../../Components/MarkdownEditor.svelte';
import MemberEditor from '../../Components/MemberEditor.svelte';
import Tags from '../tags/TagList.svelte';
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
import MemberEditor from '../../Components/MemberEditor.svelte';
import Tags from '../tags/TagList.svelte';
let { project_id = null, parent_task_id } = $props();
let error = $state(null);
let project = $state(null);
let error = $state(null);
let project = $state(null);
let extendedSettings = $state(false);
let parent_task = $state(null);
let parent_task = $state(null);
let task = $state({
name : '',
description : { source : '', rendered : '' },
due_date: null,
estimated_time: null,
no_index: false,
members : {},
show_closed: false,
start_date: null,
tags: []
name : '',
description : { source : '', rendered : '' },
due_date : null,
estimated_time : null,
no_index : false,
members : {},
show_closed : false,
start_date : null,
tags : []
});
let router = useTinyRouter();
@@ -44,28 +44,28 @@
}
async function loadParent(){
const url = api(`task/${parent_task_id}`);
const url = api(`task/${parent_task_id}`);
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
parent_task = await resp.json();
parent_task = await resp.json();
task.parent_task_id = +parent_task_id;
project_id = parent_task.project_id;
error = null;
project = null; // TODO
project_id = parent_task.project_id;
error = null;
project = null; // TODO
} else {
error = await resp.text();
}
}
async function loadProject(){
var url = api(`project/${project_id}`);
const url = api(`project/${project_id}`);
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
project = await resp.json();
task.project_id = +project_id;
project = await resp.json();
task.project_id = +project_id;
let member_source = parent_task?parent_task.members:project.members;
task.members = JSON.parse(JSON.stringify(member_source)); // deep copy
error = null;
task.members = JSON.parse(JSON.stringify(member_source)); // deep copy
error = null;
} else {
error = await resp.text();
}
@@ -98,11 +98,11 @@
}
async function saveTask(){
var url = api('task/add');
const url = api('task/add');
const resp = await fetch(url,{
credentials:'include',
method:'POST',
body: JSON.stringify(task)
credentials : 'include',
method : 'POST',
body : JSON.stringify(task)
});
if (resp.ok) {
task = await resp.json();