Compare commits
3 Commits
705b66f638
...
91fc3ae7a2
| Author | SHA1 | Date | |
|---|---|---|---|
| 91fc3ae7a2 | |||
| 88fb24a20c | |||
| 6f4b5e45cc |
@ -46,7 +46,7 @@
|
|||||||
data.substitutions.then((s: Substitution[]) => (substitutions = s));
|
data.substitutions.then((s: Substitution[]) => (substitutions = s));
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const labelwidth: string = "60px";
|
const labelwidth: string = "70px";
|
||||||
|
|
||||||
// Reactive state
|
// Reactive state
|
||||||
let required: boolean = $derived(!racepick);
|
let required: boolean = $derived(!racepick);
|
||||||
@ -84,6 +84,18 @@
|
|||||||
const img: HTMLImageElement = document.getElementById("headshot_preview") as HTMLImageElement;
|
const img: HTMLImageElement = document.getElementById("headshot_preview") as HTMLImageElement;
|
||||||
if (img) img.src = src;
|
if (img) img.src = src;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const random_select_handler = (event: Event): void => {
|
||||||
|
pxx_select_value =
|
||||||
|
active_drivers_and_substitutes[
|
||||||
|
Math.floor(Math.random() * active_drivers_and_substitutes.length)
|
||||||
|
].id;
|
||||||
|
|
||||||
|
dnf_select_value =
|
||||||
|
active_drivers_and_substitutes[
|
||||||
|
Math.floor(Math.random() * active_drivers_and_substitutes.length)
|
||||||
|
].id;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await Promise.all([data.graphics, data.drivers]) then [graphics, drivers]}
|
{#await Promise.all([data.graphics, data.drivers]) then [graphics, drivers]}
|
||||||
@ -136,6 +148,10 @@
|
|||||||
DNF
|
DNF
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|
||||||
|
<Button color="tertiary" {disabled} width="w-full" onclick={random_select_handler}>
|
||||||
|
Select Random
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- Save/Delete buttons -->
|
<!-- Save/Delete buttons -->
|
||||||
<div class="flex justify-end gap-2">
|
<div class="flex justify-end gap-2">
|
||||||
{#if racepick}
|
{#if racepick}
|
||||||
|
|||||||
@ -118,7 +118,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const on_pxxs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
|
const on_pxxs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
|
||||||
if (disabled) return;
|
if (disabled || !currentrace || !drivers) return;
|
||||||
|
|
||||||
// Can only select 7 drivers
|
// Can only select 7 drivers
|
||||||
if (pxxs_chips.length >= 7) return;
|
if (pxxs_chips.length >= 7) return;
|
||||||
@ -127,11 +127,11 @@
|
|||||||
if (pxxs_chips.some((label: string) => label.endsWith(event.detail.value))) return;
|
if (pxxs_chips.some((label: string) => label.endsWith(event.detail.value))) return;
|
||||||
|
|
||||||
// Manage labels that are displayed
|
// Manage labels that are displayed
|
||||||
pxxs_chips.push(`P${(currentrace?.pxx ?? -10) + pxxs_chips.length - 3}: ${event.detail.value}`);
|
pxxs_chips.push(`P${currentrace.pxx + pxxs_chips.length - 3}: ${event.detail.value}`);
|
||||||
pxxs_input = "";
|
pxxs_input = "";
|
||||||
|
|
||||||
// Manage ids that are submitted via form
|
// Manage ids that are submitted via form
|
||||||
const id: string = get_by_value(drivers ?? [], "code", event.detail.value)?.id ?? "Invalid";
|
const id: string = get_by_value(drivers, "code", event.detail.value)?.id ?? "Invalid";
|
||||||
if (!pxxs_ids.includes(id)) {
|
if (!pxxs_ids.includes(id)) {
|
||||||
pxxs_ids.push(id);
|
pxxs_ids.push(id);
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const on_dnfs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
|
const on_dnfs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
|
||||||
if (disabled) return;
|
if (disabled || !drivers) return;
|
||||||
|
|
||||||
// Can only select a driver once
|
// Can only select a driver once
|
||||||
if (dnfs_chips.includes(event.detail.value)) return;
|
if (dnfs_chips.includes(event.detail.value)) return;
|
||||||
@ -157,7 +157,7 @@
|
|||||||
dnfs_input = "";
|
dnfs_input = "";
|
||||||
|
|
||||||
// Manage ids that are submitted via form
|
// Manage ids that are submitted via form
|
||||||
const id: string = get_by_value(drivers ?? [], "code", event.detail.value)?.id ?? "Invalid";
|
const id: string = get_by_value(drivers, "code", event.detail.value)?.id ?? "Invalid";
|
||||||
if (!dnfs_ids.includes(id)) {
|
if (!dnfs_ids.includes(id)) {
|
||||||
dnfs_ids.push(id);
|
dnfs_ids.push(id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user