You can now create cards from runners by searching via #runnerid

ref #162
This commit is contained in:
Nicolai Ort 2023-03-15 13:12:42 +01:00
parent 92b89cc4d8
commit e8a0ad6647
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F

View File

@ -12,17 +12,22 @@
export let modal_open; export let modal_open;
export let current_cards; export let current_cards;
const getRunnerLabel = (option) => const getRunnerLabel = (option) => {
{ if (option.middlename) {
if(option.middlename){
return option.firstname + " " + option.middlename + " " + option.lastname; return option.firstname + " " + option.middlename + " " + option.lastname;
} }
return option.firstname + " " + option.lastname; return option.firstname + " " + option.lastname;
} };
const filterRunners = (label, filterText, option) => const filterRunners = (label, filterText, option) => {
label.toLowerCase().includes(filterText.toLowerCase()) || if (filterText.startsWith("#")) {
option.value.toString().startsWith(filterText.toLowerCase()); return option.value.id == parseInt(filterText.replace("#",""))
}
return (
label.toLowerCase().includes(filterText.toLowerCase()) ||
option.value.toString().startsWith(filterText.toLowerCase())
);
};
function focus(el) { function focus(el) {
el.focus(); el.focus();
} }
@ -155,19 +160,19 @@
class="block text-sm font-medium text-gray-700" class="block text-sm font-medium text-gray-700"
>{$_("runner")}</label >{$_("runner")}</label
> >
<Select <Select
containerClasses="rounded-l-md mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-gray-500 rounded-md p-2" containerClasses="rounded-l-md mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm rounded-l-md sm:text-sm border-gray-300 border bg-gray-50 text-gray-500 rounded-md p-2"
itemFilter={(label, filterText, option) => itemFilter={(label, filterText, option) =>
filterRunners(label, filterText, option)} filterRunners(label, filterText, option)}
items={runners} items={runners}
bind:loading bind:loading
showChevron={!loading} showChevron={!loading}
placeholder={$_("search-for-runner-by-name-or-id")} placeholder={$_("search-for-runner-by-name-or-id")}
noOptionsMessage={$_("no-runners-found")} noOptionsMessage={$_("no-runners-found")}
on:select={(selectedValue) => on:select={(selectedValue) =>
(runner = selectedValue.detail.value.id)} (runner = selectedValue.detail.value.id)}
on:clear={() => (runner = null)} on:clear={() => (runner = null)}
/> />
</div> </div>
</div> </div>
</div> </div>