From b4512a1948ebbc29832718ac211bc5d2f6ea3895 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 22 Mar 2026 00:02:17 +0000 Subject: [PATCH] Improved card design for object table. --- .../Dashboard/common/EmailDisplay.jsx | 2 +- .../Dashboard/common/ObjectCard.jsx | 111 +++++++++++++++++ .../Dashboard/common/ObjectProperty.jsx | 6 +- .../Dashboard/common/ObjectTable.jsx | 117 +++++------------- 4 files changed, 148 insertions(+), 88 deletions(-) create mode 100644 src/components/Dashboard/common/ObjectCard.jsx diff --git a/src/components/Dashboard/common/EmailDisplay.jsx b/src/components/Dashboard/common/EmailDisplay.jsx index 5eb3e39..58b22bc 100644 --- a/src/components/Dashboard/common/EmailDisplay.jsx +++ b/src/components/Dashboard/common/EmailDisplay.jsx @@ -11,7 +11,7 @@ const EmailDisplay = ({ email, showCopy = true, showLink = false }) => { return ( <> - + {showLink ? ( {email} diff --git a/src/components/Dashboard/common/ObjectCard.jsx b/src/components/Dashboard/common/ObjectCard.jsx new file mode 100644 index 0000000..0682025 --- /dev/null +++ b/src/components/Dashboard/common/ObjectCard.jsx @@ -0,0 +1,111 @@ +import { Descriptions, Card, Flex, Divider } from 'antd' +import PropTypes from 'prop-types' +import ObjectProperty from './ObjectProperty' +import { createElement } from 'react' + +const ObjectCard = ({ + model, + modelProperties, + visibleColumns = {}, + record, + isEditing = false, + rowActions = [], + renderActions, + cardStyle = 'borderless' +}) => { + const descriptionItems = [] + const modelIcon = createElement(model.icon, { style: { fontSize: 24 } }) + + model.columns.forEach((colName) => { + const prop = modelProperties.find((p) => p.name === colName) + if (prop) { + if ( + (Object.keys(visibleColumns).length > 0 && + visibleColumns[prop.name] === false) || + prop.name == 'name' + ) { + return + } + + descriptionItems.push( + + + + ) + } + }) + + var actions = undefined + + if (rowActions.length > 0) { + actions = renderActions(record) + } + + return ( + + + {visibleColumns?.name == true && ( + + {modelIcon} + p.name === 'name')} + objectData={record} + isEditing={isEditing} + style={{ + fontSize: 20, + fontWeight: '600', + lineHeight: 1, + overflow: 'visible' + }} + /> + {visibleColumns?.state == true && ( + p.name === 'state')} + objectData={record} + /> + )} + + )} + + {descriptionItems} + + {actions && ( + <> + + + {actions} + + + )} + + + ) +} + +ObjectCard.propTypes = { + model: PropTypes.object.isRequired, + modelProperties: PropTypes.array.isRequired, + visibleColumns: PropTypes.object, + record: PropTypes.object.isRequired, + isEditing: PropTypes.bool, + rowActions: PropTypes.array, + renderActions: PropTypes.func.isRequired, + cardStyle: PropTypes.string +} + +export default ObjectCard diff --git a/src/components/Dashboard/common/ObjectProperty.jsx b/src/components/Dashboard/common/ObjectProperty.jsx index 89a2951..72635ce 100644 --- a/src/components/Dashboard/common/ObjectProperty.jsx +++ b/src/components/Dashboard/common/ObjectProperty.jsx @@ -92,6 +92,7 @@ const ObjectProperty = ({ loading = false, rollups = [], showCard = true, + style = {}, ...rest }) => { if (value && typeof value == 'function' && objectData) { @@ -310,7 +311,7 @@ const ObjectProperty = ({ case 'text': if (value != null && value != '') { return ( - + {prefix} {value} {suffix} @@ -888,7 +889,8 @@ ObjectProperty.propTypes = { loading: PropTypes.bool, rollups: PropTypes.arrayOf(PropTypes.object), canAddRemove: PropTypes.bool, - showCard: PropTypes.bool + showCard: PropTypes.bool, + style: PropTypes.object } export default ObjectProperty diff --git a/src/components/Dashboard/common/ObjectTable.jsx b/src/components/Dashboard/common/ObjectTable.jsx index 5733360..f017a68 100644 --- a/src/components/Dashboard/common/ObjectTable.jsx +++ b/src/components/Dashboard/common/ObjectTable.jsx @@ -11,10 +11,8 @@ import { import { Table, Skeleton, - Card, Row, Col, - Descriptions, Flex, Spin, Button, @@ -35,6 +33,7 @@ import { getModelByName } from '../../../database/ObjectModels' import ObjectProperty from './ObjectProperty' +import ObjectCard from './ObjectCard' import FilterSidebar from './FilterSidebar' import XMarkIcon from '../../Icons/XMarkIcon' import CheckIcon from '../../Icons/CheckIcon' @@ -128,7 +127,7 @@ const ObjectTable = forwardRef( adjustedScrollHeight = 'calc(var(--unit-100vh) - 316px)' } if (cards) { - adjustedScrollHeight = 'calc(var(--unit-100vh) - 280px)' + adjustedScrollHeight = 'calc(var(--unit-100vh) - 210px)' } if (isElectron) { adjustedScrollHeight = 'calc(var(--unit-100vh) - 244px)' @@ -857,78 +856,25 @@ const ObjectTable = forwardRef( > {tableData.map((record) => ( - +
- - {(() => { - const descriptionItems = [] - - // Add columns in the order specified by model.columns (same logic as table) - model.columns.forEach((colName) => { - const prop = modelProperties.find( - (p) => p.name === colName - ) - if (prop) { - // Check if column should be visible based on visibleColumns prop - if ( - Object.keys(visibleColumns).length > 0 && - visibleColumns[prop.name] === false - ) { - return // Skip this column if it's not visible - } - - descriptionItems.push( - - - - ) - } - }) - - // Add actions if they exist (same as table) - if (rowActions.length > 0) { - descriptionItems.push( - - {renderActions(record)} - - ) - } - - return descriptionItems - })()} - + - +
))} @@ -955,28 +901,29 @@ const ObjectTable = forwardRef( const tableContent = ( - }} - onScroll={handleScroll} - onChange={handleTableChange} - showSorterTooltip={false} - style={{ height: '100%' }} - size={size} - components={components} - onRow={onRow} - /> {cards ? ( } spinning={loading}> {renderCards()} - ) : null} + ) : ( +
}} + onScroll={handleScroll} + onChange={handleTableChange} + showSorterTooltip={false} + style={{ height: '100%' }} + size={size} + components={components} + onRow={onRow} + /> + )} )