Fixed issue with form field losing confidence value

This commit is contained in:
Giuseppe Digilio
2020-09-03 11:18:32 +02:00
parent 7d22bcc59c
commit a504b7cbd3
2 changed files with 21 additions and 13 deletions

View File

@@ -60,23 +60,31 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
initValue$ = initEntry$.pipe(map((initEntry: VocabularyEntry) => {
if (isNotEmpty(initEntry)) {
// Integrate FormFieldMetadataValueObject with retrieved information
return Object.assign(new FormFieldMetadataValueObject(), this.model.value, {
value: initEntry.value,
authority: initEntry.authority,
display: initEntry.display,
otherInformation: initEntry.otherInformation || null
});
return new FormFieldMetadataValueObject(
initEntry.value,
null,
initEntry.authority,
initEntry.display,
null,
null,
initEntry.otherInformation || null
);
} else {
return this.model.value as any;
}
}));
} else if (isNotEmpty(this.model.value) && (this.model.value instanceof VocabularyEntry)) {
initValue$ = observableOf(Object.assign(new FormFieldMetadataValueObject(), this.model.value, {
value: this.model.value.value,
authority: this.model.value.authority,
display: this.model.value.display,
otherInformation: this.model.value.otherInformation || null
}));
initValue$ = observableOf(
new FormFieldMetadataValueObject(
this.model.value.value,
null,
this.model.value.authority,
this.model.value.display,
null,
null,
this.model.value.otherInformation || null
)
);
} else {
initValue$ = observableOf(new FormFieldMetadataValueObject(this.model.value));
}

View File

@@ -35,7 +35,7 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
this.display = display || value;
this.confidence = confidence;
if (authority != null && isEmpty(confidence)) {
if (authority != null && (isEmpty(confidence) || confidence === -1)) {
this.confidence = ConfidenceType.CF_ACCEPTED;
} else if (isNotEmpty(confidence)) {
this.confidence = confidence;