implemented project filter via query parameter
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -10,12 +10,15 @@
|
|||||||
|
|
||||||
import TimeEditor from '../../Components/TimeRecordEditor.svelte';
|
import TimeEditor from '../../Components/TimeRecordEditor.svelte';
|
||||||
|
|
||||||
|
let detail = $state(null);
|
||||||
let docLinks = $state(null);
|
let docLinks = $state(null);
|
||||||
let router = useTinyRouter();
|
let router = useTinyRouter();
|
||||||
|
|
||||||
let times = $state(null);
|
let times = $state(null);
|
||||||
let tasks = {};
|
let tasks = {};
|
||||||
let projects = {};
|
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 => ({
|
let sortedTimes = $derived.by(() => Object.values(times).map(time => ({
|
||||||
...time,
|
...time,
|
||||||
start: display(time.start_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(){
|
function onAbort(){
|
||||||
detail = null;
|
detail = null;
|
||||||
}
|
}
|
||||||
@@ -217,6 +228,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each sortedTimes as time,line}
|
{#each sortedTimes as time,line}
|
||||||
|
{#if match_prj_filter(time)}
|
||||||
<tr class={selected[time.id]?'selected':''}>
|
<tr class={selected[time.id]?'selected':''}>
|
||||||
{#if timeMap.years[line]}
|
{#if timeMap.years[line]}
|
||||||
<td class="year" rowspan={timeMap.years[line]} onclick={e => toggleRange(time.start.substring(0,4))}>
|
<td class="year" rowspan={timeMap.years[line]} onclick={e => toggleRange(time.start.substring(0,4))}>
|
||||||
@@ -279,6 +291,7 @@
|
|||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user