diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index b3465e28a..facd5ed4f 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -113,14 +113,13 @@
- - - - - - + + + + + - +
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 23d6ce159..c0f1e44b7 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -879,6 +879,23 @@ describe('DocumentDetailComponent', () => { ) }) + it('should show custom field errors', () => { + initNormally() + component.error = { + custom_fields: [ + {}, + {}, + { value: ['This field may not be null.'] }, + {}, + { non_field_errors: ['Enter a valid URL.'] }, + ], + } + expect(component.getCustomFieldError(2)).toEqual([ + 'This field may not be null.', + ]) + expect(component.getCustomFieldError(4)).toEqual(['Enter a valid URL.']) + }) + function initNormally() { jest .spyOn(documentService, 'get') diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 227c86411..368f1e632 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -859,6 +859,11 @@ export class DocumentDetailComponent return this.customFields?.find((f) => f.id === instance.field) } + public getCustomFieldError(index: number) { + const fieldError = this.error?.custom_fields?.[index] + return fieldError?.['non_field_errors'] ?? fieldError?.['value'] + } + private updateFormForCustomFields(emitEvent: boolean = false) { this.customFieldFormFields.clear({ emitEvent: false }) this.document.custom_fields?.forEach((fieldInstance) => {