From d05fa0cb2cbb0defc9fd05adaa96df71d7899139 Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Sai Potteri Date: Fri, 22 May 2026 23:13:22 +0530 Subject: [PATCH] Use rv-screen column.display for table header labels --- src/components/RecordViewTable.tsx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/RecordViewTable.tsx b/src/components/RecordViewTable.tsx index 70a8f1f..2ab92f2 100644 --- a/src/components/RecordViewTable.tsx +++ b/src/components/RecordViewTable.tsx @@ -85,9 +85,30 @@ interface Props { toolbarAction?: React.ReactNode; } +// Walks the rv-screen layout to find the rv_table element and returns a +// key_name → display map for column header labels (the recordview response's +// output_label is empty for v2 envelope screens). +function extractColumnLabels(layout: any): Record { + const out: Record = {}; + const walk = (nodes: any[]): void => { + for (const n of nodes ?? []) { + const cfg = n?.config; + if (cfg?.type === "rv_table" && Array.isArray(cfg.columns)) { + for (const c of cfg.columns) { + if (c?.key_name && c?.display) out[c.key_name] = c.display; + } + } + if (Array.isArray(n?.children)) walk(n.children); + } + }; + walk(Array.isArray(layout) ? layout : []); + return out; +} + export default function RecordViewTable({ viewId, onRowClick, toolbarAction }: Props) { const navigate = useNavigate(); const [rvTemplateUid, setRvTemplateUid] = useState(null); + const [columnLabels, setColumnLabels] = useState>({}); const [fields, setFields] = useState([]); const [rows, setRows] = useState[]>([]); const [pagination, setPagination] = useState({ page: 1, limit: 10, total_count: 0, total_pages: 0 }); @@ -102,8 +123,12 @@ export default function RecordViewTable({ viewId, onRowClick, toolbarAction }: P useEffect(() => { setLoading(true); setRvTemplateUid(null); + setColumnLabels({}); getRVScreen(viewId) - .then((rv) => setRvTemplateUid(rv.rv_template_uid)) + .then((rv) => { + setColumnLabels(extractColumnLabels(rv.layout)); + setRvTemplateUid(rv.rv_template_uid); + }) .catch((err) => { setError(err.message); setLoading(false); }); }, [viewId]); @@ -262,7 +287,7 @@ export default function RecordViewTable({ viewId, onRowClick, toolbarAction }: P `} > - {f.output_label} + {columnLabels[f.field_key] || f.output_label || f.field_key} {isSorted ? (query.sort_dir === "asc" ?