10 changed files with 136 additions and 46 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
/* © SRSoftware 2025 */ |
||||
package de.srsoftware.umbrella.core.model; |
||||
|
||||
public enum Status{ |
||||
OPEN(10), |
||||
STARTED(20), |
||||
PENDING(40), |
||||
COMPLETE(60), |
||||
CANCELLED(100); |
||||
|
||||
private int code; |
||||
|
||||
Status(int code){ |
||||
this.code = code; |
||||
} |
||||
|
||||
public int code(){ |
||||
return code; |
||||
} |
||||
|
||||
public static Status of(int code){ |
||||
return switch (code){ |
||||
case 10 -> OPEN; |
||||
case 20 -> STARTED; |
||||
case 40 -> PENDING; |
||||
case 60 -> COMPLETE; |
||||
case 100 -> CANCELLED; |
||||
default -> throw new IllegalArgumentException(); |
||||
}; |
||||
} |
||||
} |
||||
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
<script> |
||||
import { t } from '../translations.svelte.js'; |
||||
import { onMount } from 'svelte'; |
||||
import { useTinyRouter } from 'svelte-tiny-router'; |
||||
|
||||
import TaskList from './TaskList.svelte'; |
||||
|
||||
const router = useTinyRouter(); |
||||
let { estimated_time, task } = $props(); |
||||
let children = $state(null); |
||||
let error = $state(null); |
||||
|
||||
async function loadChildren(){ |
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/task/list`; |
||||
var data = {parent_task_id:+task.id}; |
||||
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(evt){ |
||||
evt.preventDefault(); |
||||
router.navigate(`/task/${task.id}/view`); |
||||
} |
||||
|
||||
if (task.estimated_time){ |
||||
estimated_time.sum += task.estimated_time; |
||||
console.log(estimated_time) |
||||
} |
||||
|
||||
onMount(loadChildren); |
||||
</script> |
||||
|
||||
<li> |
||||
<span onclick={openTask} class={task.status.name.toLowerCase()}> |
||||
{task.name} |
||||
{#if task.estimated_time} |
||||
<span class="error">({+task.estimated_time} h)</span> |
||||
{/if} |
||||
</span> |
||||
{#if error} |
||||
<span class="error">{error}</span> |
||||
{/if} |
||||
{#if children} |
||||
<TaskList tasks={children} bind:estimated_time={estimated_time} /> |
||||
{/if} |
||||
</li> |
||||
Loading…
Reference in new issue