implemented editing of document in GUI + respective handlers in backend
This commit is contained in:
@@ -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} /> {currency}
|
||||
{:else}
|
||||
<div onclick={startEdit}>{Number(value/100).toFixed(2)} {currency}</div>
|
||||
<div onclick={startEdit} class={{editable}}>{Number(value/100).toFixed(2)} {currency}</div>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user