diff --git a/src/components/cards/AddCardModal.svelte b/src/components/cards/AddCardModal.svelte index 685129a8..fce139c5 100644 --- a/src/components/cards/AddCardModal.svelte +++ b/src/components/cards/AddCardModal.svelte @@ -12,17 +12,22 @@ export let modal_open; export let current_cards; - const getRunnerLabel = (option) => - { - if(option.middlename){ + const getRunnerLabel = (option) => { + if (option.middlename) { return option.firstname + " " + option.middlename + " " + option.lastname; } return option.firstname + " " + option.lastname; - } - - const filterRunners = (label, filterText, option) => - label.toLowerCase().includes(filterText.toLowerCase()) || - option.value.toString().startsWith(filterText.toLowerCase()); + }; + + const filterRunners = (label, filterText, option) => { + if (filterText.startsWith("#")) { + return option.value.id == parseInt(filterText.replace("#","")) + } + return ( + label.toLowerCase().includes(filterText.toLowerCase()) || + option.value.toString().startsWith(filterText.toLowerCase()) + ); + }; function focus(el) { el.focus(); } @@ -155,19 +160,19 @@ class="block text-sm font-medium text-gray-700" >{$_("runner")} - + filterRunners(label, filterText, option)} + items={runners} + bind:loading + showChevron={!loading} + placeholder={$_("search-for-runner-by-name-or-id")} + noOptionsMessage={$_("no-runners-found")} + on:select={(selectedValue) => + (runner = selectedValue.detail.value.id)} + on:clear={() => (runner = null)} + />