validation msg : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-05-31 11:17:24 +05:30
parent bf73ca220c
commit 2610ba397b

View File

@ -26,6 +26,9 @@ import { ActivatedRoute, Router } from '@angular/router';
import { RentalVerificationComponent } from './../rental-verification/rental-verification.component';
/**sweet alert */
import Swal from 'sweetalert2';
@Component({
selector: 'app-other-income',
templateUrl: './other-income.component.html',
@ -58,7 +61,6 @@ export class OtherIncomeComponent implements OnInit {
mergeCompanyApplicant: any = [];
isIncomeEarnedBy: any = [];
// stringArr = [];
constructor(notifier: NotifierService,
private fb: FormBuilder,
private route: ActivatedRoute,
@ -301,6 +303,10 @@ export class OtherIncomeComponent implements OnInit {
}
let records: any = {};
let rentOptionCount: number = 0;
let validateFlag: number = 0;
// let zeroEntries
records.parent_pdid = this.parent_pdid;
records.pdid = this.pdid;
records.formid = this.form_id;
@ -308,45 +314,68 @@ export class OtherIncomeComponent implements OnInit {
records.other_income = this.otherIncomeForm.controls['other_income'].value;
records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value;
if (this.otherIncomeForm.controls['other_income'].value == 'Yes') {
records.income_details = this.otherIncomeForm.controls['income_details'].value;
let s: number = 0;
let rentOptionCount: number = 0;
records.income_details.forEach(option => {
console.log(option);
console.log(option.source);
if (+option.source == 5) {
rentOptionCount++;
console.log(option.source);
let params: any = {};
params.parent_pdid = this.parent_pdid;
params.pd_id = this.pdid;
params.pd_form_id = this.rental_form_id;
this._pd.retriveForm(params).subscribe(data => {
data.dataStatus == false ? s = 1 : s = 0;
console.log(s);
if(s == 1){
this.notifier.notify('warning', "You have choose "+ rentOptionCount +" rent option but you didn't fill the rental verification form please fill it");
s = 0;
rentOptionCount = 0;
return;
}
});
}
if (+option.source == 5) {
rentOptionCount++;
validateFlag = 1;
}
});
if(s == 1){
this.notifier.notify('warning', "You have choose "+ rentOptionCount +" rent option but you didn't fill the rental verification form please fill it");
s = 0;
rentOptionCount = 0;
return;
if(validateFlag == 1){
let params: any = {};
let textMessage : any;
params.parent_pdid = this.parent_pdid;
params.pd_id = this.pdid;
params.pd_form_id = this.rental_form_id;
this._pd.retriveForm(params).subscribe(data => {
if(!data.dataStatus){
let text : any = rentOptionCount > 1 ? rentOptionCount + ' properties' : rentOptionCount + ' property' ;
// this.notifier.notify('warning', "You have chosen "+ rentOptionCount +" properties as rental income, but rental verification form is not filled");
textMessage = '<center> You have chosen '+ text +' as rental income, but rental verification form is not filled </center>';
Swal({
title: 'Please Confirm',
type: 'info',
html: textMessage,
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Confirm',
// cancelButtonText:'Cancel And Correct',
}).then((result) => {
if (result.value) {
console.log('rental data status is true',validateFlag);
this.saveAPI(records);
}
else{
console.log('rental data status is true',validateFlag);
// rentOptionCount = 0;
// validateFlag = 0 ;
return;
}
})
rentOptionCount = 0;
validateFlag = 0 ;
}
else if(data.dataStatus){
console.log('rental data status is true',validateFlag);
this.saveAPI(records);
}
});
}
else{
console.log('now flag is zero',validateFlag);
this.saveAPI(records);
}
}
else{
console.log('now option is no',validateFlag);
this.saveAPI(records);
}
}
saveAPI(records){
this._pd.saveForm(records).subscribe(data => {
if (data.status == 200) {
this.notifier.notify('success', 'Saved Successfully.');
@ -361,7 +390,6 @@ export class OtherIncomeComponent implements OnInit {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!' + '-' + error.error_text + ' occur');
})
}
validateAllFormFields(formGroup: any) {
Object.keys(formGroup.controls).forEach(field => {
const control = formGroup.get(field);