implemented synchronisation between editors:
whenever one editable field is activated, any other active editable field is resetted
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script>
|
||||
import { activeField } from './field_sync.svelte.js';
|
||||
|
||||
let { editable = false, value = $bindable(null) } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
@@ -15,6 +17,7 @@
|
||||
}
|
||||
|
||||
function startEdit(){
|
||||
activeField.update((n) => n+1);
|
||||
editing = editable;
|
||||
}
|
||||
|
||||
@@ -22,6 +25,8 @@
|
||||
if (ev.keyCode == 13) applyEdit();
|
||||
if (ev.keyCode == 27) resetEdit();
|
||||
}
|
||||
|
||||
activeField.subscribe((val) => resetEdit());
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script>
|
||||
import { activeField } from './field_sync.svelte.js';
|
||||
|
||||
let { editable = false, value = $bindable(null) } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
@@ -17,6 +19,7 @@
|
||||
}
|
||||
|
||||
function startEdit(){
|
||||
activeField.update((n) => n+1);
|
||||
editing = editable;
|
||||
}
|
||||
|
||||
@@ -38,6 +41,8 @@
|
||||
timer = setTimeout(render,1000);
|
||||
// TODO: start timer, send text to renderer, update editValue.rendered
|
||||
}
|
||||
|
||||
activeField.subscribe((val) => resetEdit());
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script>
|
||||
import { activeField } from './field_sync.svelte.js';
|
||||
|
||||
let { editable = false, value = $bindable(null) } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
@@ -16,6 +18,7 @@
|
||||
}
|
||||
|
||||
function startEdit(){
|
||||
activeField.update((n) => n+1);
|
||||
editing = editable;
|
||||
}
|
||||
|
||||
@@ -23,6 +26,8 @@
|
||||
if (ev.keyCode == 13 && ev.ctrlKey) applyEdit();
|
||||
if (ev.keyCode == 27) resetEdit();
|
||||
}
|
||||
|
||||
activeField.subscribe((val) => resetEdit());
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script>
|
||||
import { activeField } from './field_sync.svelte.js';
|
||||
|
||||
let { editable = false, currency, value = $bindable(null) } = $props();
|
||||
let editing = $state(false);
|
||||
|
||||
@@ -15,6 +17,7 @@
|
||||
}
|
||||
|
||||
function startEdit(){
|
||||
activeField.update((n) => n+1);
|
||||
editing = editable;
|
||||
}
|
||||
|
||||
@@ -22,6 +25,8 @@
|
||||
if (ev.keyCode == 13) applyEdit();
|
||||
if (ev.keyCode == 27) resetEdit();
|
||||
}
|
||||
|
||||
activeField.subscribe((val) => resetEdit());
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
3
frontend/src/Components/field_sync.svelte.js
Normal file
3
frontend/src/Components/field_sync.svelte.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const activeField = writable(0);
|
||||
Reference in New Issue
Block a user