listväljarrutan har giltiga ursprungsvärden
This commit is contained in:
parent
84d874f81f
commit
02f41e57c1
@ -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
|
||||
<Input bind:value={form.name} placeholder="Döp förkortningslistan" class="w-[290px]" />
|
||||
</div>
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label>Prioritera lista</Label>
|
||||
<Label>Skapa ämneslista</Label>
|
||||
<Switch bind:checked={form.type} />
|
||||
</div>
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -83,6 +99,7 @@
|
||||
</Select.Trigger>
|
||||
|
||||
<Select.Content>
|
||||
<Select.Item value={0} label="Ingen lista vald">Ingen lista vald</Select.Item>
|
||||
{#each subjectLists as list}
|
||||
<Select.Item value={list.id} label={list.name}>{list.name}</Select.Item>
|
||||
{/each}
|
||||
|
Loading…
x
Reference in New Issue
Block a user