Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1790 | create similar to not copy ids
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Mar 7, 2024
1 parent 733f50c commit 82bc22c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/collections/CollectionHomeChildrenList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CollectionHomeChildrenList extends React.Component {

getURL() {
const { selectedVersion } = this.state;
const { versionedObjectURL, resource, expansion, expansions } = this.props;
const { versionedObjectURL, resource, expansions } = this.props;
let url = this.props.collectionURLs.version || this.props.collectionURLs.collection || versionedObjectURL

if(resource === 'references') {
Expand Down
14 changes: 10 additions & 4 deletions src/components/concepts/ConceptForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ConceptForm extends React.Component {
}

setFieldsForEdit(data) {
const { edit } = this.props;
const { edit, copyFrom } = this.props;
const instance = data
const newState = {...this.state}
if(edit)
Expand All @@ -108,9 +108,15 @@ class ConceptForm extends React.Component {
newState.selected_concept_class = {id: instance.concept_class, name: instance.concept_class}
newState.selected_datatype = {id: instance.datatype, name: instance.datatype}
newState.fields.datatype = instance.datatype
newState.fields.external_id = instance.external_id || ''
newState.fields.names = isEmpty(instance.names) ? newState.fields.names : map(instance.names, name => pick(name, ['locale', 'name_type', 'locale_preferred', 'external_id', 'name']))
newState.fields.descriptions = isEmpty(instance.descriptions) ? newState.fields.descriptions : map(instance.descriptions, desc => pick(desc, ['locale', 'description_type', 'locale_preferred', 'external_id', 'description']))
newState.fields.external_id = copyFrom?.id ? '' : (instance.external_id || '')
let nameLocaleFields = ['locale', 'name_type', 'locale_preferred', 'name']
let descriptionLocaleFields = ['locale', 'description_type', 'locale_preferred', 'description']
if(!copyFrom?.id) {
nameLocaleFields.push('external_id')
descriptionLocaleFields.push('external_id')
}
newState.fields.names = isEmpty(instance.names) ? newState.fields.names : map(instance.names, name => pick(name, nameLocaleFields))
newState.fields.descriptions = isEmpty(instance.descriptions) ? newState.fields.descriptions : map(instance.descriptions, desc => pick(desc, descriptionLocaleFields))
newState.fields.extras = isEmpty(instance.extras) ? newState.fields.extras : map(instance.extras, (v, k) => ({key: k, value: v}))
newState.fields.parent_concept_urls = instance.parent_concept_urls || []
this.setState(newState);
Expand Down
5 changes: 4 additions & 1 deletion src/components/mappings/MappingForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ class MappingForm extends React.Component {
const { mapping, edit, copyFrom } = this.props;
const instance = edit ? mapping : copyFrom
const attrs = [
'id', 'map_type', 'external_id',
'id', 'map_type',
'from_concept_url', 'from_concept_name',
'from_source_url', 'from_source_version',
'to_concept_url', 'to_concept_name',
'to_source_url', 'to_source_version', 'sort_weight'
]
if(!copyFrom?.id) {
attrs.push('external_id')
}
const newState = {...this.state}
attrs.forEach(attr => set(newState.fields, attr, get(instance, attr, '') || ''))
newState.fields.to_concept_code = instance.to_concept_code ? decodeURIComponent(instance.to_concept_code) : instance.to_concept_code
Expand Down

0 comments on commit 82bc22c

Please sign in to comment.