implemented editing of document in GUI + respective handlers in backend

This commit is contained in:
2025-07-12 23:34:05 +02:00
parent 2cc4d43e7c
commit 26fa72ef84
12 changed files with 190 additions and 81 deletions

View File

@@ -1,13 +1,14 @@
<script>
import { activeField } from './field_sync.svelte.js';
let { editable = false, currency, value = $bindable(null) } = $props();
let { editable = false, currency, value = $bindable(null), onSet = (newVal) => {} } = $props();
let editing = $state(false);
let editValue = value/100;
function applyEdit(){
value = editValue * 100;
async function applyEdit(){
let success = await onSet(editValue * 100);
if (success) value = editValue * 100;
editing = false;
}
@@ -31,11 +32,18 @@
<style>
input{width:100px}
div{
min-width: 40px;
min-height: 20px;
}
.editable:hover{
border: 1px dotted;
}
</style>
{#if editable && editing}
<input type="number" step=".01" bind:value={editValue} onkeyup={typed} />&nbsp;{currency}
{:else}
<div onclick={startEdit}>{Number(value/100).toFixed(2)}&nbsp;{currency}</div>
<div onclick={startEdit} class={{editable}}>{Number(value/100).toFixed(2)}&nbsp;{currency}</div>
{/if}