Handle PXXs below 4
All checks were successful
Build Formula12 Docker Image / pocketbase-docker (push) Successful in 1m19s
All checks were successful
Build Formula12 Docker Image / pocketbase-docker (push) Successful in 1m19s
This commit is contained in:
@ -66,11 +66,24 @@
|
|||||||
return raceresults.map((raceresult: RaceResult) => raceresult.race);
|
return raceresults.map((raceresult: RaceResult) => raceresult.race);
|
||||||
});
|
});
|
||||||
|
|
||||||
let pxxs_placeholder: string = $derived(
|
let pxxs_placeholder: string = $derived.by(() => {
|
||||||
currentrace
|
if (!currentrace) {
|
||||||
? `Select P${(currentrace.pxx ?? -10) - 3} to P${(currentrace.pxx ?? -10) + 3}...`
|
return "Select race first...";
|
||||||
: `Select race first...`,
|
}
|
||||||
);
|
|
||||||
|
let start = Math.max(1, (currentrace.pxx ?? -10) - 3);
|
||||||
|
let end = start + 6;
|
||||||
|
|
||||||
|
if (currentrace.pxx === 1) {
|
||||||
|
end = start + 3;
|
||||||
|
} else if (currentrace.pxx === 2) {
|
||||||
|
end = start + 4;
|
||||||
|
} else if (currentrace.pxx === 3) {
|
||||||
|
end = start + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `Select P${start} to P${end}...`;
|
||||||
|
});
|
||||||
|
|
||||||
let pxxs_input: string = $state("");
|
let pxxs_input: string = $state("");
|
||||||
let pxxs_chips: string[] = $state([]);
|
let pxxs_chips: string[] = $state([]);
|
||||||
@ -133,7 +146,7 @@
|
|||||||
const on_pxxs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
|
const on_pxxs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
|
||||||
if (disabled || !drivers) return;
|
if (disabled || !drivers) return;
|
||||||
|
|
||||||
// Can only select 7 drivers
|
// Can only select 7 drivers or less
|
||||||
if (pxxs_chips.length >= 7) return;
|
if (pxxs_chips.length >= 7) return;
|
||||||
|
|
||||||
// Can only select a driver once
|
// Can only select a driver once
|
||||||
|
|||||||
@ -59,11 +59,13 @@
|
|||||||
valuefun: async (value: string): Promise<string> => {
|
valuefun: async (value: string): Promise<string> => {
|
||||||
if (value.length === 0 || value === "") return "";
|
if (value.length === 0 || value === "") return "";
|
||||||
|
|
||||||
|
|
||||||
const pxxs_array: string[] = value.toString().split(",");
|
const pxxs_array: string[] = value.toString().split(",");
|
||||||
|
const offset: number = 7 - pxxs_array.length;
|
||||||
const pxxs_codes: string[] = await Promise.all(
|
const pxxs_codes: string[] = await Promise.all(
|
||||||
pxxs_array.map(
|
pxxs_array.map(
|
||||||
async (id: string, index: number) =>
|
async (id: string, index: number) =>
|
||||||
`<span class='w-10 badge mr-2 text-center' style='background: ${PXX_COLORS[index]};'>${get_by_value(await data.drivers, "id", id)?.code ?? "Invalid"}</span>`,
|
`<span class='w-10 badge mr-2 text-center' style='background: ${PXX_COLORS[index + offset]};'>${get_by_value(await data.drivers, "id", id)?.code ?? "Invalid"}</span>`,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -318,8 +318,8 @@
|
|||||||
{#each result.pxxs as pxx, index}
|
{#each result.pxxs as pxx, index}
|
||||||
{@const driver = get_by_value(drivers, "id", pxx)}
|
{@const driver = get_by_value(drivers, "id", pxx)}
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<span class="w-8">P{(race?.pxx ?? -100) - 3 + index}:</span>
|
<span class="w-8">P{Math.max(1, (race?.pxx ?? -100) - 3) + index}:</span>
|
||||||
<span class="badge w-10 p-1 text-center" style="background: {PXX_COLORS[index]};">
|
<span class="badge w-10 p-1 text-center" style="background: {PXX_COLORS[index + (7 - result.pxxs.length)]};">
|
||||||
{driver?.code}
|
{driver?.code}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -355,7 +355,7 @@
|
|||||||
{#each raceresults as result}
|
{#each raceresults as result}
|
||||||
{@const race = get_by_value(races, "id", result.race)}
|
{@const race = get_by_value(races, "id", result.race)}
|
||||||
{@const pick = picks.filter((pick: RacePick) => pick.race === race?.id)[0]}
|
{@const pick = picks.filter((pick: RacePick) => pick.race === race?.id)[0]}
|
||||||
{@const pxxcolor = PXX_COLORS[result.pxxs.indexOf(pick?.pxx ?? "Invalid")]}
|
{@const pxxcolor = PXX_COLORS[result.pxxs.indexOf(pick?.pxx ?? "Invalid") + (7 - result.pxxs.length)]}
|
||||||
{@const dnfcolor =
|
{@const dnfcolor =
|
||||||
result.dnfs.indexOf(pick?.dnf ?? "Invalid") >= 0 ? PXX_COLORS[3] : PXX_COLORS[-1]}
|
result.dnfs.indexOf(pick?.dnf ?? "Invalid") >= 0 ? PXX_COLORS[3] : PXX_COLORS[-1]}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user