Now with custom label generation functions

ref #91
This commit is contained in:
Nicolai Ort 2021-03-14 17:04:09 +01:00
parent fe16c66cf2
commit 48b8dfe973

View File

@ -11,9 +11,8 @@
import Toastify from "toastify-js";
export let modal_open;
export let current_donations;
const getOptionLabel = (option) =>
const getDonorLabel = (option) =>
option.firstname + " " + (option.middlename || "") + " " + option.lastname;
const getSelectionLabel = getOptionLabel;
function focus(el) {
el.focus();
}
@ -210,25 +209,13 @@
for="donor"
class="block text-sm font-medium text-gray-700">{$_('donor')}</label>
<Select
class="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}
{getOptionLabel}
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) => (getDonorLabel(option))}
getOptionLabel= {(option) => (getDonorLabel(option))}
items={donors}
showChevron={true}
placeholder="Search for donor..."
on:select={(selected) => (donor = selected.detail.id)} />
<!-- <select
bind:value={donor}
class="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">
{#each donors as d}
<option value={d.id}>
{d.firstname}
{d.middlename || ''}
{d.lastname}
</option>
{/each}
</select> -->
</div>
{#if !is_fixed}
<div class="col-span-6">