Compare commits
6 Commits
3709881176
...
feature/cu
| Author | SHA1 | Date | |
|---|---|---|---|
|
77413c7e53
|
|||
|
72e5425c08
|
|||
|
53f5fa3988
|
|||
|
6ef6dc0078
|
|||
|
b89d4f248c
|
|||
|
444b1f5370
|
@@ -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,38 +63,22 @@
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
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: "" };
|
||||||
donorinfo = { id: 0, firstname: "", lastname: "" };
|
donorinfo = { id: 0, firstname: "", lastname: "" };
|
||||||
amount = 0;
|
amount = null;
|
||||||
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");
|
||||||
}}
|
}}
|
||||||
@@ -134,13 +117,12 @@
|
|||||||
inputAriaLabel={$_("search-for-runner-by-name-or-id")}
|
inputAriaLabel={$_("search-for-runner-by-name-or-id")}
|
||||||
inputPlaceholder={$_("search-for-runner-by-name-or-id")}
|
inputPlaceholder={$_("search-for-runner-by-name-or-id")}
|
||||||
noOptionsText={$_("no-runners-found")}
|
noOptionsText={$_("no-runners-found")}
|
||||||
on:onSelected={() => {
|
on:onSelected={(data) => {
|
||||||
document.querySelector("#donation_amount_eur").focus();
|
if (data.detail !== null) {
|
||||||
|
document.querySelector("#donation_amount_eur").focus();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<!-- {#if runnerinfo}
|
|
||||||
<p class="mt-4 text-lg">Selected: {JSON.stringify(runnerinfo)}</p>
|
|
||||||
{/if} -->
|
|
||||||
|
|
||||||
<!-- Amount Input -->
|
<!-- Amount Input -->
|
||||||
<div>
|
<div>
|
||||||
@@ -186,6 +168,10 @@
|
|||||||
document.querySelector("#button_new_donor").focus();
|
document.querySelector("#button_new_donor").focus();
|
||||||
document.querySelector("#button_new_donor").click();
|
document.querySelector("#button_new_donor").click();
|
||||||
}
|
}
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
document.querySelector("#zt12c3udy3bme5bqobmqcif1").focus();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
id="button_existing_donor"
|
id="button_existing_donor"
|
||||||
class:bg-indigo-600={!donor_create_new}
|
class:bg-indigo-600={!donor_create_new}
|
||||||
@@ -205,12 +191,19 @@
|
|||||||
document.querySelector("#button_existing_donor").focus();
|
document.querySelector("#button_existing_donor").focus();
|
||||||
document.querySelector("#button_existing_donor").click();
|
document.querySelector("#button_existing_donor").click();
|
||||||
}
|
}
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
document.querySelector("#button_new_donor").click();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
id="button_new_donor"
|
id="button_new_donor"
|
||||||
class={`py-2 px-4 w-1/2 transition-colors ${donor_create_new ? "bg-indigo-600 text-white" : "bg-gray-100 text-gray-700"}`}
|
class={`py-2 px-4 w-1/2 transition-colors ${donor_create_new ? "bg-indigo-600 text-white" : "bg-gray-100 text-gray-700"}`}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
donor_create_new = true;
|
donor_create_new = true;
|
||||||
donorinfo = { id: 0, firstname: "", lastname: "" };
|
donorinfo = { id: 0, firstname: "", lastname: "" };
|
||||||
|
setTimeout(() => {
|
||||||
|
document.querySelector("#firstname").focus();
|
||||||
|
}, 50);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{$_("new-donor")}
|
{$_("new-donor")}
|
||||||
@@ -219,19 +212,31 @@
|
|||||||
</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) => {
|
||||||
|
console.log(data.detail);
|
||||||
|
if (data.detail !== null) {
|
||||||
|
document.querySelector("#submit_button").focus();
|
||||||
|
setTimeout(() => {
|
||||||
|
document.querySelector("#submit_button").focus();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
on:clear={() =>
|
|
||||||
(donorinfo = { id: 0, firstname: "", lastname: "" })}
|
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
@@ -246,6 +251,11 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="firstname"
|
id="firstname"
|
||||||
|
on:keydown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
document.querySelector("#lastname").focus();
|
||||||
|
}
|
||||||
|
}}
|
||||||
bind:value={donorinfo.firstname}
|
bind:value={donorinfo.firstname}
|
||||||
class="focus:ring-indigo-500 focus:border-indigo-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-neutral-300 border bg-neutral-50 text-neutral-800 p-2"
|
class="focus:ring-indigo-500 focus:border-indigo-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-neutral-300 border bg-neutral-50 text-neutral-800 p-2"
|
||||||
placeholder={$_("first-name")}
|
placeholder={$_("first-name")}
|
||||||
|
|||||||
@@ -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,14 +121,24 @@
|
|||||||
|
|
||||||
// Handle input focus to open dropdown
|
// Handle input focus to open dropdown
|
||||||
async function handleInputFocus() {
|
async function handleInputFocus() {
|
||||||
isOpen = true;
|
// forceVisibleItems();
|
||||||
await updateVisibleCount(); // Ensure items render on focus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle input typing to open dropdown
|
// Handle input typing to open dropdown
|
||||||
async function handleInput() {
|
async function handleInput() {
|
||||||
|
forceVisibleItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function forceVisibleItems() {
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
await updateVisibleCount(); // Ensure items render on typing
|
await updateVisibleCount(); // Ensure items render on focus
|
||||||
|
// these 2 timeouts are a more or less tmp fix for rendering items when dropdown opens
|
||||||
|
setTimeout(async () => {
|
||||||
|
await updateVisibleCount(); // Ensure items render on focus
|
||||||
|
}, 25);
|
||||||
|
setTimeout(async () => {
|
||||||
|
await updateVisibleCount(); // Ensure items render on focus
|
||||||
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle keyboard navigation
|
// Handle keyboard navigation
|
||||||
@@ -210,6 +219,7 @@
|
|||||||
aria-expanded={isOpen}
|
aria-expanded={isOpen}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
autocomplete="off"
|
||||||
type="text"
|
type="text"
|
||||||
id={inputElementID}
|
id={inputElementID}
|
||||||
bind:value={searchTerm}
|
bind:value={searchTerm}
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user