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) => { initValue$ = initEntry$.pipe(map((initEntry: VocabularyEntry) => {
if (isNotEmpty(initEntry)) { if (isNotEmpty(initEntry)) {
// Integrate FormFieldMetadataValueObject with retrieved information // Integrate FormFieldMetadataValueObject with retrieved information
return Object.assign(new FormFieldMetadataValueObject(), this.model.value, { return new FormFieldMetadataValueObject(
value: initEntry.value, initEntry.value,
authority: initEntry.authority, null,
display: initEntry.display, initEntry.authority,
otherInformation: initEntry.otherInformation || null initEntry.display,
}); null,
null,
initEntry.otherInformation || null
);
} else { } else {
return this.model.value as any; return this.model.value as any;
} }
})); }));
} else if (isNotEmpty(this.model.value) && (this.model.value instanceof VocabularyEntry)) { } else if (isNotEmpty(this.model.value) && (this.model.value instanceof VocabularyEntry)) {
initValue$ = observableOf(Object.assign(new FormFieldMetadataValueObject(), this.model.value, { initValue$ = observableOf(
value: this.model.value.value, new FormFieldMetadataValueObject(
authority: this.model.value.authority, this.model.value.value,
display: this.model.value.display, null,
otherInformation: this.model.value.otherInformation || null this.model.value.authority,
})); this.model.value.display,
null,
null,
this.model.value.otherInformation || null
)
);
} else { } else {
initValue$ = observableOf(new FormFieldMetadataValueObject(this.model.value)); initValue$ = observableOf(new FormFieldMetadataValueObject(this.model.value));
} }

View File

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