From 8558beb07c2fde2f587fa67bf312e0a7f9d792ff Mon Sep 17 00:00:00 2001 From: Rijk van Zanten Date: Mon, 9 Aug 2021 22:57:50 +0200 Subject: [PATCH] Handle JSON in labels display (#7292) Fixes #7278 --- app/src/displays/labels/labels.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/displays/labels/labels.vue b/app/src/displays/labels/labels.vue index 37a4f3a6ec..60a0560565 100644 --- a/app/src/displays/labels/labels.vue +++ b/app/src/displays/labels/labels.vue @@ -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, };