Skip to content

Commit

Permalink
Handle JSON in labels display (directus#7292)
Browse files Browse the repository at this point in the history
  • Loading branch information
rijkvanzanten authored Aug 9, 2021
1 parent 5ad5544 commit 8558beb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/src/displays/labels/labels.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down

0 comments on commit 8558beb

Please sign in to comment.