improved easylist

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-11-28 16:01:19 +01:00
parent 261a93bcc0
commit 59f864d16f
3 changed files with 59 additions and 18 deletions

View File

@@ -5,8 +5,11 @@
import { error, yikes } from '../../warn.svelte'; import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte'; import { t } from '../../translations.svelte';
import Detail from './EasyListDetail.svelte';
let { tag } = $props(); let { tag } = $props();
let filter = $state(null); let filter = $state(null);
let highlight = $state(null);
let search = $derived(filter ? filter.toLowerCase() : null); let search = $derived(filter ? filter.toLowerCase() : null);
let input; let input;
let tasks = $state(null); let tasks = $state(null);
@@ -24,6 +27,14 @@
update(task,60); update(task,60);
} }
function goTag(e,newTag){
e.preventDefault();
e.stopPropagation();
router.navigate(`/tags/easylist/${newTag}`);
tag = newTag;
load();
}
async function load(){ async function load(){
const url = api(`task/tagged/${tag}`); const url = api(`task/tagged/${tag}`);
const res = await get(url); const res = await get(url);
@@ -39,14 +50,10 @@
return !task.no_index; return !task.no_index;
} }
function oncontextmenu(e){ function extend(e,task){
e.stopPropagation();
e.preventDefault(); e.preventDefault();
console.log(e); e.stopPropagation();
var target = e.target; highlight = task;
while (target && !target.href) target=target.parentNode;
let href = target.getAttribute('href');
if (href) router.navigate(href);
return false; return false;
} }
@@ -57,6 +64,7 @@
} }
async function update(task,newState){ async function update(task,newState){
highlight = null;
const url = api(`task/${task.id}`); const url = api(`task/${task.id}`);
const res = await patch(url,{status:newState}); const res = await patch(url,{status:newState});
if (res.ok){ if (res.ok){
@@ -71,20 +79,21 @@
onMount(load); onMount(load);
</script> </script>
<div class="easylist"> <h2>{tag}</h2>
<div class="filter">
{t('filter')}: <input type="text" bind:value={filter} bind:this={input} />
</div>
<div class="easylist">
<fieldset class="open"> <fieldset class="open">
<legend>{t('state_open')}</legend> <legend>{t('state_open')}</legend>
{#if sorted} {#if sorted}
{#each sorted as task} {#each sorted as task}
{#if task.status == 20 && (!filter || task.name.toLowerCase().includes(search))} {#if task.status == 20 && (!filter || task.name.toLowerCase().includes(search))}
<a href={`/task/${task.id}/view`} title={task.description.source} onclick={e => close(e,task)} {oncontextmenu} > <a href={`/task/${task.id}/view`} title={task.description.source} onclick={e => close(e,task)} oncontextmenu={e => extend(e,task)} >
{task.name} {task.name}
</a> </a>
{#if highlight == task}
<Detail task={task} goTag={goTag} />
{/if} {/if}
{/if}
{/each} {/each}
{/if} {/if}
</fieldset> </fieldset>
@@ -94,11 +103,18 @@
{#if sorted} {#if sorted}
{#each sorted as task} {#each sorted as task}
{#if task.status > 20 && (!filter || task.name.toLowerCase().includes(search))} {#if task.status > 20 && (!filter || task.name.toLowerCase().includes(search))}
<a href={`/task/${task.id}/view`} title={task.description.source} onclick={e => open(e,task)} {oncontextmenu} > <a href={`/task/${task.id}/view`} title={task.description.source} onclick={e => open(e,task)} oncontextmenu={e => extend(e,task)} >
{task.name} {task.name}
</a> </a>
{#if highlight == task}
<Detail task={task} goTag={goTag} />
{/if}
{/if} {/if}
{/each} {/each}
{/if} {/if}
</fieldset> </fieldset>
</div>
<div class="filter">
{t('filter')}: <input type="text" bind:value={filter} bind:this={input} />
</div>
</div>

View File

@@ -0,0 +1,28 @@
<script>
import { onMount } from 'svelte';
import { api, get, patch } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
let { goTag, task } = $props();
async function load(){
const url = api(`tags/task/${task.id}`);
const res = await get(url);
if (res.ok){
yikes();
task.tags = await res.json();
} else error(res);
}
onMount(load);
</script>
{@html task.description.rendered}
{#if task.tags}
{t('other_tags')}:
{#each task.tags as tag}
<button onclick={e => goTag(e,tag)}>{tag}</button>
{/each}
<hr />
{/if}

View File

@@ -495,7 +495,7 @@ a.wikilink{
} }
.easylist .filter{ .easylist .filter{
position: sticky; position: sticky;
top: 40px; bottom: 22px;
z-index: 10; z-index: 10;
} }
@@ -527,9 +527,6 @@ a.wikilink{
.easylist input{ .easylist input{
font-size: 20px; font-size: 20px;
} }
.easylist .filter{
top: 95px;
}
} }
fieldset.vcard{ fieldset.vcard{