implemented display of projects in time record list
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
let error = $state(null);
|
||||
let router = useTinyRouter();
|
||||
let times = $state(null);
|
||||
let tasks = {};
|
||||
let projects = {};
|
||||
let detail = $state(null);
|
||||
let sortedTimes = $derived.by(() => Object.values(times).sort((b, a) => a.start_time - b.start_time));
|
||||
let selected = $state({});
|
||||
@@ -58,7 +60,10 @@
|
||||
const url = api('time');
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
times = await resp.json();
|
||||
var json = await resp.json();
|
||||
times = json.times;
|
||||
tasks = json.tasks;
|
||||
projects = json.projects;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
@@ -147,6 +152,7 @@
|
||||
<th>{t('start')}<wbr>…<wbr>{t('end')}</th>
|
||||
<th>{t('duration')}</th>
|
||||
<th>{t('subject')}</th>
|
||||
<th>{t('projects')}</th>
|
||||
<th>{t('tasks')}</th>
|
||||
<th>{t('state')}</th>
|
||||
</tr>
|
||||
@@ -180,15 +186,28 @@
|
||||
<td class="subject" onclick={e => {detail = time.id}}>
|
||||
{time.subject}
|
||||
</td>
|
||||
<td class="tasks" onclick={e => {detail = time.id}}>
|
||||
<td class="projects" onclick={e => {detail = time.id}}>
|
||||
<ul>
|
||||
{#each Object.entries(time.tasks) as [tid,task]}
|
||||
{#each time.task_ids as tid}
|
||||
{#if tasks[tid] && projects[tasks[tid].project_id]}
|
||||
<li>
|
||||
<a href="#" onclick={e => openTask(tid)}>{task}</a>
|
||||
<a href="#" onclick={e => openProject(tasks[tid].project_id)}>{projects[tasks[tid].project_id].name}</a>
|
||||
</li>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
</td>
|
||||
<td class="tasks" onclick={e => {detail = time.id}}>
|
||||
<ul>
|
||||
{#each time.task_ids as tid}
|
||||
{#if tasks[tid]}
|
||||
<li>
|
||||
<a href="#" onclick={e => openTask(tid)}>{tasks[tid].name}</a>
|
||||
</li>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
</td>
|
||||
<td class="state" onclick={e => {detail = time.id}}>
|
||||
{t("state_"+time.state.name.toLowerCase())}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user