diff --git a/src/components/import/import.svelte b/src/components/import/import.svelte
index 52638bb..7da5764 100644
--- a/src/components/import/import.svelte
+++ b/src/components/import/import.svelte
@@ -21,7 +21,7 @@
$: form = {
textarea: '',
name: '',
- type: false
+ type: true
};
let importing = false;
let progress = 0;
@@ -92,7 +92,7 @@ förkn=förkortningen
-
+
diff --git a/src/components/listselector.svelte b/src/components/listselector.svelte
index ddb08e7..4a53e2f 100644
--- a/src/components/listselector.svelte
+++ b/src/components/listselector.svelte
@@ -12,10 +12,16 @@
const onSelectedStandardListChange = (e) => {
console.log('onSelectedStandardListChange', e);
shortforms.standardList = e.value;
- cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectLists)]);
+ cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
};
const onSelectedSubjectListChange = (e) => {
+ if (e.value == 0) {
+ listSelectorForm.subject = { value: '', label: '' };
+ shortforms.subjectList = '';
+ cacheShortforms([Number(shortforms.standardList)]);
+ return;
+ }
console.log('onSelectedSubjectListChange', e);
shortforms.subjectList = e.value;
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
@@ -26,17 +32,27 @@
console.log('submit', listSelectorForm);
};
- let listSelectorForm = {
+ $: listSelectorForm = {
standard: { value: '', label: '' },
- subject: { value: '', label: '' }
+ subject: {}
+ };
+
+ const getListFromId = (lists, id) => {
+ return lists.filter((l) => l.id == id)[0];
};
let standardLists = [];
let subjectLists = [];
onMount(() => {
+ //console.log($state.snapshot(shortforms));
db.lists.toArray().then((lists) => {
standardLists = lists.filter((l) => l.type == 0);
subjectLists = lists.filter((l) => l.type == 1);
+ const standard = getListFromId(standardLists, shortforms.standardList);
+ listSelectorForm.standard = { value: standard.id, label: standard.name };
+ const subject = getListFromId(subjectLists, shortforms.subjectList);
+ listSelectorForm.subject = { value: subject.id, label: subject.name };
+ console.log(listSelectorForm);
});
});
@@ -83,6 +99,7 @@
+ Ingen lista vald
{#each subjectLists as list}
{list.name}
{/each}