-
Notifications
You must be signed in to change notification settings - Fork 13
/
ConceptHomeDetails.jsx
112 lines (108 loc) · 4.03 KB
/
ConceptHomeDetails.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import React from 'react';
import {
Accordion, AccordionSummary, AccordionDetails, Typography
} from '@material-ui/core';
import { map, get, isEmpty } from 'lodash';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import ConceptDetailsLocale from './ConceptDetailsLocale';
import NestedMappingsTable from '../mappings/NestedMappingsTable';
import CustomAttributesAccordian from '../common/CustomAttributesAccordian';
import { getIndirectMappings, getDirectMappings } from '../../common/utils';
const ACCORDIAN_HEADING_STYLES = {
fontWeight: 'bold',
}
const ACCORDIAN_DETAILS_STYLES = {
maxHeight: '300px', overflow: 'scroll', display: 'inline-block', width: '100%',
}
const None = () => {
return <div style={{margin: '5px', fontWeight: '300'}}>None</div>
}
const ConceptHomeDetails = ({ concept, currentURL }) => {
const directMappings = getDirectMappings(concept.mappings, concept.id);
const indirectMappings = getIndirectMappings(concept.mappings, concept.id);
const names = get(concept, 'names', [])
const descriptions = get(concept, 'descriptions', [])
const extras = get(concept, 'extras', {});
return (
<div className='col-md-12'>
<div className='col-md-6 no-left-padding'>
<Accordion defaultExpanded>
<AccordionSummary
className='light-gray-bg'
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
>
<Typography style={ACCORDIAN_HEADING_STYLES}>Names & Synonyms</Typography>
</AccordionSummary>
<AccordionDetails style={ACCORDIAN_DETAILS_STYLES}>
{
isEmpty(names) ?
None() :
map(names, name => (
<ConceptDetailsLocale locale={name} key={name.uuid} url={`${currentURL}names/${name.uuid}/`} />
))
}
</AccordionDetails>
</Accordion>
<Accordion defaultExpanded>
<AccordionSummary
className='light-gray-bg'
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
>
<Typography style={ACCORDIAN_HEADING_STYLES}>Descriptions</Typography>
</AccordionSummary>
<AccordionDetails style={ACCORDIAN_DETAILS_STYLES}>
{
isEmpty(descriptions) ?
None() :
map(descriptions, description => (
<ConceptDetailsLocale locale={description} isDescription={true} key={description.uuid} url={`${currentURL}descriptions/${description.uuid}/`} />
))
}
</AccordionDetails>
</Accordion>
<CustomAttributesAccordian
attributes={extras}
headingStyles={ACCORDIAN_HEADING_STYLES}
detailStyles={ACCORDIAN_DETAILS_STYLES}
/>
</div>
<div className='col-md-6 no-right-padding'>
<Accordion defaultExpanded>
<AccordionSummary
className='light-gray-bg'
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
>
<Typography style={ACCORDIAN_HEADING_STYLES}>Mappings</Typography>
</AccordionSummary>
<AccordionDetails style={ACCORDIAN_DETAILS_STYLES}>
{
isEmpty(directMappings) ?
None() :
<NestedMappingsTable mappings={directMappings} />
}
</AccordionDetails>
</Accordion>
<Accordion defaultExpanded>
<AccordionSummary
className='light-gray-bg'
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
>
<Typography style={ACCORDIAN_HEADING_STYLES}>Inverse Mappings</Typography>
</AccordionSummary>
<AccordionDetails style={ACCORDIAN_DETAILS_STYLES}>
{
isEmpty(indirectMappings) ?
None() :
<NestedMappingsTable mappings={indirectMappings} />
}
</AccordionDetails>
</Accordion>
</div>
</div>
);
}
export default ConceptHomeDetails;