OpenSlides/client/src/app/shared/parent-error-state-matcher.ts
Sean Engelhardt bc0fea3310 Update to Angular 8.0.6
Updates to angular 8 and updates all used components

- removed wrapper class for ngx/pwa LocalStorrace
- removed database lock service due to bugs
- tried to work around a cycle of dependancies
- changed some structure to be more close to default angular
- removed legacy angular packages
- removed date-picker since it was not currently used and
  is not compatible anymore
- upgrade tinyMCE
2019-07-04 14:20:57 +02:00

23 lines
948 B
TypeScript

import { ErrorStateMatcher } from '@angular/material/core';
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
/**
* Custom state matcher for mat-errors. Enables the error for an input, if one has set the error
* with `setError` on the parent element.
*/
export class ParentErrorStateMatcher implements ErrorStateMatcher {
public isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = !!(form && form.submitted);
const controlTouched = !!(control && (control.dirty || control.touched));
const controlInvalid = !!(control && control.invalid);
const parentInvalid = !!(
control &&
control.parent &&
control.parent.invalid &&
(control.parent.dirty || control.parent.touched)
);
return (isSubmitted || controlTouched) && (controlInvalid || parentInvalid);
}
}