From a504b7cbd340243406f15e88f7325949e724b8f5 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 3 Sep 2020 11:18:32 +0200 Subject: [PATCH] Fixed issue with form field losing confidence value --- .../models/dynamic-vocabulary.component.ts | 32 ++++++++++++------- .../models/form-field-metadata-value.model.ts | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-vocabulary.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-vocabulary.component.ts index d3263f1584..3c95aa0585 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-vocabulary.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-vocabulary.component.ts @@ -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)); } diff --git a/src/app/shared/form/builder/models/form-field-metadata-value.model.ts b/src/app/shared/form/builder/models/form-field-metadata-value.model.ts index 7f43349c6c..a80dbdc7de 100644 --- a/src/app/shared/form/builder/models/form-field-metadata-value.model.ts +++ b/src/app/shared/form/builder/models/form-field-metadata-value.model.ts @@ -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;