Skip to content

Commit 1fc0462

Browse files
committed
Preserve the confidence value when loading the initial value of the model into the DsDynamicOneboxComponent. Previously, the accepted confidence value was always displayed if a valid vocabulary entry was retrieved, incorrectly displaying it for values without accepted authority.
1 parent 7253a59 commit 1fc0462

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-vocabulary.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
5050

5151
/**
5252
* Retrieves the init form value from model
53+
* @param preserveConfidence if the original model confidence value should be used after retrieving the vocabulary's entry
5354
*/
54-
getInitValueFromModel(): Observable<FormFieldMetadataValueObject> {
55+
getInitValueFromModel(preserveConfidence = false): Observable<FormFieldMetadataValueObject> {
5556
let initValue$: Observable<FormFieldMetadataValueObject>;
5657
if (isNotEmpty(this.model.value) && (this.model.value instanceof FormFieldMetadataValueObject) && !this.model.value.hasAuthorityToGenerate()) {
5758
let initEntry$: Observable<VocabularyEntry>;
@@ -63,7 +64,7 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
6364
initValue$ = initEntry$.pipe(map((initEntry: VocabularyEntry) => {
6465
if (isNotEmpty(initEntry)) {
6566
// Integrate FormFieldMetadataValueObject with retrieved information
66-
return new FormFieldMetadataValueObject(
67+
let formField = new FormFieldMetadataValueObject(
6768
initEntry.value,
6869
null,
6970
initEntry.authority,
@@ -72,6 +73,11 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
7273
null,
7374
initEntry.otherInformation || null
7475
);
76+
// Preserve the original confidence
77+
if (preserveConfidence) {
78+
formField.confidence = (this.model.value as any).confidence;
79+
}
80+
return formField;
7581
} else {
7682
return this.model.value as any;
7783
}

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
273273
let result: string;
274274
if (init) {
275275
this.changeLoadingInitialValueStatus(true);
276-
this.getInitValueFromModel()
276+
this.getInitValueFromModel(true)
277277
.subscribe((formValue: FormFieldMetadataValueObject) => {
278278
this.changeLoadingInitialValueStatus(false);
279279
this.currentValue = formValue;

0 commit comments

Comments
 (0)