Fixed select bug for org detail 🏠

ref #98
This commit is contained in:
Nicolai Ort 2021-03-18 16:17:21 +01:00
parent 64311e9652
commit 82423ec467

View File

@ -20,6 +20,7 @@
let contacts = [];
export let params;
$: editable = {};
$: contact = {};
$: data_loaded = false;
$: data_changed = !(JSON.stringify(editable) === original);
$: isAddress1Valid = editable.address?.address1?.trim().length !== 0;
@ -46,9 +47,16 @@
editable = editable;
original_object = Object.assign(editable, value);
original = JSON.stringify(value);
});
GroupContactService.groupContactControllerGetAll().then((val) => {
contacts = val;
contacts = val.map((r) => {
return { label: getContactLabel(r), value: r };
});
if (editable.contact) {
contact = contacts.find((g) => g.value.id == editable.contact.id);
} else {
contact = null;
}
});
});
let modal_open = false;
let delete_org = {};
@ -359,18 +367,19 @@
class="font-medium text-gray-700">{$_('contact')}</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) => getContactLabel(option)}
getOptionLabel={(option) => getContactLabel(option)}
itemFilter={(label, filterText, option) => label
.toLowerCase()
.includes(
filterText.toLowerCase()
) || option.id.toString().startsWith(filterText.toLowerCase())}
) || option.value.id
.toString()
.startsWith(filterText.toLowerCase())}
items={contacts}
showChevron={true}
placeholder={$_('no-contact-selected')}
noOptionsMessage={$_('no-contact-found')}
bind:selectedValue={editable.contact}
bind:selectedValue={contact}
on:select={(selectedValue) => (editable.contact = selectedValue.detail.value)}
on:clear={() => (editable.contact = null)} />
</div>
<!-- -->