Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d76bbe8979 | ||
|
|
3d51ea3e10 |
@@ -33,11 +33,42 @@
|
|||||||
const required: boolean = $derived(!result);
|
const required: boolean = $derived(!result);
|
||||||
const disabled: boolean = $derived(!data.admin);
|
const disabled: boolean = $derived(!data.admin);
|
||||||
const labelwidth: string = "70px";
|
const labelwidth: string = "70px";
|
||||||
|
|
||||||
|
let race_select_value: string = $state(result?.race ?? "");
|
||||||
|
|
||||||
|
// TODO: Currentrace needs to be updated once a race is selected
|
||||||
|
// This way it doesn't update the placeholder (or the chips)...
|
||||||
const currentrace: Promise<Race | undefined> = $derived.by(async () =>
|
const currentrace: Promise<Race | undefined> = $derived.by(async () =>
|
||||||
get_by_value(await data.races, "id", result?.race ?? "Invalid"),
|
get_by_value(await data.races, "id", race_select_value),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let pxxs_input: string = $state("");
|
||||||
|
let pxxs_chips: string[] = $state([]);
|
||||||
|
|
||||||
|
let dnfs_input: string = $state("");
|
||||||
|
let dnfs_chips: string[] = $state([]);
|
||||||
|
|
||||||
|
// This is the actual data that gets sent through the form
|
||||||
|
let pxxs_ids: string[] = $state(result?.pxxs ?? []);
|
||||||
|
let dnfs_ids: string[] = $state(result?.dnfs ?? []);
|
||||||
|
|
||||||
const pxxs_options: Promise<AutocompleteOption<string>[]> = $derived.by(async () =>
|
const pxxs_options: Promise<AutocompleteOption<string>[]> = $derived.by(async () =>
|
||||||
|
(await data.drivers)
|
||||||
|
.filter((driver: Driver) => {
|
||||||
|
// Filter out all drivers that are already selected
|
||||||
|
return !pxxs_ids.includes(driver.id);
|
||||||
|
})
|
||||||
|
.map((driver: Driver) => {
|
||||||
|
return {
|
||||||
|
// NOTE: Because Skeleton displays the values inside the autocomplete input,
|
||||||
|
// we have to supply the driver code twice and manage a list of ids manually (ugh)
|
||||||
|
label: driver.code,
|
||||||
|
value: driver.code,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const dnfs_options: Promise<AutocompleteOption<string>[]> = $derived.by(async () =>
|
||||||
(await data.drivers).map((driver: Driver) => {
|
(await data.drivers).map((driver: Driver) => {
|
||||||
return {
|
return {
|
||||||
// NOTE: Because Skeleton displays the values inside the autocomplete input,
|
// NOTE: Because Skeleton displays the values inside the autocomplete input,
|
||||||
@@ -54,18 +85,6 @@
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
let race_select_value: string = $state(result?.race ?? "");
|
|
||||||
|
|
||||||
let pxxs_input: string = $state("");
|
|
||||||
let pxxs_chips: string[] = $state([]);
|
|
||||||
|
|
||||||
let dnfs_input: string = $state("");
|
|
||||||
let dnfs_chips: string[] = $state([]);
|
|
||||||
|
|
||||||
// This is the actual data that gets sent through the form
|
|
||||||
let pxxs_ids: string[] = $state(result?.pxxs ?? []);
|
|
||||||
let dnfs_ids: string[] = $state(result?.dnfs ?? []);
|
|
||||||
|
|
||||||
const on_pxxs_chip_select = async (
|
const on_pxxs_chip_select = async (
|
||||||
event: CustomEvent<AutocompleteOption<string>>,
|
event: CustomEvent<AutocompleteOption<string>>,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
@@ -210,7 +229,7 @@
|
|||||||
/>
|
/>
|
||||||
{/await}
|
{/await}
|
||||||
<div class="card max-h-48 w-full overflow-y-auto p-2" tabindex="-1">
|
<div class="card max-h-48 w-full overflow-y-auto p-2" tabindex="-1">
|
||||||
{#await pxxs_options then options}
|
{#await dnfs_options then options}
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
bind:input={dnfs_input}
|
bind:input={dnfs_input}
|
||||||
{options}
|
{options}
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ export const load: PageServerLoad = async ({ fetch, locals }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentrace: await fetch_currentrace(),
|
|
||||||
|
|
||||||
racepicks: fetch_racepicks(),
|
racepicks: fetch_racepicks(),
|
||||||
currentpickedusers: fetch_currentpickedusers(),
|
currentpickedusers: fetch_currentpickedusers(),
|
||||||
raceresults: fetch_raceresults(),
|
raceresults: fetch_raceresults(),
|
||||||
|
|
||||||
|
currentrace: await fetch_currentrace(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user