Merge branch 'main' into module/stock

This commit is contained in:
2025-10-18 20:27:56 +02:00
10 changed files with 154 additions and 60 deletions

View File

@@ -14,8 +14,9 @@
let map = $state({});
let hidden = $state({});
async function changeState(tid,state){
const task = tasks[tid];
async function changeState(idx,state){
const task = tasks[idx];
const tid = task.id;
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}`);
@@ -25,18 +26,18 @@
body : JSON.stringify({status:stat})
});
if (resp.ok){
tasks[tid] = await resp.json();
tasks[idx] = await resp.json();
} else {
error(resp);
}
}
function abort(tid){
changeState(tid,'CANCELLED');
function abort(idx){
changeState(idx,'CANCELLED');
}
function complete(tid){
changeState(tid,'COMPLETE');
function complete(idx){
changeState(idx,'COMPLETE');
}
function edit(tid){
@@ -81,16 +82,16 @@
}
}
function open(tid){
changeState(tid,'OPEN');
function open(idx){
changeState(idx,'OPEN');
}
function postpone(tid){
changeState(tid,'PENDING');
function postpone(idx){
changeState(idx,'PENDING');
}
function start(tid){
changeState(tid,'STARTED');
function start(idx){
changeState(idx,'STARTED');
}
onMount(load);
@@ -115,7 +116,7 @@
</tr>
</thead>
<tbody>
{#each tasks as task (task.id)}
{#each tasks as task,idx}
{#if task.status > 10 && task.status < 60 && !task.no_index && projects[task.project_id]?.status < 60 && !hidden[task.id]}
<tr>
<td onclick={() => go('task',task.id)}>{task.name}</td>
@@ -136,11 +137,11 @@
</td>
<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>
<button class="symbol" onclick={() => postpone(idx)} title={t('postpone')} ></button>
<button class="symbol" onclick={() => open(idx)} title={t('open')}></button>
<button class="symbol" onclick={() => start(idx)} title={t('start')} ></button>
<button class="symbol" onclick={() => complete(idx)} title={t('complete')} ></button>
<button class="symbol" onclick={() => abort(idx)} title={t('abort')} ></button>
</td>
</tr>
{/if}

View File

@@ -140,6 +140,10 @@
showSettings = !showSettings;
}
function unlink_parent(){
update({parent_task_id:null});
}
async function update(data){
const url = api(`task/${id}`);
const resp = await fetch(url,{
@@ -151,7 +155,11 @@
yikes();
let old_task = task;
task = await resp.json();
if (task.parent_id == old_task.parent_id) task.parent = old_task.parent;
if (!task.parent_id){
task.parent = null;
} else {
if (task.parent_id == old_task.parent_id) task.parent = old_task.parent;
}
return true;
} else {
error(resp);
@@ -196,6 +204,7 @@
<div>{t('parent_task')}</div>
<div class="parent">
<a href="#" onclick={gotoParent}>{task.parent.name}</a>
<button class="symbol" title={t('unlink')} onclick={unlink_parent}></button>
</div>
{/if}
<div>{t('task')}</div>

View File

@@ -10,12 +10,15 @@
import TimeEditor from '../../Components/TimeRecordEditor.svelte';
let detail = $state(null);
let docLinks = $state(null);
let router = useTinyRouter();
let times = $state(null);
let tasks = {};
let projects = {};
let detail = $state(null);
let project_filter = $state(null);
if (router.hasQueryParam('project')) project_filter = router.getQueryParam('project');
let sortedTimes = $derived.by(() => Object.values(times).map(time => ({
...time,
start: display(time.start_time),
@@ -114,6 +117,14 @@
}
}
function match_prj_filter(time){
if (!project_filter) return true;
for (var tid of time.task_ids){
if (project_filter == tasks[tid].project_id) return true;
}
return false;
}
function onAbort(){
detail = null;
}
@@ -217,6 +228,7 @@
</thead>
<tbody>
{#each sortedTimes as time,line}
{#if match_prj_filter(time)}
<tr class={selected[time.id]?'selected':''}>
{#if timeMap.years[line]}
<td class="year" rowspan={timeMap.years[line]} onclick={e => toggleRange(time.start.substring(0,4))}>
@@ -279,6 +291,7 @@
</td>
{/if}
</tr>
{/if}
{/each}
</tbody>
</table>