Fixes child selection function on the mapping form.
This commit is contained in:
parent
782e685df6
commit
958e258195
|
@ -140,7 +140,7 @@
|
||||||
!isFetchingCollectionMetadata"
|
!isFetchingCollectionMetadata"
|
||||||
:disabled="[undefined, null, false, 'create_metadata' + index].includes(checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
|
:disabled="[undefined, null, false, 'create_metadata' + index].includes(checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
|
||||||
:value="checkCurrentSelectedCollectionChildMetadatum(childSourceMetadatum, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
|
:value="checkCurrentSelectedCollectionChildMetadatum(childSourceMetadatum, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
|
||||||
@input="onSelectCollectionChildMetadata($event, childSourceMetadatum, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
|
@input="onSelectCollectionChildMetadata($event, childSourceMetadatum, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true), Object.entries(sourceMetadatum)[0][0])"
|
||||||
:placeholder="$i18n.get('label_select_metadatum')">
|
:placeholder="$i18n.get('label_select_metadatum')">
|
||||||
<option :value="null">
|
<option :value="null">
|
||||||
{{ $i18n.get('label_select_metadatum') }}
|
{{ $i18n.get('label_select_metadatum') }}
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
v-for="(collectionMetadatum, metadatumIndex) of getChildOfSelectedCompoundMetadata(sourceMetadatum)"
|
v-for="(collectionMetadatum, metadatumIndex) of getChildOfSelectedCompoundMetadata(sourceMetadatum)"
|
||||||
:key="metadatumIndex"
|
:key="metadatumIndex"
|
||||||
:value="collectionMetadatum.id"
|
:value="collectionMetadatum.id"
|
||||||
:disabled="checkIfMetadatumIsAvailable(collectionMetadatum.id)">
|
:disabled="checkIfChildMetadatumIsAvailable(collectionMetadatum.id, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true), Object.entries(sourceMetadatum)[0][0])">
|
||||||
<span class="metadatum-name">
|
<span class="metadatum-name">
|
||||||
{{ collectionMetadatum.name }}
|
{{ collectionMetadatum.name }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -543,6 +543,16 @@ export default {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
checkIfChildMetadatumIsAvailable(metadatumId, parentId, parentSource) {
|
||||||
|
if (this.mappedCollection['mapping'][parentId] &&
|
||||||
|
this.mappedCollection['mapping'][parentId][parentSource] &&
|
||||||
|
this.mappedCollection['mapping'][parentId][parentSource][metadatumId] &&
|
||||||
|
this.importerSourceInfo != undefined &&
|
||||||
|
this.importerSourceInfo != null)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
},
|
||||||
checkIfMetadatumIsCompound(metadatum) {
|
checkIfMetadatumIsCompound(metadatum) {
|
||||||
return metadatum.metadata_type_object && metadatum.metadata_type_object.component && metadatum.metadata_type_object.component == 'tainacan-compound';
|
return metadatum.metadata_type_object && metadatum.metadata_type_object.component && metadatum.metadata_type_object.component == 'tainacan-compound';
|
||||||
},
|
},
|
||||||
|
@ -611,22 +621,23 @@ export default {
|
||||||
this.$console.log(errors);
|
this.$console.log(errors);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onSelectCollectionChildMetadata(selectedMetadatum, sourceMetadatum, parent) {
|
onSelectCollectionChildMetadata(selectedMetadatum, sourceMetadatum, parentId, parentSource) {
|
||||||
|
|
||||||
if (this.mappedCollection['mapping'][parent] && Object.values(this.mappedCollection['mapping'][parent]) && Object.values(this.mappedCollection['mapping'][parent])[0]) {
|
if (this.mappedCollection['mapping'][parentId] && this.mappedCollection['mapping'][parentId] && this.mappedCollection['mapping'][parentId][parentSource]) {
|
||||||
let parentMappings = Object.values(this.mappedCollection['mapping'][parent])[0]
|
let parentMappings = Array.isArray(this.mappedCollection['mapping'][parentId][parentSource]) ? {} : this.mappedCollection['mapping'][parentId][parentSource];
|
||||||
|
|
||||||
let removedKey = '';
|
let removedKey = '';
|
||||||
for (let key in parentMappings) {
|
for (let key in parentMappings) {
|
||||||
if (parentMappings[key] == sourceMetadatum)
|
if (parentMappings[key] == sourceMetadatum)
|
||||||
removedKey = key;
|
removedKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removedKey != '')
|
if (removedKey != '')
|
||||||
delete parentMappings[removedKey];
|
delete parentMappings[removedKey];
|
||||||
|
|
||||||
|
if (selectedMetadatum)
|
||||||
parentMappings[selectedMetadatum] = sourceMetadatum;
|
parentMappings[selectedMetadatum] = sourceMetadatum;
|
||||||
|
|
||||||
|
this.mappedCollection['mapping'][parentId][parentSource] = parentMappings;
|
||||||
// Necessary for causing reactivity to re-check if metadata remains available
|
// Necessary for causing reactivity to re-check if metadata remains available
|
||||||
this.collectionMetadata.push("");
|
this.collectionMetadata.push("");
|
||||||
this.collectionMetadata.pop();
|
this.collectionMetadata.pop();
|
||||||
|
|
Loading…
Reference in New Issue