64503: Metadata Format resetting to initial state fix

This commit is contained in:
Kristof De Langhe
2019-11-12 13:16:41 +01:00
parent 2d3d7ae71e
commit 857f796287

View File

@@ -284,9 +284,12 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
this.updateSub = this.update$.subscribe((update: FieldUpdate) => { this.updateSub = this.update$.subscribe((update: FieldUpdate) => {
if (update) { if (update) {
const field = update.field as ContentSource; const field = update.field as ContentSource;
let defaultConfigId; let configId;
if (hasValue(this.contentSource) && isNotEmpty(this.contentSource.metadataConfigs)) { if (hasValue(this.contentSource) && isNotEmpty(this.contentSource.metadataConfigs)) {
defaultConfigId = this.contentSource.metadataConfigs[0].id; configId = this.contentSource.metadataConfigs[0].id;
}
if (hasValue(field) && hasValue(field.metadataConfigId)) {
configId = field.metadataConfigId;
} }
if (hasValue(field)) { if (hasValue(field)) {
this.formGroup.patchValue({ this.formGroup.patchValue({
@@ -295,7 +298,7 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
}, },
oaiSetContainer: { oaiSetContainer: {
oaiSetId: field.oaiSetId, oaiSetId: field.oaiSetId,
metadataConfigId: field.metadataConfigId || defaultConfigId metadataConfigId: configId
}, },
harvestTypeContainer: { harvestTypeContainer: {
harvestType: field.harvestType harvestType: field.harvestType
@@ -303,7 +306,7 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
}); });
this.contentSource = cloneDeep(field); this.contentSource = cloneDeep(field);
} }
this.contentSource.metadataConfigId = defaultConfigId; this.contentSource.metadataConfigId = configId;
} }
}); });
} }