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