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
|
* 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>;
|
let initValue$: Observable<FormFieldMetadataValueObject>;
|
||||||
if (isNotEmpty(this.model.value) && (this.model.value instanceof FormFieldMetadataValueObject) && !this.model.value.hasAuthorityToGenerate()) {
|
if (isNotEmpty(this.model.value) && (this.model.value instanceof FormFieldMetadataValueObject) && !this.model.value.hasAuthorityToGenerate()) {
|
||||||
let initEntry$: Observable<VocabularyEntry>;
|
let initEntry$: Observable<VocabularyEntry>;
|
||||||
@@ -63,7 +64,7 @@ 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 new FormFieldMetadataValueObject(
|
let formField = new FormFieldMetadataValueObject(
|
||||||
initEntry.value,
|
initEntry.value,
|
||||||
null,
|
null,
|
||||||
initEntry.authority,
|
initEntry.authority,
|
||||||
@@ -72,6 +73,11 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
|
|||||||
null,
|
null,
|
||||||
initEntry.otherInformation || null
|
initEntry.otherInformation || null
|
||||||
);
|
);
|
||||||
|
// Preserve the original confidence
|
||||||
|
if (preserveConfidence) {
|
||||||
|
formField.confidence = (this.model.value as any).confidence;
|
||||||
|
}
|
||||||
|
return formField;
|
||||||
} else {
|
} else {
|
||||||
return this.model.value as any;
|
return this.model.value as any;
|
||||||
}
|
}
|
||||||
|
@@ -273,7 +273,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
|
|||||||
let result: string;
|
let result: string;
|
||||||
if (init) {
|
if (init) {
|
||||||
this.changeLoadingInitialValueStatus(true);
|
this.changeLoadingInitialValueStatus(true);
|
||||||
this.getInitValueFromModel()
|
this.getInitValueFromModel(true)
|
||||||
.subscribe((formValue: FormFieldMetadataValueObject) => {
|
.subscribe((formValue: FormFieldMetadataValueObject) => {
|
||||||
this.changeLoadingInitialValueStatus(false);
|
this.changeLoadingInitialValueStatus(false);
|
||||||
this.currentValue = formValue;
|
this.currentValue = formValue;
|
||||||
|
Reference in New Issue
Block a user