re-arrenged components
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
<script>
|
||||
import { t } from '../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { api } from '../urls.svelte.js';
|
||||
|
||||
import TaskList from './TaskList.svelte';
|
||||
import LineEditor from './LineEditor.svelte';
|
||||
const router = useTinyRouter();
|
||||
let { estimated_time, show_closed, task } = $props();
|
||||
let children = $state(null);
|
||||
let error = $state(null);
|
||||
let start = 0;
|
||||
|
||||
function addSubtask(){
|
||||
router.navigate(`/task/${task.id}/add_subtask`);
|
||||
}
|
||||
|
||||
async function loadChildren(){
|
||||
const url = api('task/list');
|
||||
var data = {
|
||||
parent_task_id:+task.id,
|
||||
show_closed: show_closed
|
||||
};
|
||||
if (task.show_closed) data.show_closed = true;
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'POST',
|
||||
body:JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
children = await resp.json();
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
function openTask(){
|
||||
router.navigate(`/task/${task.id}/view`);
|
||||
}
|
||||
|
||||
async function patchTask(changeset){
|
||||
const url = api(`task/${task.id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(changeset)
|
||||
});
|
||||
if (resp.ok){
|
||||
task = await resp.json();
|
||||
return true;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function setName(newName){
|
||||
patchTask({name:newName});
|
||||
}
|
||||
|
||||
if (task.estimated_time){
|
||||
estimated_time.sum += task.estimated_time;
|
||||
console.log(estimated_time)
|
||||
}
|
||||
|
||||
onMount(loadChildren);
|
||||
</script>
|
||||
|
||||
<li class="task {task.status.name.toLowerCase()}">
|
||||
<LineEditor bind:value={task.name} onclick={openTask} editable={true} onSet={setName} type="span" />
|
||||
{#if task.estimated_time}
|
||||
<span class="estimated_time">({+task.estimated_time} h)</span>
|
||||
{/if}
|
||||
{#if task.status.name != 'PENDING'}
|
||||
<button class="symbol" title={t('do_open')} onclick={() => patchTask({status:'PENDING'})}></button>
|
||||
{/if}
|
||||
{#if task.status.name != 'OPEN'}
|
||||
<button class="symbol" title={t('do_open')} onclick={() => patchTask({status:'OPEN'})}></button>
|
||||
{/if}
|
||||
{#if task.status.name != 'STARTED'}
|
||||
<button class="symbol" title={t('started')} onclick={() => patchTask({status:'STARTED'})}></button>
|
||||
{/if}
|
||||
{#if task.status.name != 'COMPLETE'}
|
||||
<button class="symbol" title={t('complete')} onclick={() => patchTask({status:'COMPLETE'})}></button>
|
||||
{/if}
|
||||
{#if task.status.name != 'CANCELLED'}
|
||||
<button class="symbol" title={t('abort')} onclick={() => patchTask({status:'CANCELLED'})} ></button>
|
||||
{/if}
|
||||
|
||||
<button class="symbol" title={t('add_subtask')} onclick={addSubtask}></button>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
{#if children}
|
||||
<TaskList tasks={children} {estimated_time} {show_closed} />
|
||||
{/if}
|
||||
</li>
|
||||
@@ -1,14 +0,0 @@
|
||||
<script>
|
||||
import { t } from '../translations.svelte.js';
|
||||
import ListTask from './ListTask.svelte';
|
||||
|
||||
let { estimated_time, show_closed, tasks } = $props();
|
||||
|
||||
let sortedTasks = $derived.by(() => Object.values(tasks).sort((a, b) => a.name.localeCompare(b.name)));
|
||||
</script>
|
||||
|
||||
<ul>
|
||||
{#each sortedTasks as task}
|
||||
<ListTask {task} {estimated_time} show_closed={show_closed || task.show_closed} />
|
||||
{/each}
|
||||
</ul>
|
||||
Reference in New Issue
Block a user