Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#985 | upgrading Autocomplete to use new ren…
Browse files Browse the repository at this point in the history
…derOption
  • Loading branch information
snyaggarwal committed Oct 20, 2021
1 parent 7508aca commit 74887e0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/components/common/ConceptContainersAutocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const ConceptContainersAutocomplete = ({onChange, items, label, id, required, se
params => <TextField {...params} required label={label || "Collection/Source"} variant="outlined" fullWidth />
}
renderOption={
option => (
<React.Fragment>
(props, option) => (
<li {...props} key={option.type + '-' + option.name}>
<span className='flex-vertical-center'>
<span style={{marginRight: '5px'}}>
{
Expand All @@ -33,7 +33,7 @@ const ConceptContainersAutocomplete = ({onChange, items, label, id, required, se
</span>
{option.name}
</span>
</React.Fragment>
</li>
)
}
onChange={(event, item) => onChange(get(item, 'type') || 'source', item)}
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/MixedOwnersAutocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ const MixedOwnersAutocomplete = ({onChange, label, id, required, minCharactersFo
)
}
renderOption={
option => (
<React.Fragment>
(props, option) => (
<li {...props} key={`${option.ownerType}-${option.name}`}>
<span className='flex-vertical-center'>
<span style={{marginRight: '5px'}}>
{
Expand All @@ -103,7 +103,7 @@ const MixedOwnersAutocomplete = ({onChange, label, id, required, minCharactersFo
</span>
{option.name}
</span>
</React.Fragment>
</li>
)
}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/ViewConfigForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ class ViewConfigForm extends React.Component {
onChange={(event, item) => this.onConfigurationChange(item)}
clearIcon={false}
renderOption={
option => (
<React.Fragment>
(props, option) => (
<li {...props} key={option.name}>
<span className='flex-vertical-center'>
{
option.id === 'new' ?
Expand All @@ -283,7 +283,7 @@ class ViewConfigForm extends React.Component {
}

</span>
</React.Fragment>
</li>
)
}
/>
Expand Down
20 changes: 11 additions & 9 deletions src/components/concepts/HierarchySearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ class HierarchySearch extends React.Component {
return name
}

getLabelDom = option => {
getLabelDom = (props, option) => {
const showName = option.display_name && option.display_name !== option.id
return (
<span style={{fontSize: '12px'}}>
<span>
{
showName ?
<React.Fragment><b>{option.id}</b>&nbsp;{option.display_name}</React.Fragment> :
<React.Fragment>{option.id}</React.Fragment>
}
<li {...props} key={option.id}>
<span style={{fontSize: '12px'}}>
<span>
{
showName ?
<React.Fragment><b>{option.id}</b>&nbsp;{option.display_name}</React.Fragment> :
<React.Fragment>{option.id}</React.Fragment>
}
</span>
</span>
</span>
</li>
)
}

Expand Down

0 comments on commit 74887e0

Please sign in to comment.