wip
This commit is contained in:
parent
b89d4f248c
commit
6ef6dc0078
@ -5,9 +5,9 @@
|
|||||||
DonorService,
|
DonorService,
|
||||||
RunnerService,
|
RunnerService,
|
||||||
} from "@odit/lfk-client-js";
|
} from "@odit/lfk-client-js";
|
||||||
import Select from "svelte-select";
|
|
||||||
import toast from "svelte-french-toast";
|
import toast from "svelte-french-toast";
|
||||||
import VirtualSelect from "./VirtualSelect.svelte";
|
import VirtualSelect from "./VirtualSelect.svelte";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
let runners = [];
|
let runners = [];
|
||||||
let donors = [];
|
let donors = [];
|
||||||
@ -63,23 +63,8 @@
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterRunners = (label, filterText, option) => {
|
let selectRefRunner;
|
||||||
if (filterText.startsWith("#")) {
|
let selectRefDonor;
|
||||||
return option.value.id == parseInt(filterText.replace("#", ""));
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
label.toLowerCase().includes(filterText.toLowerCase()) ||
|
|
||||||
option.value.toString().startsWith(filterText.toLowerCase())
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
let selectRef;
|
|
||||||
// function resetComponent() {
|
|
||||||
// if (selectRef) {
|
|
||||||
// selectRef.reset();
|
|
||||||
// console.log("Component state reset");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
function resetAll() {
|
function resetAll() {
|
||||||
runnerinfo = { id: 0, firstname: "", lastname: "" };
|
runnerinfo = { id: 0, firstname: "", lastname: "" };
|
||||||
@ -87,14 +72,13 @@
|
|||||||
amount = 0;
|
amount = 0;
|
||||||
address_checked = false;
|
address_checked = false;
|
||||||
donor_create_new = false;
|
donor_create_new = false;
|
||||||
// const clears = document.querySelectorAll(".clearSelect");
|
selectRefRunner.reset();
|
||||||
// clears.forEach((c) => {
|
selectRefDonor.reset();
|
||||||
// c.click();
|
|
||||||
// });
|
|
||||||
// resetComponent();
|
|
||||||
selectRef.reset();
|
|
||||||
document.querySelector("#jjqzqicxujrnnh1x3447x18x").focus();
|
document.querySelector("#jjqzqicxujrnnh1x3447x18x").focus();
|
||||||
}
|
}
|
||||||
|
onMount(() => {
|
||||||
|
document.querySelector("#jjqzqicxujrnnh1x3447x18x").focus();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
@ -117,8 +101,7 @@
|
|||||||
<h4 class="text-xl font-semibold">{$_("runner")}</h4>
|
<h4 class="text-xl font-semibold">{$_("runner")}</h4>
|
||||||
<VirtualSelect
|
<VirtualSelect
|
||||||
inputElementID="jjqzqicxujrnnh1x3447x18x"
|
inputElementID="jjqzqicxujrnnh1x3447x18x"
|
||||||
bind:this={selectRef}
|
bind:this={selectRefRunner}
|
||||||
autofocus={true}
|
|
||||||
on:onClear={() => {
|
on:onClear={() => {
|
||||||
console.log("Cleared selection");
|
console.log("Cleared selection");
|
||||||
}}
|
}}
|
||||||
@ -140,9 +123,6 @@
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<!-- {#if runnerinfo}
|
|
||||||
<p class="mt-4 text-lg">Selected: {JSON.stringify(runnerinfo)}</p>
|
|
||||||
{/if} -->
|
|
||||||
|
|
||||||
<!-- Amount Input -->
|
<!-- Amount Input -->
|
||||||
<div>
|
<div>
|
||||||
@ -221,19 +201,27 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if !donor_create_new}
|
{#if !donor_create_new}
|
||||||
<Select
|
<VirtualSelect
|
||||||
containerClasses="rounded-md mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 border bg-gray-50 text-neutral-800 rounded-md p-2"
|
inputElementID="zt12c3udy3bme5bqobmqcif1"
|
||||||
itemFilter={(label, filterText, option) =>
|
bind:this={selectRefDonor}
|
||||||
filterRunners(label, filterText, option)}
|
on:onClear={() => {
|
||||||
items={donors}
|
console.log("Cleared selection");
|
||||||
showChevron={true}
|
}}
|
||||||
placeholder={$_("search-for-donor")}
|
options={donors}
|
||||||
noOptionsMessage={$_("no-donors-found")}
|
filterFn={(item, searchTerm) => {
|
||||||
on:select={(selectedValue) => {
|
return item.label
|
||||||
donorinfo = selectedValue.detail.value;
|
.toLowerCase()
|
||||||
|
.includes(searchTerm.toLowerCase());
|
||||||
|
}}
|
||||||
|
bind:selected={donorinfo}
|
||||||
|
inputAriaLabel={$_("search-for-donor")}
|
||||||
|
inputPlaceholder={$_("search-for-donor")}
|
||||||
|
noOptionsText={$_("no-donors-found")}
|
||||||
|
on:onSelected={(data) => {
|
||||||
|
if (data.detail !== null) {
|
||||||
|
document.querySelector("#submit_button").focus();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
on:clear={() =>
|
|
||||||
(donorinfo = { id: 0, firstname: "", lastname: "" })}
|
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
|
@ -107,8 +107,7 @@
|
|||||||
async function toggleDropdown() {
|
async function toggleDropdown() {
|
||||||
isOpen = !isOpen;
|
isOpen = !isOpen;
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
// Update visible count when dropdown opens
|
forceVisibleItems();
|
||||||
await updateVisibleCount(); // Ensure container is rendered
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +121,15 @@
|
|||||||
|
|
||||||
// Handle input focus to open dropdown
|
// Handle input focus to open dropdown
|
||||||
async function handleInputFocus() {
|
async function handleInputFocus() {
|
||||||
|
// forceVisibleItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle input typing to open dropdown
|
||||||
|
async function handleInput() {
|
||||||
|
forceVisibleItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function forceVisibleItems() {
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
await updateVisibleCount(); // Ensure items render on focus
|
await updateVisibleCount(); // Ensure items render on focus
|
||||||
// these 2 timeouts are a more or less tmp fix for rendering items when dropdown opens
|
// these 2 timeouts are a more or less tmp fix for rendering items when dropdown opens
|
||||||
@ -133,12 +141,6 @@
|
|||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle input typing to open dropdown
|
|
||||||
async function handleInput() {
|
|
||||||
isOpen = true;
|
|
||||||
await updateVisibleCount(); // Ensure items render on typing
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle keyboard navigation
|
// Handle keyboard navigation
|
||||||
function handleKeydown(event, index) {
|
function handleKeydown(event, index) {
|
||||||
if (!isOpen) return;
|
if (!isOpen) return;
|
||||||
|
@ -227,7 +227,7 @@
|
|||||||
"enabled_large": "Aktiviert",
|
"enabled_large": "Aktiviert",
|
||||||
"english": "Englisch",
|
"english": "Englisch",
|
||||||
"enter-payment": "Zahlung eingeben",
|
"enter-payment": "Zahlung eingeben",
|
||||||
"error-creating-donation": "Fehler bei der Anlage",
|
"error-creating-donation": "Fehler beim Erstellen des Sponsorings",
|
||||||
"error-during-import": "Fehler beim Importieren",
|
"error-during-import": "Fehler beim Importieren",
|
||||||
"error-whyile-copying-to-clipboard": "Fehler beim Kopieren in die Zwischenablage",
|
"error-whyile-copying-to-clipboard": "Fehler beim Kopieren in die Zwischenablage",
|
||||||
"error_on_login": "😢Fehler beim Login",
|
"error_on_login": "😢Fehler beim Login",
|
||||||
|
@ -227,6 +227,7 @@
|
|||||||
"enabled_large": "Enabled",
|
"enabled_large": "Enabled",
|
||||||
"english": "English",
|
"english": "English",
|
||||||
"enter-payment": "Enter payment",
|
"enter-payment": "Enter payment",
|
||||||
|
"error-creating-donation": "error creating the sponsoring",
|
||||||
"error-during-import": "Error during import",
|
"error-during-import": "Error during import",
|
||||||
"error-whyile-copying-to-clipboard": "Error while copying to clipboard",
|
"error-whyile-copying-to-clipboard": "Error while copying to clipboard",
|
||||||
"error_on_login": "Error on login",
|
"error_on_login": "Error on login",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user