From 6cc3fdb0ce8491782b7e686eb3ca3e73243b1bc8 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sat, 20 Jun 2026 23:10:10 +0100 Subject: [PATCH] Added minimal object child table with modal popup. --- .../Dashboard/common/ObjectChildTable.jsx | 51 +++++++++++++++---- .../Dashboard/common/ObjectProperty.jsx | 2 + 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/components/Dashboard/common/ObjectChildTable.jsx b/src/components/Dashboard/common/ObjectChildTable.jsx index ab519a6..50de38f 100644 --- a/src/components/Dashboard/common/ObjectChildTable.jsx +++ b/src/components/Dashboard/common/ObjectChildTable.jsx @@ -1,11 +1,11 @@ -import { useMemo, useEffect, useRef } from 'react' +import { useMemo, useEffect, useRef, useState } from 'react' import PropTypes from 'prop-types' -import { Table, Skeleton, Card, Button, Flex, Typography } from 'antd' +import { Table, Skeleton, Card, Button, Flex, Typography, Modal } from 'antd' import PlusIcon from '../../Icons/PlusIcon' import ObjectProperty from './ObjectProperty' import { LoadingOutlined } from '@ant-design/icons' import BinIcon from '../../Icons/BinIcon' -const { Text } = Typography +const { Text, Link, Title } = Typography const DEFAULT_COLUMN_WIDTHS = { text: 200, @@ -64,13 +64,15 @@ const ObjectChildTable = ({ value = [], rollups = [], onChange, + minimal = false, + label = '', ...tableProps }) => { const mainTableWrapperRef = useRef(null) const rollupTableWrapperRef = useRef(null) const generatedRowKeysRef = useRef(new WeakMap()) const generatedRowKeyCountRef = useRef(0) - + const [minimalModelOpen, setMinimalModelOpen] = useState(false) const getFallbackRowKey = (record) => { if (!record || typeof record !== 'object') { return `object-child-table-row-${String(record)}` @@ -274,8 +276,7 @@ const ObjectChildTable = ({ return itemsSource }, [itemsSource, loading, skeletonData]) - const resolvedRowKey = - (record) => getResolvedRecordKey(record) + const resolvedRowKey = (record) => getResolvedRecordKey(record) const scrollConfig = scrollHeight != null @@ -460,7 +461,8 @@ const ObjectChildTable = ({ rowKey={resolvedRowKey} scroll={scrollConfig} locale={{ emptyText }} - style={{ maxWidth, minWidth: 0 }} + bordered={true} + style={{ maxWidth: minimal ? '100%' : maxWidth, minWidth: 0 }} className='rollup-table' /> @@ -470,13 +472,14 @@ const ObjectChildTable = ({
}} size={size} rowKey={resolvedRowKey} scroll={scrollConfig} + bordered={true} locale={{ emptyText }} pagination={false} className={hasRollups ? 'child-table-rollups' : 'child-table'} @@ -509,6 +512,34 @@ const ObjectChildTable = ({ ) } + if (minimal == true) { + return ( + <> + { + setMinimalModelOpen(true) + }} + > + {value?.length || 0} {value?.length == 1 ? 'item' : 'items'} + + setMinimalModelOpen(false)} + footer={null} + width='860px' + > + + {label} + + {tableComponent} + + + ) + } + return tableComponent } @@ -530,13 +561,15 @@ ObjectChildTable.propTypes = { skeletonRows: PropTypes.number, additionalColumns: PropTypes.arrayOf(PropTypes.object), emptyText: PropTypes.node, + label: PropTypes.string, isEditing: PropTypes.bool, value: PropTypes.arrayOf(PropTypes.object), onChange: PropTypes.func, maxWidth: PropTypes.string, rollups: PropTypes.arrayOf(PropTypes.object), objectData: PropTypes.object, - canAddRemove: PropTypes.bool + canAddRemove: PropTypes.bool, + minimal: PropTypes.bool } export default ObjectChildTable diff --git a/src/components/Dashboard/common/ObjectProperty.jsx b/src/components/Dashboard/common/ObjectProperty.jsx index 1984602..7c4186f 100644 --- a/src/components/Dashboard/common/ObjectProperty.jsx +++ b/src/components/Dashboard/common/ObjectProperty.jsx @@ -422,6 +422,8 @@ const ObjectProperty = ({ loading={loading} rollups={rollups} size={size} + minimal={minimal} + label={label} canAddRemove={canAddRemove} /> )