Applied the select fix to all things runner 🏃‍♀️🏃‍♂️

ref #98
This commit is contained in:
2021-03-18 15:35:39 +01:00
parent b541c93797
commit 0386d4e88a
2 changed files with 30 additions and 39 deletions

View File

@@ -11,7 +11,6 @@
import isMobilePhone from "validator/es/lib/isMobilePhone";
import Toastify from "toastify-js";
import Select from "svelte-select";
import AddDonationModal from "../donations/AddDonationModal.svelte";
export let modal_open;
export let current_runners;
$: selected_team = undefined;
@@ -22,11 +21,15 @@
let email_input;
let teams = [];
RunnerTeamService.runnerTeamControllerGetAll().then((val) => {
teams = val;
teams = val.map((r) => {
return { label: `${r.parentGroup.name} > ${r.name}`, value: r };
});
});
let orgs = [];
RunnerOrganizationService.runnerOrganizationControllerGetAll().then((val) => {
orgs = val;
orgs = val.map((r) => {
return { label: r.name, value: r };
});
});
function focus(el) {
el.focus();
@@ -230,30 +233,18 @@
class="block text-sm font-medium text-gray-700">{$_('team')}</label>
<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"
getSelectionLabel={(option) => {
if (option.responseType == 'RUNNERORGANIZATION') {
return option.name;
}
return `${option.parentGroup.name} &gt; ${option.name}`;
}}
getOptionLabel={(option) => {
if (option.responseType == 'RUNNERORGANIZATION') {
return option.name;
}
return `${option.parentGroup.name} &gt; ${option.name}`;
}}
itemFilter={(label, filterText, option) => label
.toLowerCase()
.includes(
filterText.toLowerCase()
) || option.id
) || option.value.id
.toString()
.startsWith(filterText.toLowerCase())}
items={orgs.concat(teams)}
showChevron={true}
placeholder={$_('search-for-an-organization-or-team-by-name-or-id')}
noOptionsMessage={$_('no-organization-or-team-found')}
on:select={(selectedValue) => (selected_team = selectedValue.detail.id)}
on:select={(selectedValue) => (selected_team = selectedValue.detail.value.id)}
on:clear={() => (selected_team = null)} />
</div>
<div class="col-span-6">