Fix #2197 authority key lookup

Avoid an authority key lookup when it starts with "will be generated::"
This commit is contained in:
Sean Kalynuk
2023-04-19 16:44:04 -05:00
parent ade9533f4c
commit 73b2c0b29f
2 changed files with 12 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ export abstract class DsDynamicVocabularyComponent extends DynamicFormControlCom
*/
getInitValueFromModel(): Observable<FormFieldMetadataValueObject> {
let initValue$: Observable<FormFieldMetadataValueObject>;
if (isNotEmpty(this.model.value) && (this.model.value instanceof FormFieldMetadataValueObject)) {
if (isNotEmpty(this.model.value) && (this.model.value instanceof FormFieldMetadataValueObject) && !this.model.value.hasAuthorityToGenerate()) {
let initEntry$: Observable<VocabularyEntry>;
if (this.model.value.hasAuthority()) {
initEntry$ = this.vocabularyService.getVocabularyEntryByID(this.model.value.authority, this.model.vocabularyOptions);

View File

@@ -11,6 +11,10 @@ export interface OtherInformation {
* A class representing a specific input-form field's value
*/
export class FormFieldMetadataValueObject implements MetadataValueInterface {
static readonly AUTHORITY_SPLIT: string = '::';
static readonly AUTHORITY_GENERATE: string = 'will be generated' + FormFieldMetadataValueObject.AUTHORITY_SPLIT;
metadata?: string;
value: any;
display: string;
@@ -58,6 +62,13 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
return isNotEmpty(this.authority);
}
/**
* Returns true if this object has an authority value that needs to be generated
*/
hasAuthorityToGenerate(): boolean {
return isNotEmpty(this.authority) && this.authority.startsWith(FormFieldMetadataValueObject.AUTHORITY_GENERATE);
}
/**
* Returns true if this this object has a value
*/