From 45ba09fef3b970fb916ffb1b0ac7509db7bbdde6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Feb 2021 12:06:26 +0100 Subject: Improve edit config submit error --- .../edit-custom-config.component.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index bbdf1bfbe..2c7a10937 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -290,6 +290,25 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { this.router.navigate([], { fragment: this.activeNav }) } + grabAllErrors (errorObjectArg?: any) { + const errorObject = errorObjectArg || this.formErrors + + let acc: string[] = [] + + for (const key of Object.keys(errorObject)) { + const value = errorObject[key] + if (!value) continue + + if (typeof value === 'string') { + acc.push(value) + } else { + acc = acc.concat(this.grabAllErrors(value)) + } + } + + return acc + } + private updateForm () { this.form.patchValue(this.customConfig) } -- cgit v1.2.3