1
0
Fork 0
mirror of synced 2024-09-30 09:07:25 +13:00

Improve multiselect determintation of pretty labels

This commit is contained in:
Andrew Kingston 2021-04-16 11:32:05 +01:00
parent 6e9c3b7b5d
commit 48a85ae103

View file

@ -20,7 +20,10 @@
const getFieldText = (value, map, placeholder) => {
if (value?.length) {
const vals = value.map(option => map[option] || "").join(", ")
if (!map) {
return ""
}
const vals = value.map(option => map[option] || option).join(", ")
return `(${value.length}) ${vals}`
} else {
return placeholder || "Choose some options"
@ -40,8 +43,9 @@
}
const getOptionLookupMap = options => {
let map = {}
if (options) {
let map = null
if (options?.length) {
map = {}
options.forEach(option => {
const optionValue = getOptionValue(option)
if (optionValue != null) {