Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1057 | Collection References | cascade sour…
Browse files Browse the repository at this point in the history
…ce to concepts option
  • Loading branch information
snyaggarwal committed Oct 28, 2021
1 parent 6f8798f commit 12f9b4e
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/common/AddToCollection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AddToCollection extends React.Component {
allCollections: [],
collections: [],
cascadeMappings: true,
cascadeToConcepts: false,
notAdded: [],
added: [],
collectionForm: false,
Expand Down Expand Up @@ -67,7 +68,7 @@ class AddToCollection extends React.Component {

handleDialogClose = () => this.setState({selectedCollection: null, notAdded: []})

onCheckboxChange = event => this.setState({cascadeMappings: event.target.checked})
onCheckboxChange = event => this.setState({[event.target.name]: event.target.checked})

handleMenuItemClick = (event, collection) => {
if(get(collection, 'id') === '__new__')
Expand All @@ -77,11 +78,16 @@ class AddToCollection extends React.Component {
}

handleAdd = () => {
const { selectedCollection, cascadeMappings } = this.state
const { selectedCollection, cascadeMappings, cascadeToConcepts } = this.state
const { references } = this.props
this.setState({isAdding: true}, () => {
const expressions = map(references, 'url')
const queryParams = cascadeMappings ? {cascade: 'sourcemappings'} : {}
let queryParams = {}
if(cascadeToConcepts)
queryParams = {cascade: 'sourceToConcepts'}
else if(cascadeMappings)
queryParams = {cascade: 'sourceMappings'}

APIService.new().overrideURL(selectedCollection.url)
.appendToUrl('references/')
.put({data: {expressions: expressions}}, null, null, queryParams)
Expand Down Expand Up @@ -142,7 +148,7 @@ class AddToCollection extends React.Component {

render() {
const {
open, allCollections, collections, selectedCollection, cascadeMappings, notAdded, added, isAdding, isLoading, searchedValue, collectionForm
open, allCollections, collections, selectedCollection, cascadeMappings, cascadeToConcepts, notAdded, added, isAdding, isLoading, searchedValue, collectionForm
} = this.state;
const { references } = this.props
const openDialog = Boolean(selectedCollection)
Expand Down Expand Up @@ -275,6 +281,17 @@ class AddToCollection extends React.Component {
</span>
}
/>
<FormControlLabel
control={<Checkbox checked={cascadeToConcepts} onChange={this.onCheckboxChange} name="cascadeToConcepts" size='small' style={{paddingRight: '4px'}}/>}
label={
<span className='flex-vertical-center'>
<span style={{marginRight: '5px', fontSize: '14px'}}>Automatically add associated mappings to concepts</span>
<Tooltip arrow title="A concept's associated mappings are mappings that originate from the specified concept (the 'from concept') and that are stored in the same source">
<HelpIcon fontSize='small' style={{fontSize: '14px'}}/>
</Tooltip>
</span>
}
/>
</DialogContent>
)
}
Expand Down

0 comments on commit 12f9b4e

Please sign in to comment.