From 8d68374bbd136ed4098460ebdb3222d86c12d5e1 Mon Sep 17 00:00:00 2001 From: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Date: Thu, 2 Dec 2021 03:05:48 +0800 Subject: [PATCH] add default render tmpl & scope to json display (#10124) --- .../formatted-json-value/formatted-json-value.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/displays/formatted-json-value/formatted-json-value.vue b/app/src/displays/formatted-json-value/formatted-json-value.vue index 63e557468d..4d44045331 100644 --- a/app/src/displays/formatted-json-value/formatted-json-value.vue +++ b/app/src/displays/formatted-json-value/formatted-json-value.vue @@ -46,15 +46,23 @@ export default defineComponent({ try { if (Array.isArray(props.value)) { - return props.value.map((item: any) => render(props.format || '', item)); + return props.value.map((item: any) => renderValue(item)); } else { - return [render(props.format || '', props.value)]; + return [renderValue(props.value)]; } } catch { return null; } }); + function renderValue(input: Record | Record[]) { + if (props.format) { + return render(props.format, input); + } else { + return render('{{ value }}', { value: input }); + } + } + return { displayValue, t }; }, });