Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#997 | Reference by expression fix for searc…
Browse files Browse the repository at this point in the history
…h of count
  • Loading branch information
snyaggarwal committed Jan 27, 2022
1 parent fcc026e commit 967aa11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/collections/ReferenceForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ class ReferenceForm extends React.Component {
}

getResourcesFromExpression(index) {
const newState = {...this.state};
const expression = get(newState.fields.expressions, index)
const expression = get(this.state.fields.expressions, index)
if(expression.uri) {
const service = isConcept(expression.uri) ? APIService.concepts() : APIService.mappings()
service.head(null, null, {uri: expression.uri}).then(response => {
if(get(response, 'status') === 200) {
const found = parseInt(get(response, 'headers.num_found'))
expression.count = (!isNaN(found) && isNumber(found)) ? found : undefined
const newState = {...this.state};
newState.expressions.splice(index, 1, expression)
this.setState(newState)
}
})
Expand Down

0 comments on commit 967aa11

Please sign in to comment.