Skip to content

Commit 66c1034

Browse files
committed
OpenConceptLab/ocl_issues#2173 | Source | properties/filters table view
1 parent 883cbe3 commit 66c1034

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

src/components/common/EntityAttributesDialog.jsx

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import TableHead from '@mui/material/TableHead';
1010
import TableBody from '@mui/material/TableBody';
1111
import TableRow from '@mui/material/TableRow';
1212
import TableCell from '@mui/material/TableCell';
13-
import { map, get } from 'lodash'
13+
import { map, get, keys, flatten, uniq } from 'lodash'
1414
import Link from '../common/Link'
1515
import { formatWebsiteLink, formatDate, formatDateTime } from '../../common/utils'
1616

@@ -31,6 +31,41 @@ const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
3131
return <Link sx={{fontSize: '14px'}} label={value} href={`#/users/${value}/`} />
3232
if(info.type === 'json')
3333
return <pre>{JSON.stringify(value, undefined, 2)}</pre>
34+
if(info.type === 'table') {
35+
if(value?.length > 0) {
36+
let columns = uniq(flatten(value.map(val => keys(val))))
37+
return <Table size='small' sx={{'.MuiTableCell-root': {padding: '6px', border: '1px solid rgba(0, 0, 0, 0.1)'}}}>
38+
<TableHead>
39+
<TableRow>
40+
{
41+
columns.map(
42+
col => <TableCell key={col} sx={{fontSize: '12px'}}><b>{col}</b></TableCell>
43+
)
44+
}
45+
</TableRow>
46+
</TableHead>
47+
<TableBody>
48+
{
49+
map(value, (val, index) => (
50+
<TableRow key={index}>
51+
{
52+
columns.map(col => (
53+
<TableCell key={col}>
54+
<span style={{display: 'inline-block', maxWidth: '200px', wordBreak: 'break-all'}}>
55+
{val[col] || null}
56+
</span>
57+
</TableCell>
58+
))
59+
}
60+
</TableRow>
61+
))
62+
}
63+
</TableBody>
64+
</Table>
65+
} else {
66+
return value
67+
}
68+
}
3469
}
3570
return value
3671
}
@@ -39,12 +74,12 @@ const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
3974
open={open}
4075
onClose={onClose}
4176
scroll='paper'
42-
maxWidth="sm"
77+
maxWidth="lg"
4378
sx={{
4479
'& .MuiDialog-paper': {
4580
backgroundColor: 'surface.n92',
4681
borderRadius: '28px',
47-
minWidth: '312px',
82+
minWidth: entity?.properties?.length > 0 ? '812px' : '312px',
4883
minHeight: '262px',
4984
padding: 0
5085
}
@@ -54,11 +89,11 @@ const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
5489
{entity.type} {t('common.attributes')}
5590
</DialogTitle>
5691
<DialogContent style={{padding: '0 8px'}}>
57-
<Table size="small">
92+
<Table size="small" sx={{'.MuiTableCell-root': {padding: '6px'}}}>
5893
<TableHead>
5994
<TableRow>
60-
<TableCell><b>{t('common.attribute')}</b></TableCell>
61-
<TableCell><b>{t('common.value')}</b></TableCell>
95+
<TableCell sx={{fontSize: '12px'}}><b>{t('common.attribute')}</b></TableCell>
96+
<TableCell sx={{fontSize: '12px'}}><b>{t('common.value')}</b></TableCell>
6297
</TableRow>
6398
</TableHead>
6499
<TableBody>
@@ -69,8 +104,8 @@ const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
69104
key={field}
70105
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
71106
>
72-
<TableCell component="th" scope="row">
73-
{info?.label}
107+
<TableCell component="th" scope="row" sx={{fontSize: '12px', color: 'rgba(0, 0, 0, 0.7)'}}>
108+
<span style={{maxWidth: '125px', display: 'inline-block'}}>{info?.label}</span>
74109
</TableCell>
75110
<TableCell>{getValue(field, info)}</TableCell>
76111
</TableRow>

src/components/repos/RepoHeader.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClic
109109
locales: {label: t('repo.locales')},
110110
custom_validation_schema: {label: t('repo.custom_validation_schema')},
111111
public_access: {label: t('common.access_level')},
112-
properties: {label: t('repo.properties'), type: 'json'},
113-
filters: {label: t('repo.filters'), type: 'json'},
112+
properties: {label: t('repo.properties'), type: 'table'},
113+
filters: {label: t('repo.filters'), type: 'table'},
114114
identifier: {label: t('repo.identifier'), type: 'json'},
115115
contact: {label: t('repo.contact'), type: 'json'},
116116
jurisdiction: {label: t('repo.jurisdiction'), type: 'json'},

0 commit comments

Comments
 (0)