Check admin config when loading the page
Avoid issues when an invalid config was set in the configuration file
This commit is contained in:
parent
08d2761097
commit
8b69f9f028
|
@ -292,6 +292,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
formValidated () {
|
formValidated () {
|
||||||
|
this.forceCheck()
|
||||||
|
if (!this.form.valid) return
|
||||||
|
|
||||||
const value: ComponentCustomConfig = this.form.getRawValue()
|
const value: ComponentCustomConfig = this.form.getRawValue()
|
||||||
|
|
||||||
forkJoin([
|
forkJoin([
|
||||||
|
@ -381,8 +384,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
||||||
this.customConfig = { ...config, instanceCustomHomepage: homepage }
|
this.customConfig = { ...config, instanceCustomHomepage: homepage }
|
||||||
|
|
||||||
this.updateForm()
|
this.updateForm()
|
||||||
// Force form validation
|
this.markAllAsDirty()
|
||||||
this.forceCheck()
|
|
||||||
},
|
},
|
||||||
|
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import { FormGroup } from '@angular/forms'
|
import { AbstractControl, FormGroup } from '@angular/forms'
|
||||||
import { wait } from '@root-helpers/utils'
|
import { wait } from '@root-helpers/utils'
|
||||||
import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
|
import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
|
||||||
import { FormValidatorService } from './form-validator.service'
|
import { FormValidatorService } from './form-validator.service'
|
||||||
|
@ -44,6 +44,21 @@ export abstract class FormReactive {
|
||||||
} while (this.form.status === 'PENDING')
|
} while (this.form.status === 'PENDING')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected markAllAsDirty (controlsArg?: { [ key: string ]: AbstractControl }) {
|
||||||
|
const controls = controlsArg || this.form.controls
|
||||||
|
|
||||||
|
for (const key of Object.keys(controls)) {
|
||||||
|
const control = controls[key]
|
||||||
|
|
||||||
|
if (control instanceof FormGroup) {
|
||||||
|
this.markAllAsDirty(control.controls)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
control.markAsDirty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected forceCheck () {
|
protected forceCheck () {
|
||||||
this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false)
|
this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +74,8 @@ export abstract class FormReactive {
|
||||||
this.onStatusChanged(
|
this.onStatusChanged(
|
||||||
form.controls[field] as FormGroup,
|
form.controls[field] as FormGroup,
|
||||||
formErrors[field] as FormReactiveErrors,
|
formErrors[field] as FormReactiveErrors,
|
||||||
validationMessages[field] as FormReactiveValidationMessages
|
validationMessages[field] as FormReactiveValidationMessages,
|
||||||
|
onlyDirty
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue