listväljarrutan har giltiga ursprungsvärden
This commit is contained in:
parent
84d874f81f
commit
02f41e57c1
@ -21,7 +21,7 @@
|
|||||||
$: form = {
|
$: form = {
|
||||||
textarea: '',
|
textarea: '',
|
||||||
name: '',
|
name: '',
|
||||||
type: false
|
type: true
|
||||||
};
|
};
|
||||||
let importing = false;
|
let importing = false;
|
||||||
let progress = 0;
|
let progress = 0;
|
||||||
@ -92,7 +92,7 @@ förkn=förkortningen
|
|||||||
<Input bind:value={form.name} placeholder="Döp förkortningslistan" class="w-[290px]" />
|
<Input bind:value={form.name} placeholder="Döp förkortningslistan" class="w-[290px]" />
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label>Prioritera lista</Label>
|
<Label>Skapa ämneslista</Label>
|
||||||
<Switch bind:checked={form.type} />
|
<Switch bind:checked={form.type} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -12,10 +12,16 @@
|
|||||||
const onSelectedStandardListChange = (e) => {
|
const onSelectedStandardListChange = (e) => {
|
||||||
console.log('onSelectedStandardListChange', e);
|
console.log('onSelectedStandardListChange', e);
|
||||||
shortforms.standardList = e.value;
|
shortforms.standardList = e.value;
|
||||||
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectLists)]);
|
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelectedSubjectListChange = (e) => {
|
const onSelectedSubjectListChange = (e) => {
|
||||||
|
if (e.value == 0) {
|
||||||
|
listSelectorForm.subject = { value: '', label: '' };
|
||||||
|
shortforms.subjectList = '';
|
||||||
|
cacheShortforms([Number(shortforms.standardList)]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.log('onSelectedSubjectListChange', e);
|
console.log('onSelectedSubjectListChange', e);
|
||||||
shortforms.subjectList = e.value;
|
shortforms.subjectList = e.value;
|
||||||
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
|
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
|
||||||
@ -26,17 +32,27 @@
|
|||||||
console.log('submit', listSelectorForm);
|
console.log('submit', listSelectorForm);
|
||||||
};
|
};
|
||||||
|
|
||||||
let listSelectorForm = {
|
$: listSelectorForm = {
|
||||||
standard: { value: '', label: '' },
|
standard: { value: '', label: '' },
|
||||||
subject: { value: '', label: '' }
|
subject: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getListFromId = (lists, id) => {
|
||||||
|
return lists.filter((l) => l.id == id)[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
let standardLists = [];
|
let standardLists = [];
|
||||||
let subjectLists = [];
|
let subjectLists = [];
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
//console.log($state.snapshot(shortforms));
|
||||||
db.lists.toArray().then((lists) => {
|
db.lists.toArray().then((lists) => {
|
||||||
standardLists = lists.filter((l) => l.type == 0);
|
standardLists = lists.filter((l) => l.type == 0);
|
||||||
subjectLists = lists.filter((l) => l.type == 1);
|
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>
|
</script>
|
||||||
@ -83,6 +99,7 @@
|
|||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
|
|
||||||
<Select.Content>
|
<Select.Content>
|
||||||
|
<Select.Item value={0} label="Ingen lista vald">Ingen lista vald</Select.Item>
|
||||||
{#each subjectLists as list}
|
{#each subjectLists as list}
|
||||||
<Select.Item value={list.id} label={list.name}>{list.name}</Select.Item>
|
<Select.Item value={list.id} label={list.name}>{list.name}</Select.Item>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user