Browse Source

completed task index

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
featue/module_registry
Stephan Richter 3 months ago
parent
commit
20e91f5b2a
  1. 47
      frontend/src/routes/task/Index.svelte
  2. 3
      frontend/src/routes/task/View.svelte

47
frontend/src/routes/task/Index.svelte

@ -10,6 +10,31 @@ @@ -10,6 +10,31 @@
let router = useTinyRouter();
let tasks = $state(null);
async function changeState(tid,state){
const task = tasks[tid];
const prj = projects[task.project_id];
const stat = Object.keys(prj.allowed_states).find(k => prj.allowed_states[k] === state);
const url = api(`task/${tid}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify({status:stat})
});
if (resp.ok){
tasks[tid] = await resp.json();
} else {
error = await resp.text();
}
}
function abort(tid){
changeState(tid,'CANCELLED');
}
function complete(tid){
changeState(tid,'COMPLETE');
}
function edit(tid){
router.navigate(`/task/${tid}/edit`);
}
@ -37,13 +62,24 @@ @@ -37,13 +62,24 @@
error = await resp.text();
}
}
console.log(projects);
}
function open(tid){
changeState(tid,'OPEN');
}
function postpone(tid){
changeState(tid,'PENDING');
}
function start(tid){
changeState(tid,'STARTED');
}
onMount(load);
</script>
<fieldsett>
<fieldset>
<legend>{t('task_list')}</legend>
{#if error}
<soan class="error">{error}</soan>
@ -62,12 +98,13 @@ @@ -62,12 +98,13 @@
</thead>
<tbody>
{#each Object.entries(tasks) as [tid,task]}
{#if task.status < 60}
<tr>
<td onclick={() => go('task',tid)}>{task.name}</td>
<td>
<a href="#" onclick={() => go('project',task.project_id)}> {projects[task.project_id]?.name}</a>
{#if task.parent_task_id}
(<a href="#" onclick={() => go('task',task.parent_task_id)}>{tasks[task.parent_task_id]?.name}</a>)
: <a href="#" onclick={() => go('task',task.parent_task_id)}>{tasks[task.parent_task_id]?.name}</a>
{/if}
</td>
<td>
@ -82,13 +119,15 @@ @@ -82,13 +119,15 @@
<td>
<button class="symbol" onclick={() => edit(task.id)} title={t('edit')} ></button>
<button class="symbol" onclick={() => postpone(task.id)} title={t('postpone')} ></button>
<button class="symbol" onclick={() => open(task.id)} title={t('open')}></button>
<button class="symbol" onclick={() => start(task.id)} title={t('start')} ></button>
<button class="symbol" onclick={() => complete(task.id)} title={t('complete')} ></button>
<button class="symbol" onclick={() => abort(task.id)} title={t('abort')} ></button>
</td>
</tr>
{/if}
{/each}
</tbody>
</table>
{/if}
</fieldsett>
</fieldset>

3
frontend/src/routes/task/View.svelte

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
let estimated_time = $state({sum:0});
let project = $state(null);
const router = useTinyRouter();
let showSettings = $state(false);
let showSettings = $state(router.fullPath.endsWith('/edit'));
let task = $state(null);
$effect(() => updateOn(id));
@ -46,6 +46,7 @@ @@ -46,6 +46,7 @@
function updateOn(id){
task = null;
loadTask();
console.log(router);
}
function addChild(){

Loading…
Cancel
Save