-import { Component, Input, OnInit } from '@angular/core';
+import { Component, ContentChild, Input, OnInit, TemplateRef } from '@angular/core';
import { FormArray, FormControl, NgForm, Validators } from '@angular/forms';
import _ from 'lodash';
@Input()
clients: any[];
+ @ContentChild('squashHelper', { static: true }) squashHelperTpl: TemplateRef<any>;
+
nfsSquash: any[] = this.nfsService.nfsSquash;
nfsAccessType: any[] = this.nfsService.nfsAccessType;
icons = Icons;
+ clientsFormArray: FormArray;
constructor(private nfsService: NfsService) {}
const fg = this.addClient();
fg.patchValue(client);
});
+ this.clientsFormArray = this.form.get('clients') as FormArray;
}
getNoAccessTypeDescr() {
}
addClient() {
- const clients = this.form.get('clients') as FormArray;
+ this.clientsFormArray = this.form.get('clients') as FormArray;
const REGEX_IP = `(([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\.([0-9]{1,3})([/](\\d|[1-2]\\d|3[0-2]))?)`;
const REGEX_LIST_IP = `${REGEX_IP}([ ,]{1,2}${REGEX_IP})*`;
-
const fg = new CdFormGroup({
addresses: new FormControl('', {
validators: [Validators.required, Validators.pattern(REGEX_LIST_IP)]
squash: new FormControl('')
});
- clients.push(fg);
+ this.clientsFormArray.push(fg);
return fg;
}
removeClient(index: number) {
- const clients = this.form.get('clients') as FormArray;
- clients.removeAt(index);
+ this.clientsFormArray = this.form.get('clients') as FormArray;
+ this.clientsFormArray.removeAt(index);
}
showError(index: number, control: string, formDir: NgForm, x: string) {
}
getValue(index: number, control: string) {
- const clients = this.form.get('clients') as FormArray;
- const client = clients.at(index) as CdFormGroup;
+ this.clientsFormArray = this.form.get('clients') as FormArray;
+ const client = this.clientsFormArray.at(index) as CdFormGroup;
return client.getValue(control);
}