Browse Source

implemented project filter via query parameter

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
module/timetracking
Stephan Richter 2 weeks ago
parent
commit
090f8af94e
  1. 15
      frontend/src/routes/time/Index.svelte

15
frontend/src/routes/time/Index.svelte

@ -10,12 +10,15 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -279,6 +291,7 @@
</td>
{/if}
</tr>
{/if}
{/each}
</tbody>
</table>

Loading…
Cancel
Save