From 619c33c1893d1c5ebfd01814d2d8f9b6054908ef Mon Sep 17 00:00:00 2001 From: Botvid Johansson Date: Thu, 24 Apr 2025 11:01:23 +0200 Subject: [PATCH] =?UTF-8?q?=C3=A4ndra=20hur=20valda=20listor=20sparas,=20?= =?UTF-8?q?=C3=B6ppna=20och=20st=C3=A4ng=20debug=20med=20home?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/create.svelte | 40 +++++++++++++-------------- src/components/listselector.svelte | 44 ++++++++++++++++++------------ src/components/textarea.svelte | 16 +---------- src/lib/stores.svelte.ts | 17 ++++++------ src/modules/keyboard.ts | 6 ++-- src/routes/+page.svelte | 20 ++++++++++---- 6 files changed, 72 insertions(+), 71 deletions(-) diff --git a/src/components/create.svelte b/src/components/create.svelte index af165c5..436c6e4 100644 --- a/src/components/create.svelte +++ b/src/components/create.svelte @@ -21,13 +21,13 @@ $: abbForm = { shortform: '', phrase: '', - target: '', + target: { value: -1 }, errors: [] }; let importing = false; let progress = 0; - const handleCreate = async (e: Any) => { + const handleCreate = async (e: Event) => { // abbForm.errors = [] e.preventDefault(); @@ -41,7 +41,8 @@ remind: number, // negative if disabled updated: Date; */ - const sf = { + var sf = { + id: null, listid: abbForm.target.value, shortform: abbForm.shortform.replace(/\s/g, '').toLowerCase(), phrase: abbForm.phrase.trim(), @@ -56,11 +57,13 @@ .equals([sf.listid, sf.shortform]) .first() .then((existing) => { - sf.id = existing.id; - db.shortforms.put(sf).then((result) => { - cacheShortform(sf); - appState.open = ''; - }); + if (existing?.id) { + sf.id = Number(existing.id); + db.shortforms.put(sf).then((result) => { + cacheShortform(sf); + appState.open = ''; + }); + } }) .catch(() => { db.shortforms.put(sf).then((result) => { @@ -81,17 +84,18 @@ }; const onSelectedChange = (v) => { - // console.log(v); + console.log(typeof v, v); abbForm.target = v; }; + $: selectedLists = { - standard: {}, - subject: {} + standard: { label: '', value: -1 }, + subject: { label: '', value: -1 } }; let show = false; db.lists - .get(shortforms.standardList) + .get(shortforms.standardList.id) .then((l) => { if (l) { selectedLists.standard = { value: l.id, label: l.name }; @@ -104,7 +108,7 @@ console.error('db.lists.get (standard)', err); }); db.lists - .get(shortforms.subjectList) + .get(shortforms.subjectList.id) .then((l) => { if (l) { selectedLists.subject = { value: l.id, label: l.name }; @@ -159,13 +163,7 @@ >
- +
@@ -221,7 +219,7 @@ >

Fel vid import

diff --git a/src/components/listselector.svelte b/src/components/listselector.svelte index 90035b1..d87f83e 100644 --- a/src/components/listselector.svelte +++ b/src/components/listselector.svelte @@ -1,4 +1,4 @@ - @@ -47,6 +51,13 @@
+ {#if appState.debug} +
+ hello appState: {debugState} +
+ shortforms: {debugShortforms} +
+ {/if} {#if appState.open == 'create'}
-