-
Notifications
You must be signed in to change notification settings - Fork 12
/
ConceptHierarchyRow.jsx
73 lines (68 loc) · 2.47 KB
/
ConceptHierarchyRow.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react';
import {
TableRow, TableCell, Chip, Tooltip
} from '@mui/material';
import {LocalOffer as LocalOfferIcon} from '@mui/icons-material'
import { map, get, orderBy } from 'lodash';
import { getSiteTitle } from '../../common/utils';
const SITE_TITLE = getSiteTitle()
const ConceptHierarchyRow = ({ mapType, concepts, source }) => {
const onDefaultClick = (event, concept) => {
event.stopPropagation()
event.preventDefault()
window.location.hash = concept.url
}
const count = get(concepts, 'length') || 0
const getOrderedConcepts = () => orderBy(concepts, 'display_name')
return (
<React.Fragment>
{
mapType &&
<TableRow>
<TableCell align='left' rowSpan={count + 1} style={{paddingRight: '5px', verticalAlign: 'top', paddingTop: '7px', width: '10%'}}>
<Chip
size='small'
variant='outlined'
color='default'
label={mapType}
style={{border: 'none'}}
/>
</TableCell>
</TableRow>
}
{
map(getOrderedConcepts(), (concept, index) => {
return (
<TableRow
hover key={get(concept, 'uuid') || index} onClick={event => onDefaultClick(event, concept)} style={{cursor: 'pointer'}} className='underline-text'>
<TableCell align='left' className='ellipsis-text' style={{width: '30%', paddingLeft: '5px'}}>
<span className='flex-vertical-center'>
<span className='flex-vertical-center' style={{marginRight: '4px'}}>
<Tooltip title={`Defined in ${SITE_TITLE}`}>
<LocalOfferIcon
color='primary'
fontSize='small'
style={{width: '12pt'}}
/>
</Tooltip>
</span>
<span className={concept.retired ? 'retired' : ''}>
{get(concept, 'id')}
</span>
</span>
</TableCell>
<TableCell align='left' style={{width: '35%'}}>
{ get(concept, 'display_name') }
</TableCell>
<TableCell align='left' style={{width: '20%'}}>
{get(source, 'id')}
</TableCell>
<TableCell />
</TableRow>
)
})
}
</React.Fragment>
)
}
export default ConceptHierarchyRow;