implemented task editing right from the project list

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-07-25 22:03:53 +02:00
parent be0435db1b
commit 5bc84f1321
7 changed files with 284 additions and 26 deletions

View File

@@ -4,9 +4,11 @@
let {
editable = true,
onclick = evt => {},
onSet = newVal => {return true;},
simple = false,
value = $bindable({source:null,rendered:null}),
onSet = (newVal) => {}
type = 'div',
value = $bindable({source:null,rendered:null})
} = $props();
let editing = $state(false);
@@ -14,6 +16,7 @@
let editValue = $state({source:value.source,rendered:value.rendered});
let timer = null;
let start = 0;
async function applyEdit(){
let success = await onSet(editValue.source);
@@ -55,6 +58,34 @@
timer = setTimeout(render,500);
}
function measured(evt,duration){
if (duration < 500){
onclick(evt);
} else {
startEdit();
}
}
function onmousedown(evt){
evt.preventDefault();
start = evt.timeStamp;
}
function onmouseup(evt){
evt.preventDefault();
measured(evt, evt.timeStamp - start);
}
function ontouchstart(evt){
evt.preventDefault();
start = evt.timeStamp;
}
function ontouchend(evt){
evt.preventDefault();
measured(evt, evt.timeStamp - start);
}
activeField.subscribe((val) => resetEdit());
if (simple) startEdit();
</script>
@@ -76,4 +107,4 @@
{#if editing}
<textarea bind:value={editValue.source} onkeyup={typed} autofocus={!simple}></textarea>
{/if}
<div ondblclick={startEdit} class={{editable}} title={t('double_click_to_edit')} >{@html editValue.rendered}</div>
<svelte:element this={type} {onmousedown} {onmouseup} {ontouchstart} {ontouchend} class={{editable}} title={t('double_click_to_edit')} >{@html editValue.rendered}</svelte:element>