completed task index
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -10,6 +10,31 @@
|
|||||||
let router = useTinyRouter();
|
let router = useTinyRouter();
|
||||||
let tasks = $state(null);
|
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){
|
function edit(tid){
|
||||||
router.navigate(`/task/${tid}/edit`);
|
router.navigate(`/task/${tid}/edit`);
|
||||||
}
|
}
|
||||||
@@ -37,13 +62,24 @@
|
|||||||
error = await resp.text();
|
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);
|
onMount(load);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<fieldsett>
|
<fieldset>
|
||||||
<legend>{t('task_list')}</legend>
|
<legend>{t('task_list')}</legend>
|
||||||
{#if error}
|
{#if error}
|
||||||
<soan class="error">{error}</soan>
|
<soan class="error">{error}</soan>
|
||||||
@@ -62,12 +98,13 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each Object.entries(tasks) as [tid,task]}
|
{#each Object.entries(tasks) as [tid,task]}
|
||||||
|
{#if task.status < 60}
|
||||||
<tr>
|
<tr>
|
||||||
<td onclick={() => go('task',tid)}>{task.name}</td>
|
<td onclick={() => go('task',tid)}>{task.name}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#" onclick={() => go('project',task.project_id)}> {projects[task.project_id]?.name}</a>
|
<a href="#" onclick={() => go('project',task.project_id)}> {projects[task.project_id]?.name}</a>
|
||||||
{#if task.parent_task_id}
|
{#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}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -82,13 +119,15 @@
|
|||||||
<td>
|
<td>
|
||||||
<button class="symbol" onclick={() => edit(task.id)} title={t('edit')} ></button>
|
<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={() => 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={() => start(task.id)} title={t('start')} ></button>
|
||||||
<button class="symbol" onclick={() => complete(task.id)} title={t('complete')} ></button>
|
<button class="symbol" onclick={() => complete(task.id)} title={t('complete')} ></button>
|
||||||
<button class="symbol" onclick={() => abort(task.id)} title={t('abort')} ></button>
|
<button class="symbol" onclick={() => abort(task.id)} title={t('abort')} ></button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
</fieldsett>
|
</fieldset>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
let estimated_time = $state({sum:0});
|
let estimated_time = $state({sum:0});
|
||||||
let project = $state(null);
|
let project = $state(null);
|
||||||
const router = useTinyRouter();
|
const router = useTinyRouter();
|
||||||
let showSettings = $state(false);
|
let showSettings = $state(router.fullPath.endsWith('/edit'));
|
||||||
let task = $state(null);
|
let task = $state(null);
|
||||||
|
|
||||||
$effect(() => updateOn(id));
|
$effect(() => updateOn(id));
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
function updateOn(id){
|
function updateOn(id){
|
||||||
task = null;
|
task = null;
|
||||||
loadTask();
|
loadTask();
|
||||||
|
console.log(router);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChild(){
|
function addChild(){
|
||||||
|
|||||||
Reference in New Issue
Block a user