Handle JSON in labels display (#7292)

Fixes #7278
This commit is contained in:
Rijk van Zanten
2021-08-09 22:57:50 +02:00
committed by GitHub
parent 5ad5544bf4
commit 8558beb07c

View File

@@ -81,17 +81,29 @@ export default defineComponent({
return items.map((item) => {
const choice = (props.choices || []).find((choice) => choice.value === item);
let itemStringValue: string;
if (typeof item === 'object') {
itemStringValue = JSON.stringify(item);
} else {
if (props.format) {
itemStringValue = formatTitle(item);
} else {
itemStringValue = item;
}
}
if (choice === undefined) {
return {
value: item,
text: props.format ? formatTitle(item) : item,
text: itemStringValue,
foreground: props.defaultForeground,
background: props.defaultBackground,
};
} else {
return {
value: item,
text: choice.text || (props.format ? formatTitle(item) : item),
text: choice.text || itemStringValue,
foreground: choice.foreground || props.defaultForeground,
background: choice.background || props.defaultBackground,
};