Skip to content

Commit

Permalink
[UIPQB-145] Display raw booleans in nested table
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Oct 25, 2024
1 parent 84bbe2a commit 69ccec7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/QueryBuilder/ResultViewer/DynamicTable/DynamicTable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import React, { useMemo } from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import css from './DynamicTable.css';

const columnStyle = { width: '180px', minWidth: '180px' };

function getCellValue(row, property) {
// typeof check to ensure we don't consider null/undefined as a boolean
if (property.dataType.dataType === 'booleanType' && typeof row[property.property] === 'boolean') {
return row[property.property]
? <FormattedMessage id="ui-plugin-query-builder.options.true" />
: <FormattedMessage id="ui-plugin-query-builder.options.false" />;
}

return row[property.property];
}

export const DynamicTable = ({ properties, values }) => {
const tableBodyRows = useMemo(() => JSON.parse(values ?? '[]'), [values]);

Expand All @@ -27,7 +39,7 @@ export const DynamicTable = ({ properties, values }) => {
<tr key={index}>
{properties?.map((cell) => (
<td key={cell.property} style={columnStyle}>
{row[cell.property]}
{getCellValue(row, cell)}
</td>
))}
</tr>
Expand Down

0 comments on commit 69ccec7

Please sign in to comment.