Merge branch 'master' of https://bitbucket.org/sriramv18/sparqsineedge
This commit is contained in:
commit
4bed8d3d04
@ -63,11 +63,11 @@
|
||||
<mat-card-content>
|
||||
<div fxLayout="row wrap" formArrayName="companies">
|
||||
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100" *ngFor="let com of _generalForm.controls.companies['controls']; let c = index;" [formGroupName]="c">
|
||||
<mat-form-field style="width: 60%">
|
||||
<mat-form-field style="width: 60%" *ngIf="com.value.is_active==true">
|
||||
<input matInput placeholder="Company/Firm" formControlName="company_name" type="text">
|
||||
</mat-form-field>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More Company/Firm" matTooltipPosition="above" color="primary" (click)="addMoreCompanies()" *ngIf="c==0"><mat-icon>add</mat-icon></button>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanies(c)" *ngIf="c>0"
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanies(c)" *ngIf="c>0 && com.value.is_active==true"
|
||||
matTooltip="Remove Company/Firm" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
|
||||
@ -4,6 +4,8 @@ import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , MatTableDataSource} from '@a
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { PdTrigerService } from './../../../../../pd-service/pd-triger.service';
|
||||
import {OtherApplicantDetailsComponent} from './../dialogue/other-applicant-details/other-applicant-details.component';
|
||||
import { element } from '@angular/core/src/render3/instructions';
|
||||
import { ELEMENT_PROBE_PROVIDERS } from '@angular/platform-browser/src/dom/debug/ng_probe';
|
||||
@Component({
|
||||
selector: 'app-general-info',
|
||||
templateUrl: './general-info.component.html',
|
||||
@ -47,7 +49,7 @@ export class GeneralInfoComponent implements OnInit {
|
||||
// update company details
|
||||
this._generalForm.controls['companies'].valueChanges.subscribe(val=>{
|
||||
let control = <FormArray>this._generalForm.controls['companies'];
|
||||
this.companyList = control.value.filter(element =>element.company_name);
|
||||
this.companyList = control.value.filter(element =>element.company_name && element.is_active);
|
||||
});
|
||||
}
|
||||
|
||||
@ -113,8 +115,14 @@ export class GeneralInfoComponent implements OnInit {
|
||||
return data.records.companies[key];
|
||||
});
|
||||
if(exist_companies.length>0){
|
||||
exist_companies.forEach(element => {
|
||||
companyControl.push(this.createCompanies(element))
|
||||
exist_companies.forEach((element,cindex) => {
|
||||
companyControl.push(this.createCompanies(element));
|
||||
if(element.is_active==false){
|
||||
let control: any = this._generalForm.get('companies') as FormArray;
|
||||
control.controls[cindex].controls.company_name.clearValidators();
|
||||
control.controls[cindex].controls.company_name.updateValueAndValidity();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -134,11 +142,6 @@ export class GeneralInfoComponent implements OnInit {
|
||||
innercomrelControl.push(this.createMultipleCompanyRelation(innerecomElement));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -158,13 +161,13 @@ export class GeneralInfoComponent implements OnInit {
|
||||
|
||||
// create companies
|
||||
if(element.company_name!='' && element.company_name!=null){
|
||||
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:element.company_name}
|
||||
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:element.company_name,is_active:true}
|
||||
companyControl.push(this.createCompanies(setCompanyValues))
|
||||
}
|
||||
});
|
||||
// check company if null update one row
|
||||
if(companyControl.controls.length ==0){
|
||||
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:''}
|
||||
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:'',is_active:true}
|
||||
companyControl.push(this.createCompanies(setCompanyValues))
|
||||
|
||||
}
|
||||
@ -187,20 +190,24 @@ export class GeneralInfoComponent implements OnInit {
|
||||
return this._fb.group({
|
||||
company_order_id: [elementValue.company_order_id],
|
||||
company_name: [elementValue.company_name,Validators.required],
|
||||
is_active: [elementValue.is_active]
|
||||
});
|
||||
}
|
||||
|
||||
// add more companies
|
||||
addMoreCompanies() {
|
||||
let control: any = this._generalForm.get('companies') as FormArray;
|
||||
let setValues: any = {company_order_id :control.controls.length+1,company_name:''}
|
||||
let setValues: any = {company_order_id :control.controls.length+1,company_name:'',is_active:true}
|
||||
control.push(this.createCompanies(setValues))
|
||||
}
|
||||
|
||||
// remove companies
|
||||
removeCompanies(indexValues) {
|
||||
let control: any = this._generalForm.get('companies') as FormArray;
|
||||
control.removeAt(indexValues);
|
||||
control.controls[indexValues].controls.is_active.setValue(false);
|
||||
control.controls[indexValues].controls.company_name.clearValidators();
|
||||
control.controls[indexValues].controls.company_name.updateValueAndValidity();
|
||||
//control.removeAt(indexValues);
|
||||
}
|
||||
|
||||
// create applicant form array
|
||||
|
||||
Loading…
Reference in New Issue
Block a user