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

@@ -2,12 +2,18 @@
import { activeField } from './field_sync.svelte.js';
import { t } from '../translations.svelte.js';
let { editable = false, value = $bindable(null), onSet = (newVal) => {} } = $props();
let {
editable = false,
onclick = evt => {},
onSet = newVal => {return true;},
type = 'div',
value = $bindable(null)
} = $props();
let editing = $state(false);
let editValue = $state(value);
let timer = null;
let start = 0;
async function applyEdit(){
let success = await onSet(editValue);
@@ -29,7 +35,34 @@
if (ev.keyCode == 13 && ev.ctrlKey) applyEdit();
if (ev.keyCode == 27) resetEdit();
}
console.log(value);
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());
</script>
@@ -52,10 +85,10 @@
<textarea bind:value={editValue} onkeyup={typed} autofocus></textarea>
{:else}
{#if value}
<div ondblclick={startEdit} class={{editable}} title={t('double_click_to_edit')} >
<svelte:element this={type} {onmousedown} {onmouseup} {ontouchstart} {ontouchend} class={{editable}} title={t('double_click_to_edit')} >
{#each value.split("\n") as line}
{line}<br/>
{/each}
</div>
</svelte:element>
{/if}
{/if}