Skip to content

Commit 3c4fbcd

Browse files
committed
OpenConceptLab/ocl_issues#2183 | Added option to include/exclude retired in configuration
1 parent bbd641c commit 3c4fbcd

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/components/map-projects/ConfigurationForm.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import RepoSearchAutocomplete from '../repos/RepoSearchAutocomplete'
2222
import RepoVersionSearchAutocomplete from '../repos/RepoVersionSearchAutocomplete'
2323
import CloseIconButton from '../common/CloseIconButton';
2424
import ColumnMapTable from './ColumnMapTable'
25+
import IncludeRetired from './IncludeRetired'
2526

2627
const VisuallyHiddenInput = styled('input')({
2728
clip: 'rect(0 0 0 0)',
@@ -36,7 +37,7 @@ const VisuallyHiddenInput = styled('input')({
3637
});
3738

3839

39-
const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, name, setName, description, setDescription, repo, onRepoChange, repoVersion, setRepoVersion, versions, mappedSources, targetSourcesFromRows, algo, onAlgoSelect, sx, algos, validColumns, columns, isValidColumnValue, updateColumn, configure, setConfigure, columnVisibilityModel, setColumnVisibilityModel, onSave }) => {
40+
const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, name, setName, description, setDescription, repo, onRepoChange, repoVersion, setRepoVersion, versions, mappedSources, targetSourcesFromRows, algo, onAlgoSelect, sx, algos, validColumns, columns, isValidColumnValue, updateColumn, configure, setConfigure, columnVisibilityModel, setColumnVisibilityModel, onSave, retired, setRetired }) => {
4041
const [algoMenuAnchorEl, setAlgoMenuAnchorEl] = React.useState(null)
4142

4243
const onAlgoButtonClick = event => setAlgoMenuAnchorEl(algoMenuAnchorEl ? null : event.currentTarget)
@@ -125,6 +126,7 @@ const ConfigurationForm = ({ project, handleFileUpload, file, owner, setOwner, n
125126

126127
<RepoSearchAutocomplete label='Repository' size='small' onChange={(id, item) => onRepoChange(item)} value={repo} sx={{marginTop: '12px'}}/>
127128
<RepoVersionSearchAutocomplete versions={versions} label='Version' size='small' onChange={(id, item) => setRepoVersion(item)} value={repoVersion} sx={{marginTop: '12px'}} />
129+
<IncludeRetired checked={retired} onChange={setRetired} />
128130

129131
<Typography component="div" sx={{fontSize: '16px', fontWeight: 'bold', marginTop: '20px'}}>
130132
Matching Algorithm
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react'
2+
import Switch from '@mui/material/Switch';
3+
import FormControlLabel from '@mui/material/FormControlLabel';
4+
5+
const IncludeRetired = ({checked, onChange}) => {
6+
return (
7+
<FormControlLabel
8+
sx={{margin: '8px 0'}}
9+
size='small'
10+
control={<Switch size='small' checked={checked} onChange={() => onChange(!checked)} color='error' />}
11+
label="Include Retired"
12+
/>
13+
)
14+
}
15+
16+
export default IncludeRetired

src/components/map-projects/MapProject.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ const MapProject = () => {
162162
const [columnWidth, setColumnWidth] = React.useState({})
163163
const [logs, setLogs] = React.useState({})
164164
const [filterModel, setFilterModel] = React.useState({ items: [] });
165+
const [retired, setRetired] = React.useState(false)
165166

166167
// repo state
167168
const [repo, setRepo] = React.useState(false)
@@ -248,6 +249,7 @@ const MapProject = () => {
248249
setName(response.data?.name || '')
249250
setDescription(response.data?.description || '')
250251
setOwner(response.data?.owner_url)
252+
setRetired(Boolean(response.data?.include_retired))
251253
setProject(response.data)
252254
setConfigure(false)
253255
})
@@ -512,6 +514,7 @@ const MapProject = () => {
512514
if(repoVersion?.version_url)
513515
formData.append('target_repo_url', repoVersion.version_url)
514516
formData.append('matching_algorithm', algo)
517+
formData.append('include_retired', retired)
515518
let service = APIService.new().overrideURL(owner).appendToUrl('map-projects/')
516519
if(project?.id)
517520
service = service.appendToUrl(project.id + '/').put(formData, null, {"Content-Type": "multipart/form-data"})
@@ -1022,6 +1025,7 @@ const MapProject = () => {
10221025
.post(payload, null, null, {
10231026
includeSearchMeta: true,
10241027
includeMappings: true,
1028+
includeRetired: retired,
10251029
mappingBrief: true,
10261030
mapTypes: 'SAME-AS,SAME AS,SAME_AS',
10271031
verbose: true,
@@ -1053,7 +1057,7 @@ const MapProject = () => {
10531057
fetchOtherCandidates(null, currentResults)
10541058
}
10551059

1056-
const searchCandidates = (event, page, pageSize) => {
1060+
const searchCandidates = (event, page, pageSize, includeRetired) => {
10571061
setIsLoadingInDecisionView(true)
10581062
APIService.new().overrideURL(repoVersion.version_url).appendToUrl('concepts/').get(null, null, {
10591063
includeSearchMeta: true,
@@ -1064,6 +1068,7 @@ const MapProject = () => {
10641068
limit: pageSize || 5,
10651069
q: searchStr,
10661070
page: page || 1,
1071+
includeRetired: includeRetired === undefined ? retired : includeRetired
10671072
}).then(response => {
10681073
let items = response.data
10691074
setSearchedConcepts({...searchedConcepts, [row.__index]: items})
@@ -1159,6 +1164,8 @@ const MapProject = () => {
11591164
columnVisibilityModel={columnVisibilityModel}
11601165
setColumnVisibilityModel={setColumnVisibilityModel}
11611166
onSave={onSave}
1167+
retired={retired}
1168+
setRetired={setRetired}
11621169
/>
11631170
</div>
11641171
}
@@ -1485,6 +1492,8 @@ const MapProject = () => {
14851492
columnVisibilityModel={columnVisibilityModel}
14861493
setColumnVisibilityModel={setColumnVisibilityModel}
14871494
onSave={onSave}
1495+
retired={retired}
1496+
setRetired={setRetired}
14881497
/>
14891498
</div> :
14901499
(

0 commit comments

Comments
 (0)