Lib: Only show races without result present in RaceResultCard race dropdown
All checks were successful
Build Formula11 Docker Image / pocketbase-docker (push) Successful in 27s
All checks were successful
Build Formula11 Docker Image / pocketbase-docker (push) Successful in 27s
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
type ModalStore,
|
type ModalStore,
|
||||||
type ToastStore,
|
type ToastStore,
|
||||||
} from "@skeletonlabs/skeleton";
|
} from "@skeletonlabs/skeleton";
|
||||||
import { Button, Card, Dropdown } from "$lib/components";
|
import { Button, Card, Dropdown, type DropdownOption } from "$lib/components";
|
||||||
import type { Driver, Race, RaceResult, Substitution } from "$lib/schema";
|
import type { Driver, Race, RaceResult, Substitution } from "$lib/schema";
|
||||||
import { get_by_value } from "$lib/database";
|
import { get_by_value } from "$lib/database";
|
||||||
import { race_dropdown_options } from "$lib/dropdown";
|
import { race_dropdown_options } from "$lib/dropdown";
|
||||||
@ -46,6 +46,9 @@
|
|||||||
let substitutions: Substitution[] | undefined = $state(undefined);
|
let substitutions: Substitution[] | undefined = $state(undefined);
|
||||||
data.substitutions.then((s: Substitution[]) => (substitutions = s));
|
data.substitutions.then((s: Substitution[]) => (substitutions = s));
|
||||||
|
|
||||||
|
let raceresults: RaceResult[] | undefined = $state(undefined);
|
||||||
|
data.raceresults.then((r: RaceResult[]) => (raceresults = r));
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const labelwidth: string = "70px";
|
const labelwidth: string = "70px";
|
||||||
|
|
||||||
@ -58,6 +61,11 @@
|
|||||||
get_by_value<Race>(races ?? [], "id", race_select_value) ?? undefined,
|
get_by_value<Race>(races ?? [], "id", race_select_value) ?? undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let present_results: string[] = $derived.by(() => {
|
||||||
|
if (!raceresults || raceresults.length === 0) return [];
|
||||||
|
return raceresults.map((raceresult: RaceResult) => raceresult.race);
|
||||||
|
});
|
||||||
|
|
||||||
let pxxs_placeholder: string = $derived(
|
let pxxs_placeholder: string = $derived(
|
||||||
currentrace
|
currentrace
|
||||||
? `Select P${(currentrace.pxx ?? -10) - 3} to P${(currentrace.pxx ?? -10) + 3}...`
|
? `Select P${(currentrace.pxx ?? -10) - 3} to P${(currentrace.pxx ?? -10) + 3}...`
|
||||||
@ -227,7 +235,9 @@
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
name="race"
|
name="race"
|
||||||
bind:value={race_select_value}
|
bind:value={race_select_value}
|
||||||
options={race_dropdown_options(races)}
|
options={race_dropdown_options(races).filter(
|
||||||
|
(option: DropdownOption) => !present_results.includes(option.value),
|
||||||
|
)}
|
||||||
{labelwidth}
|
{labelwidth}
|
||||||
{disabled}
|
{disabled}
|
||||||
{required}
|
{required}
|
||||||
|
Reference in New Issue
Block a user