-
Notifications
You must be signed in to change notification settings - Fork 12
/
HierarchyTreeFilters.jsx
254 lines (250 loc) · 10 KB
/
HierarchyTreeFilters.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import React from 'react';
import {
Tooltip, Chip, Menu, MenuItem, TextField,
Button, Dialog, DialogActions, DialogContent, DialogTitle,
} from '@mui/material'
import {
FilterAlt as FilterIcon,
Cancel as CancelIcon,
Link as MappingIcon,
ArrowDropDown as DownIcon
} from '@mui/icons-material'
import { map } from 'lodash';
const LEVEL_OPTIONS = [
{id: '1', name: '1'},
{id: '2', name: '2'},
{id: '3', name: '3'},
{id: '4', name: '4'},
{id: '5', name: '5'},
{id: '*', name: 'All'},
]
const HierarchyTreeFilters = ({filters, onChange, onMapTypesFilterChange, size}) => {
const [mapTypes, setMapTypes] = React.useState(filters.mapTypes || '')
const [excludeMapTypes, setExcludeMapTypes] = React.useState(filters.excludeMapTypes || '')
const [returnMapTypes, setReturnMapTypes] = React.useState(filters.returnMapTypes || '')
const [omitIfExistsIn, setOmitIfExistsIn] = React.useState(filters.omitIfExistsIn || '')
const [equivalencyMapType, setEquivalencyMapType] = React.useState(filters.equivalencyMapType || '')
const [levelAnchorEl, setLevelAnchorEl] = React.useState(null);
const [mapTypeAnchorEl, setMapTypeAnchorEl] = React.useState(null);
const [omitIfExistsInAnchorEl, setOmitIfExistsInAnchorEl] = React.useState(null);
const cascadeLevelText = filters.cascadeLevels === '*' ? 'Levels: All' : `Levels: ${filters.cascadeLevels}`
const toggleLevelAnchor = event => setLevelAnchorEl(levelAnchorEl ? null : event.currentTarget)
const toggleMapTypeAnchor = event => setMapTypeAnchorEl(mapTypeAnchorEl ? null : event.currentTarget)
const toggleOmitIfExistsInAnchor = event => setOmitIfExistsInAnchorEl(omitIfExistsInAnchorEl ? null : event.currentTarget)
const onLevelChange = newLevel => {
toggleLevelAnchor()
onChange('cascadeLevels', newLevel)
}
const onMapTypesChange = () => {
toggleMapTypeAnchor()
onMapTypesFilterChange({...filters, mapTypes: mapTypes, excludeMapTypes: excludeMapTypes, returnMapTypes: returnMapTypes})
}
const onOmitIfExistsInChange = () => {
toggleOmitIfExistsInAnchor()
onMapTypesFilterChange({...filters, omitIfExistsIn: omitIfExistsIn, equivalencyMapType: equivalencyMapType})
}
const _size = size || 'small'
return (
<span className="flex-vertical-center" style={{flexWrap: 'wrap'}}>
<Tooltip title={cascadeLevelText} arrow placement='top'>
<Chip
color="primary"
variant="outlined"
label={cascadeLevelText}
size={_size}
clickable
onClick={toggleLevelAnchor}
onDelete={toggleLevelAnchor}
deleteIcon={<DownIcon />}
/>
</Tooltip>
<Tooltip title={filters.cascadeHierarchy ? 'Remove Hierarchy' : 'Cascade Hierarchy'} arrow placement='top'>
<Chip
color={filters.cascadeHierarchy ? "primary" : "secondary"}
variant="outlined"
label="Hierarchy"
size={_size}
style={filters.cascadeHierarchy ? {marginLeft: '2px'} : { marginLeft: '2px', color: 'rgba(0, 0, 0, 0.5)' }}
icon={filters.cascadeHierarchy ? <CancelIcon /> : null}
clickable
onClick={() => onChange('cascadeHierarchy', !filters.cascadeHierarchy) }
/>
</Tooltip>
<Tooltip title={filters.cascadeMappings ? 'Remove Mappings' : 'Cascade Mappings'} arrow placement='top'>
<Chip
color={filters.cascadeMappings ? "primary" : "secondary"}
variant="outlined"
label="Mappings"
size={_size}
style={filters.cascadeMappings ? {marginLeft: '2px'} : { color: 'rgba(0, 0, 0, 0.5)', marginLeft: '2px' }}
icon={filters.cascadeMappings ? <CancelIcon /> : null}
clickable
onClick={() => onChange('cascadeMappings', !filters.cascadeMappings) }
/>
</Tooltip>
{
filters.cascadeMappings &&
<Tooltip title="Include/Exclude MapTypes" arrow placement='top'>
<Chip
color={(filters.mapTypes || filters.excludeMapTypes) ? "primary" : "secondary"}
variant="outlined"
label="MapTypes"
size={_size}
clickable
deleteIcon={<FilterIcon />}
icon={<MappingIcon />}
onDelete={toggleMapTypeAnchor}
onClick={toggleMapTypeAnchor}
style={{marginLeft: '2px'}}
/>
</Tooltip>
}
<Tooltip title="Omit If Exists In Repo Version" arrow placement='top'>
<Chip
color={filters.omitIfExistsIn ? "primary" : "secondary"}
variant="outlined"
label="OmitIfExistsIn"
size={_size}
clickable
deleteIcon={<FilterIcon />}
onDelete={toggleOmitIfExistsInAnchor}
onClick={toggleOmitIfExistsInAnchor}
style={{marginLeft: '2px'}}
/>
</Tooltip>
<Tooltip title={filters.includeRetired ? 'Exclude Retired' : 'Include Retired'} arrow placement='top'>
<Chip
color="primary"
variant="outlined"
label={filters.includeRetired ? 'Exclude Retired' : 'Include Retired'}
size={_size}
style={{marginLeft: '2px'}}
clickable
onClick={() => onChange('includeRetired', !filters.includeRetired) }
/>
</Tooltip>
<Tooltip title={filters.reverse ? 'Cascade Forward/Down' : 'Cascade Backward/Up'} arrow placement='top'>
<Chip
color="primary"
variant="outlined"
label={filters.reverse ? 'Forward' : 'Backward'}
size={_size}
style={{marginLeft: '2px'}}
clickable
onClick={() => onChange('reverse', !filters.reverse) }
/>
</Tooltip>
<Menu
id="hierarchy-tree-filter-level-menu"
anchorEl={levelAnchorEl}
keepMounted
open={Boolean(levelAnchorEl)}
onClose={toggleLevelAnchor}
>
{
map(LEVEL_OPTIONS, ({id, name}) => (
<MenuItem key={id} value={id} onClick={() => onLevelChange(id)} selected={filters.cascadeLevels === id}>
{name}
</MenuItem>
))
}
</Menu>
<Dialog open={Boolean(mapTypeAnchorEl)} onClose={toggleMapTypeAnchor}>
<DialogTitle>
Include/Exclude Map Types from Results
</DialogTitle>
<DialogContent style={{minWidth: '400px'}}>
<div className='col-xs-12 no-side-padding'>
<div className='col-xs-12 no-side-padding' style={{fontWeight: 'bold', marginBottom: '5px'}}>
Include MapTypes
</div>
<div className='col-xs-12 no-side-padding'>
<TextField
fullWidth
value={mapTypes}
onChange={event => setMapTypes(event.target.value)}
placeholder='e.g. SAME-AS,NARROWER-THAN,CONCEPT-SET'
/>
</div>
</div>
<div className='col-xs-12 no-side-padding' style={{marginTop: '15px'}}>
<div className='col-xs-12 no-side-padding' style={{fontWeight: 'bold', marginBottom: '5px'}}>
Exclude MapTypes
</div>
<div className='col-xs-12 no-side-padding'>
<TextField
fullWidth
value={excludeMapTypes}
onChange={event => setExcludeMapTypes(event.target.value)}
placeholder='e.g. SAME-AS,NARROWER-THAN,CONCEPT-SET'
/>
</div>
</div>
<div className='col-xs-12 no-side-padding' style={{marginTop: '15px'}}>
<div className='col-xs-12 no-side-padding' style={{fontWeight: 'bold', marginBottom: '5px'}}>
Return MapTypes
</div>
<div className='col-xs-12 no-side-padding'>
<TextField
fullWidth
value={returnMapTypes}
onChange={event => setReturnMapTypes(event.target.value)}
placeholder='e.g. SAME-AS,NARROWER-THAN,CONCEPT-SET'
/>
</div>
</div>
</DialogContent>
<DialogActions>
<Button onClick={toggleMapTypeAnchor} variant='outlined' color='secondary'>
Close
</Button>
<Button onClick={onMapTypesChange} color="primary" variant='outlined'>
Apply
</Button>
</DialogActions>
</Dialog>
<Dialog open={Boolean(omitIfExistsInAnchorEl)} onClose={toggleOmitIfExistsInAnchor}>
<DialogTitle>
Omit If Exists In Repo Version
</DialogTitle>
<DialogContent style={{minWidth: '400px'}}>
<div className='col-xs-12 no-side-padding'>
<div className='col-xs-12 no-side-padding' style={{fontWeight: 'bold', marginBottom: '5px'}}>
OmitIfExistsIn
</div>
<div className='col-xs-12 no-side-padding'>
<TextField
fullWidth
value={omitIfExistsIn}
onChange={event => setOmitIfExistsIn(event.target.value)}
placeholder='e.g. /orgs/MyOrg/collections/MyCollection/'
/>
</div>
</div>
<div className='col-xs-12 no-side-padding' style={{marginTop: '15px'}}>
<div className='col-xs-12 no-side-padding' style={{fontWeight: 'bold', marginBottom: '5px'}}>
EquivalencyMapType
</div>
<div className='col-xs-12 no-side-padding'>
<TextField
fullWidth
value={equivalencyMapType}
onChange={event => setEquivalencyMapType(event.target.value)}
placeholder='e.g. SAME-AS,CONCEPT-SET'
/>
</div>
</div>
</DialogContent>
<DialogActions>
<Button onClick={toggleOmitIfExistsInAnchor} variant='outlined' color='secondary'>
Close
</Button>
<Button onClick={onOmitIfExistsInChange} color="primary" variant='outlined'>
Apply
</Button>
</DialogActions>
</Dialog>
</span>
);
}
export default HierarchyTreeFilters;