Skip to content

Commit 8d400c8

Browse files
committed
OpenConceptLab/ocl_issues#2244 | filters to indicate columns if mapped
1 parent 4787d15 commit 8d400c8

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

src/components/map-projects/Candidates.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const CandidateList = ({candidates, header, rowIndex, orderBy, order, onOrderCha
129129
): null
130130
}
131131

132-
const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, isLoading, candidatesScore, repoVersion, analysis, onFetchRecommendation, appliedFacets, setAppliedFacets, filters, facets}) => {
132+
const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOrderChange, setShowItem, showItem, setShowHighlights, isSelectedForMap, onMap, onFetchMore, isLoading, candidatesScore, repoVersion, analysis, onFetchRecommendation, appliedFacets, setAppliedFacets, filters, facets, columns}) => {
133133
const inAIAssistantGroup = hasAuthGroup(getCurrentUser(), 'mapper_ai_assistant')
134134
const [openFilters, setOpenFilters] = React.useState(false)
135135
const [display, setDisplay] = React.useState('card')
@@ -227,6 +227,7 @@ const Candidates = ({rowIndex, alert, setAlert, candidates, orderBy, order, onOr
227227
properties={repoVersion?.meta?.display?.concept_summary_properties}
228228
propertyFilters={repoVersion?.filters}
229229
heightToSubtract={523}
230+
columns={columns}
230231
/>
231232
</div>
232233
}

src/components/map-projects/MapProject.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ const MapProject = () => {
920920
return false
921921
}
922922

923+
const getValidColumns = () => filter(columns, column => isValidColumnValue(column.label))
923924

924925
const onGetCandidates = event => {
925926
event.stopPropagation()
@@ -2027,6 +2028,7 @@ const MapProject = () => {
20272028
repoVersion={repoVersion}
20282029
onFetchRecommendation={fetchRecommendation}
20292030
analysis={analysis[rowIndex]}
2031+
columns={getValidColumns()}
20302032
facets={facets[rowIndex]}
20312033
appliedFacets={appliedFacets[rowIndex]}
20322034
filters={getFilters(rowIndex)}
@@ -2052,6 +2054,7 @@ const MapProject = () => {
20522054
searchStr={searchStr}
20532055
setSearchStr={setSearchStr}
20542056
isLoading={isLoadingInDecisionView}
2057+
columns={getValidColumns()}
20552058
facets={facets[rowIndex]}
20562059
appliedFacets={appliedFacets[rowIndex]}
20572060
filters={getFilters()}

src/components/map-projects/Search.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Mappings from './Mappings'
2222
import Concept from './Concept'
2323
import MapButton from './MapButton'
2424

25-
const Search = ({searchStr, setSearchStr, onSearch, repo, repoVersion, concepts, setShowItem, showItem, isSelectedForMap, onMap, response, facets, appliedFacets, setAppliedFacets, isLoading, filters}) => {
25+
const Search = ({searchStr, setSearchStr, onSearch, repo, repoVersion, concepts, setShowItem, showItem, isSelectedForMap, onMap, response, facets, appliedFacets, setAppliedFacets, isLoading, filters, columns}) => {
2626
const [openFilters, setOpenFilters] = React.useState(false)
2727
const [display, setDisplay] = React.useState('card')
2828
let total = parseInt(response?.headers?.num_found) || concepts?.length || 0
@@ -124,6 +124,7 @@ const Search = ({searchStr, setSearchStr, onSearch, repo, repoVersion, concepts,
124124
properties={repoVersion?.meta?.display?.concept_summary_properties}
125125
propertyFilters={repoVersion?.filters}
126126
heightToSubtract={523}
127+
columns={columns}
127128
/>
128129
</div>
129130
}

src/components/search/SearchFilters.jsx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import { useTranslation } from 'react-i18next';
3-
import {omit, omitBy, isEmpty, isObject, has, map, startCase, includes, get, without, forEach, flatten, values, pickBy, isEqual, filter, reject, cloneDeep, keys} from 'lodash';
3+
import {omit, omitBy, isEmpty, isObject, has, map, startCase, includes, get, without, forEach, flatten, values, pickBy, isEqual, filter, reject, cloneDeep, keys, find} from 'lodash';
44
import InfoIcon from '@mui/icons-material/InfoOutlined';
5+
import MappedIcon from '@mui/icons-material/Link';
56
import Button from '@mui/material/Button';
67
import Badge from '@mui/material/Badge';
78
import Tooltip from '@mui/material/Tooltip';
@@ -18,7 +19,7 @@ import CircularProgress from '@mui/material/CircularProgress';
1819
import { URIToParentParams, currentUserHasAccess } from '../../common/utils'
1920
import { FACET_ORDER } from './ResultConstants';
2021

21-
const SearchFilters = ({filters, resource, onChange, kwargs, bgColor, appliedFilters, fieldOrder, noSubheader, disabledZero, filterDefinitions, nested, onSaveAsDefaultFilters, loading, repoDefaultFilters, propertyFilters, heightToSubtract, open}) => {
22+
const SearchFilters = ({filters, resource, onChange, kwargs, bgColor, appliedFilters, fieldOrder, noSubheader, disabledZero, filterDefinitions, nested, onSaveAsDefaultFilters, loading, repoDefaultFilters, propertyFilters, heightToSubtract, open, columns}) => {
2223
const { t } = useTranslation()
2324
const [applied, setApplied] = React.useState({});
2425
const [count, setCount] = React.useState(0);
@@ -96,14 +97,22 @@ const SearchFilters = ({filters, resource, onChange, kwargs, bgColor, appliedFil
9697
return label
9798
}
9899

99-
const formattedListSubheader = field => {
100-
if(field.startsWith('properties__')){
101-
const fields = field.split('__')
102-
return startCase(fields[1])
103-
} else if (isFixedConceptField(field)) {
104-
return startCase(field)
100+
const formattedListSubheader = field => field.startsWith('properties__') ? startCase(field.split('__')[1]) : startCase(field)
101+
102+
const getMappedToColumnName = field => {
103+
let mappedColumnName;
104+
if(columns?.length) {
105+
let isProperty = field.startsWith('properties__')
106+
if(isProperty) {
107+
let name = field.split('__')[1]
108+
mappedColumnName = find(columns, column => column.label.toLowerCase() === `Property: ${name}`.toLowerCase() || column.label.toLowerCase().includes(name.toLowerCase()))?.original
109+
if(!mappedColumnName && name === 'concept_class')
110+
mappedColumnName = find(columns, column => column.label.toLowerCase() === `Property: Class`.toLowerCase())?.original
111+
} else {
112+
mappedColumnName = find(columns, column => column.label.toLowerCase() === field.toLowerCase())?.original
113+
}
105114
}
106-
return startCase(field)
115+
return mappedColumnName
107116
}
108117

109118
const handleToggle = (field, value) => () => {
@@ -180,6 +189,7 @@ const SearchFilters = ({filters, resource, onChange, kwargs, bgColor, appliedFil
180189
const getFilterList = (fieldFilters, field) => {
181190
const shouldShowExpand = fieldFilters.length > 5
182191
const isExpanded = expanded.includes(field)
192+
const mappedColumnName = getMappedToColumnName(field)
183193
return (
184194
<ListItem key={field} sx={{padding: 0, flexDirection: 'column'}}>
185195
<List
@@ -193,8 +203,17 @@ const SearchFilters = ({filters, resource, onChange, kwargs, bgColor, appliedFil
193203
>
194204
{
195205
!noSubheader &&
196-
<ListSubheader sx={{padding: '0 8px 0 0px', fontWeight: 'bold', backgroundColor: bgColor, lineHeight: '30px'}}>
197-
{formattedListSubheader(field)}
206+
<ListSubheader sx={{padding: '0 8px 0 0px', fontWeight: 'bold', backgroundColor: bgColor, lineHeight: '30px', display: 'flex', alignItems: 'center', justifyContent: 'space-between'}}>
207+
<span>{formattedListSubheader(field)}</span>
208+
{
209+
mappedColumnName &&
210+
<Tooltip title={`Mapped to column ${mappedColumnName} from input sheet`}>
211+
<span style={{fontWeight: 'normal', fontSize: '12px', display: 'flex', alignItems: 'center'}}>
212+
<MappedIcon color='warning' sx={{marginRight: '4px', fontSize: '14px'}} />
213+
{mappedColumnName}
214+
</span>
215+
</Tooltip>
216+
}
198217
</ListSubheader>
199218
}
200219
{
@@ -249,7 +268,6 @@ const SearchFilters = ({filters, resource, onChange, kwargs, bgColor, appliedFil
249268
}
250269

251270

252-
const isFixedConceptField = field => isConcept && ['conceptClass', 'datatype'].includes(field)
253271
const canUpdateDefaultFilters = nested && onSaveAsDefaultFilters && currentUserHasAccess()
254272
const topBarHeight = canUpdateDefaultFilters ? 60 : 30
255273
let totalFilters = {...propertyFacets, ...uiFilters}

0 commit comments

Comments
 (0)