mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
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.
This commit is contained in:
@@ -50,8 +50,9 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
|
||||
|
||||
/**
|
||||
* Retrieves the init form value from model
|
||||
* @param preserveConfidence if the original model confidence value should be used after retrieving the vocabulary's entry
|
||||
*/
|
||||
getInitValueFromModel(): Observable<FormFieldMetadataValueObject> {
|
||||
getInitValueFromModel(preserveConfidence = false): Observable<FormFieldMetadataValueObject> {
|
||||
let initValue$: Observable<FormFieldMetadataValueObject>;
|
||||
if (isNotEmpty(this.model.value) && (this.model.value instanceof FormFieldMetadataValueObject) && !this.model.value.hasAuthorityToGenerate()) {
|
||||
let initEntry$: Observable<VocabularyEntry>;
|
||||
@@ -63,7 +64,7 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
|
||||
initValue$ = initEntry$.pipe(map((initEntry: VocabularyEntry) => {
|
||||
if (isNotEmpty(initEntry)) {
|
||||
// Integrate FormFieldMetadataValueObject with retrieved information
|
||||
return new FormFieldMetadataValueObject(
|
||||
let formField = new FormFieldMetadataValueObject(
|
||||
initEntry.value,
|
||||
null,
|
||||
initEntry.authority,
|
||||
@@ -72,6 +73,11 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
|
||||
null,
|
||||
initEntry.otherInformation || null
|
||||
);
|
||||
// Preserve the original confidence
|
||||
if (preserveConfidence) {
|
||||
formField.confidence = (this.model.value as any).confidence;
|
||||
}
|
||||
return formField;
|
||||
} else {
|
||||
return this.model.value as any;
|
||||
}
|
||||
|
@@ -273,7 +273,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
|
||||
let result: string;
|
||||
if (init) {
|
||||
this.changeLoadingInitialValueStatus(true);
|
||||
this.getInitValueFromModel()
|
||||
this.getInitValueFromModel(true)
|
||||
.subscribe((formValue: FormFieldMetadataValueObject) => {
|
||||
this.changeLoadingInitialValueStatus(false);
|
||||
this.currentValue = formValue;
|
||||
|
Reference in New Issue
Block a user