Skip to content

Commit

Permalink
Merge pull request #125 from mercedes-benz/VULCAN-650/ExpandedCellRen…
Browse files Browse the repository at this point in the history
…derer

Vulcan 650/expanded cell renderer
  • Loading branch information
brahmprakashMishra committed Jun 17, 2024
2 parents ecc74f5 + 9b0ca9d commit ebbe6ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/component/misc/DataGridExpandRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Box from '@mui/material/Box';
import { Paper, Popper, Typography } from '@mui/material';
import { GridRenderCellParams } from '@mui/x-data-grid';
import { useEffect } from 'react';
import {RenderString } from '../../report/ReportRecordProcessing';


interface GridCellExpandProps {
value: string;
Expand Down Expand Up @@ -105,15 +107,15 @@ const GridCellExpand = React.memo((props: GridCellExpandProps) => {
});

export function renderCellExpand(params: GridRenderCellParams<any, string>, lineBreakAfterListEntry: boolean) {

let value = params.value?.low ? params.value.low : params.value;

return (typeof value==="string" || value instanceof String)
? <GridCellExpand value={RenderString(value)} width={params.colDef.computedWidth} />
: <GridCellExpand value={JSON.stringify(value)
.replaceAll(',', lineBreakAfterListEntry ? ',\r\n' : ', ')
.replaceAll(']', '')
.replaceAll('[', '')
.replaceAll('"', '')} width={params.colDef.computedWidth} />;

const stringifiedObj = value
? JSON.stringify(value)
.replaceAll(',', lineBreakAfterListEntry ? ',\r\n' : ', ') // TODO: Consolidate to a regex
.replaceAll(']', '')
.replaceAll('[', '')
.replaceAll('"', '')
: '';

return <GridCellExpand value={stringifiedObj || ''} width={params.colDef.computedWidth} />;
}
2 changes: 1 addition & 1 deletion src/report/ReportRecordProcessing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function RenderArray(value) {
return mapped;
}

function RenderString(value) {
export function RenderString(value) {
const str = value?.toString() || '';
if (str.startsWith('http') || str.startsWith('https')) {
return (
Expand Down

0 comments on commit ebbe6ba

Please sign in to comment.