Vendor Question Validators remove

This commit is contained in:
sriram-at-840620226347 2020-07-28 18:47:10 +05:30
parent 9204bc657b
commit f410e46d73
5 changed files with 71 additions and 29 deletions

View File

@ -132,7 +132,7 @@
placeholder="Enter actual PD address" placeholder="Enter actual PD address"
formControlName="alternative_address" formControlName="alternative_address"
[value]="alter_addr.get('alternative_address').value" [value]="alter_addr.get('alternative_address').value"
required autocomplete="off" appCustomTitleCase> autocomplete="off" appCustomTitleCase>
<mat-error <mat-error
*ngIf="alter_addr.controls['alternative_address'].hasError('required')"> *ngIf="alter_addr.controls['alternative_address'].hasError('required')">
Alternative Address Required</mat-error> Alternative Address Required</mat-error>
@ -202,7 +202,7 @@
<input matInput <input matInput
[placeholder]="(fk_pd_type == '3' || fk_pd_type == '2') ? 'Reason for change in business address' : 'Reason for change in PD visit address'" [placeholder]="(fk_pd_type == '3' || fk_pd_type == '2') ? 'Reason for change in business address' : 'Reason for change in PD visit address'"
formControlName="reason_for_alternative_address" formControlName="reason_for_alternative_address"
required autocomplete="off"> autocomplete="off">
<mat-error <mat-error
*ngIf="alter_addr.controls['reason_for_alternative_address'].hasError('required')"> *ngIf="alter_addr.controls['reason_for_alternative_address'].hasError('required')">
Reason Required</mat-error> Reason Required</mat-error>
@ -218,7 +218,6 @@
<div fxFlex="100"> <div fxFlex="100">
<mat-form-field style="width: 46%;"> <mat-form-field style="width: 46%;">
<mat-select placeholder="Address Type" formControlName="address_type" <mat-select placeholder="Address Type" formControlName="address_type"
required
(selectionChange)="setOthers($event.value,'',3);selectedAddressType($event.source.triggerValue)"> (selectionChange)="setOthers($event.value,'',3);selectedAddressType($event.source.triggerValue)">
<mat-option>Select</mat-option> <mat-option>Select</mat-option>
<mat-option value="{{m_addressType.address_type_id}}" <mat-option value="{{m_addressType.address_type_id}}"
@ -234,8 +233,7 @@
<mat-form-field style="width: 46%;" <mat-form-field style="width: 46%;"
*ngIf="addressForm.controls['address_type'].value == 1 && addressForm.controls['address_type_others']"> *ngIf="addressForm.controls['address_type'].value == 1 && addressForm.controls['address_type_others']">
<input matInput placeholder="Specify Address Type " required <input matInput placeholder="Specify Address Type " formControlName="address_type_others" autocomplete="off"
formControlName="address_type_others" autocomplete="off"
(change)="selectedAddressType($event.target.value)"> (change)="selectedAddressType($event.target.value)">
<mat-error <mat-error
*ngIf="addressForm.controls['address_type_others'].hasError('required')"> *ngIf="addressForm.controls['address_type_others'].hasError('required')">
@ -248,7 +246,7 @@
<div fxLayout="row wrap"> <div fxLayout="row wrap">
<div fxFlex="100"> <div fxFlex="100">
<mat-form-field style="width: 46%;"> <mat-form-field style="width: 46%;">
<mat-select placeholder="Locality" formControlName="locality" required <mat-select placeholder="Locality" formControlName="locality"
(selectionChange)="setOthers($event.value,'',4)"> (selectionChange)="setOthers($event.value,'',4)">
<mat-option>Select</mat-option> <mat-option>Select</mat-option>
<mat-option value="{{m_locality.locality_id}}" <mat-option value="{{m_locality.locality_id}}"
@ -263,7 +261,7 @@
<mat-form-field style="width: 46%;" <mat-form-field style="width: 46%;"
*ngIf="addressForm.controls['locality'].value == 1 && addressForm.controls['locality_others']"> *ngIf="addressForm.controls['locality'].value == 1 && addressForm.controls['locality_others']">
<input matInput placeholder="Specify Locality " required <input matInput placeholder="Specify Locality "
formControlName="locality_others" autocomplete="off"> formControlName="locality_others" autocomplete="off">
<!-- autofocus --> <!-- autofocus -->
<!-- <mat-error *ngIf="!addressForm.controls['locality_others'].hasError('required')">Locality Required</mat-error> --> <!-- <mat-error *ngIf="!addressForm.controls['locality_others'].hasError('required')">Locality Required</mat-error> -->
@ -283,7 +281,7 @@
<div fxFlex="100"> <div fxFlex="100">
<mat-form-field style="width: 46%;" *ngIf="fk_pd_type != '3'"> <mat-form-field style="width: 46%;" *ngIf="fk_pd_type != '3'">
<mat-select placeholder="Approach to PD Location" <mat-select placeholder="Approach to PD Location"
formControlName="pd_location" required> formControlName="pd_location">
<mat-option>Select</mat-option> <mat-option>Select</mat-option>
<mat-option value="{{data.pd_location_approach_id}}" <mat-option value="{{data.pd_location_approach_id}}"
*ngFor="let data of locationdata">{{data.description}} *ngFor="let data of locationdata">{{data.description}}
@ -296,7 +294,7 @@
<mat-form-field style="width: 46%;" *ngIf="fk_pd_type != '3'"> <mat-form-field style="width: 46%;" *ngIf="fk_pd_type != '3'">
<mat-select placeholder="Comment on Locality" <mat-select placeholder="Comment on Locality"
formControlName="comment_locality" required> formControlName="comment_locality">
<mat-option>Select</mat-option> <mat-option>Select</mat-option>
<mat-option value="{{data.comments_on_locality_id}}" <mat-option value="{{data.comments_on_locality_id}}"
*ngFor="let data of commentData">{{data.rating}} *ngFor="let data of commentData">{{data.rating}}
@ -329,7 +327,7 @@
<mat-form-field style="width: 24%" <mat-form-field style="width: 24%"
*ngIf="addressForm.controls['uom'].value == 1"> *ngIf="addressForm.controls['uom'].value == 1">
<input matInput placeholder="Specify UOM" formControlName="uom_others" <input matInput placeholder="Specify UOM" formControlName="uom_others"
autocomplete="off" required> autocomplete="off" >
<mat-error <mat-error
*ngIf="addressForm.controls['uom_others'].hasError('required')"> *ngIf="addressForm.controls['uom_others'].hasError('required')">
UOM Required</mat-error> UOM Required</mat-error>

View File

@ -246,11 +246,32 @@ export class AddressComponent implements OnInit {
address_form_remark: [''] address_form_remark: ['']
}); });
if(this.fk_pd_type == '3' || this.fk_pd_type == '2'){ if(this.fk_pd_type == '3' || this.fk_pd_type == '2'){
this.addressForm.controls['is_pd_done_on_initiated_address'].clearValidators();
this.addressForm.controls['is_pd_done_on_initiated_address'].updateValueAndValidity();
this.addressForm.controls['address_type'].clearValidators();
this.addressForm.controls['address_type'].updateValueAndValidity();
this.addressForm.controls['locality'].clearValidators();
this.addressForm.controls['locality'].updateValueAndValidity();
this.addressForm.controls['locality_mixuse'].clearValidators();
this.addressForm.controls['locality_mixuse'].updateValueAndValidity();
this.addressForm.controls['pd_location'].clearValidators();
this.addressForm.controls['pd_location'].updateValueAndValidity();
this.addressForm.controls['pd_location'].clearValidators(); this.addressForm.controls['pd_location'].clearValidators();
this.addressForm.controls['pd_location'].updateValueAndValidity(); this.addressForm.controls['pd_location'].updateValueAndValidity();
this.addressForm.controls['comment_locality'].clearValidators(); this.addressForm.controls['comment_locality'].clearValidators();
this.addressForm.controls['comment_locality'].updateValueAndValidity(); this.addressForm.controls['comment_locality'].updateValueAndValidity();
this.addressForm.controls['estimated_area'].clearValidators();
this.addressForm.controls['estimated_area'].updateValueAndValidity();
this.addressForm.controls['uom'].clearValidators();
this.addressForm.controls['uom'].updateValueAndValidity();
} }
if(this.lender_short_name == 'CLIX' || this.prod_catagory == 'BL'){ if(this.lender_short_name == 'CLIX' || this.prod_catagory == 'BL'){
this.addressForm.removeControl('estimated_area'); this.addressForm.removeControl('estimated_area');
@ -296,7 +317,7 @@ export class AddressComponent implements OnInit {
createAlternativeAddresses(AddressDetails): FormGroup { createAlternativeAddresses(AddressDetails): FormGroup {
if (AddressDetails != null) { if (AddressDetails != null) {
return this.fb.group({ return this.fb.group({
alternative_address: [this.transformName(AddressDetails.alternative_address), Validators.compose([Validators.required])], alternative_address: [this.transformName(AddressDetails.alternative_address)],
alternative_state: [AddressDetails.alternative_state], alternative_state: [AddressDetails.alternative_state],
alternative_city: [AddressDetails.alternative_city], alternative_city: [AddressDetails.alternative_city],
alternative_pincode: [AddressDetails.alternative_pincode], alternative_pincode: [AddressDetails.alternative_pincode],
@ -305,13 +326,13 @@ export class AddressComponent implements OnInit {
pinSearch:[''], pinSearch:[''],
alternative_pd_address_id:[''], alternative_pd_address_id:[''],
alternative_pincode_others: [AddressDetails.alternative_pincode_others, Validators.compose([Validators.minLength(6), Validators.maxLength(6)])], alternative_pincode_others: [AddressDetails.alternative_pincode_others, Validators.compose([Validators.minLength(6), Validators.maxLength(6)])],
reason_for_alternative_address: [AddressDetails.reason_for_alternative_address, Validators.compose([Validators.required])], reason_for_alternative_address: [AddressDetails.reason_for_alternative_address],
}); });
} }
else if (AddressDetails == null) { else if (AddressDetails == null) {
return this.fb.group({ return this.fb.group({
alternative_address: ['', Validators.compose([Validators.required])], alternative_address: [''],
alternative_state: [''], alternative_state: [''],
alternative_city: [''], alternative_city: [''],
alternative_pincode: [''], alternative_pincode: [''],
@ -320,9 +341,11 @@ export class AddressComponent implements OnInit {
pinSearch:[''], pinSearch:[''],
alternative_pd_address_id: [''], alternative_pd_address_id: [''],
alternative_pincode_others:['', Validators.compose([Validators.minLength(6), Validators.maxLength(6)])], alternative_pincode_others:['', Validators.compose([Validators.minLength(6), Validators.maxLength(6)])],
reason_for_alternative_address: ['', Validators.compose([Validators.required])], reason_for_alternative_address: [''],
}); });
} }
} }
// addAddresses() { // addAddresses() {
@ -395,11 +418,17 @@ export class AddressComponent implements OnInit {
this.addressForm.addControl('alternative_addresses', this.fb.array([])); this.addressForm.addControl('alternative_addresses', this.fb.array([]));
const alternative_address_control = <FormArray>this.addressForm.controls['alternative_addresses']; const alternative_address_control = <FormArray>this.addressForm.controls['alternative_addresses'];
alternative_address_control.push(this.createAlternativeAddresses(null)); alternative_address_control.push(this.createAlternativeAddresses(null));
if(this.fk_pd_type != '2'){
alternative_address_control.at(0)['controls'].reason_for_alternative_address.setValidators(Validators.required);
alternative_address_control.at(0)['controls'].alternative_address.setValidators(Validators.required);
}
} }
else if (e === true) { else if (e === true) {
// console.log('alternativeAddress',e); // console.log('alternativeAddress',e);
this.addressForm.removeControl('alternative_addresses'); this.addressForm.removeControl('alternative_addresses');
} }
} }
// Add and Remove The SpecifyOthers Field // Add and Remove The SpecifyOthers Field
@ -831,6 +860,11 @@ export class AddressComponent implements OnInit {
} }
this.getCityAndPincodeDetails(datas.alternative_state, index, 2); this.getCityAndPincodeDetails(datas.alternative_state, index, 2);
alternative_address_control.push(this.createAlternativeAddresses(obj)); alternative_address_control.push(this.createAlternativeAddresses(obj));
if(this.fk_pd_type != '2'){
alternative_address_control.at(0)['controls'].reason_for_alternative_address.setValidators(Validators.required);
alternative_address_control.at(0)['controls'].alternative_address.setValidators(Validators.required);
}
this.setOthers(+datas.alternative_pincode, index, 2); this.setOthers(+datas.alternative_pincode, index, 2);
if(datas.alternative_pincode == 1) { if(datas.alternative_pincode == 1) {
let AltCtrl: any = alternative_address_control.controls[index]; let AltCtrl: any = alternative_address_control.controls[index];
@ -927,6 +961,11 @@ export class AddressComponent implements OnInit {
alternative_address_control.removeAt(0); alternative_address_control.removeAt(0);
} }
alternative_address_control.push(this.createAlternativeAddresses(obj)); alternative_address_control.push(this.createAlternativeAddresses(obj));
if(this.fk_pd_type != '2'){
alternative_address_control.at(0)['controls'].reason_for_alternative_address.setValidators(Validators.required);
alternative_address_control.at(0)['controls'].alternative_address.setValidators(Validators.required);
}
this.setOthers(+datas.alternative_pincode, index, 2); this.setOthers(+datas.alternative_pincode, index, 2);
if(datas.alternative_pincode == 1) { if(datas.alternative_pincode == 1) {
let AltCtrl: any = alternative_address_control.controls[index]; let AltCtrl: any = alternative_address_control.controls[index];

View File

@ -1603,12 +1603,12 @@
</mat-form-field> </mat-form-field>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
<mat-card [ngClass]="{'smartPd':fk_pd_type == '2'}"> <mat-card>
<mat-card-header> <mat-card-header [ngClass]="{'smartPd':fk_pd_type == '2'}">
<mat-card-title *ngIf="fk_pd_type != '3' || fk_pd_type == '2'">No of Employees Sighted By PD Officer During His Visit </mat-card-title> <mat-card-title *ngIf="fk_pd_type != '3' || fk_pd_type == '2'">No of Employees Sighted By PD Officer During His Visit </mat-card-title>
<mat-card-title *ngIf="fk_pd_type == '3'">Company Name Board </mat-card-title> <mat-card-title *ngIf="fk_pd_type == '3'">Company Name Board </mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content class="matcard"> <mat-card-content class="matcard" [ngClass]="{'smartPd':fk_pd_type == '2'}">
<mat-form-field *ngIf="fk_pd_type != '3'"> <mat-form-field *ngIf="fk_pd_type != '3'">
<input matInput placeholder="Total" formControlName="officer_total"> <input matInput placeholder="Total" formControlName="officer_total">
<mat-error *ngIf="businessForm.controls['officer_total'].hasError('required')">Total Required</mat-error> <mat-error *ngIf="businessForm.controls['officer_total'].hasError('required')">Total Required</mat-error>

View File

@ -133,6 +133,8 @@ pdf(fileURL){
this.getMasterDetails('RELATIONWITHBUSINESS',1); this.getMasterDetails('RELATIONWITHBUSINESS',1);
this.getMasterDetails('FREQUENCY',2); this.getMasterDetails('FREQUENCY',2);
} }
// load form data // load form data
@ -362,17 +364,20 @@ pdf(fileURL){
Ncnt++; Ncnt++;
} }
} }
if(this.fk_pd_type != '2'){
this._neighbourhoodForm.controls.neighbourhood_status.setValidators([Validators.required]); this._neighbourhoodForm.controls.neighbourhood_status.setValidators([Validators.required]);
this._neighbourhoodForm.controls.neighbourhood_status.updateValueAndValidity(); this._neighbourhoodForm.controls.neighbourhood_status.updateValueAndValidity();
if(this._neighbourhoodForm.controls.neighbourhood_status.value != 'Positive'){
this._neighbourhoodForm.controls.neighbour_reference_remark.setValidators([Validators.required]);
this._neighbourhoodForm.controls.neighbour_reference_remark.updateValueAndValidity(); if(this._neighbourhoodForm.controls.neighbourhood_status.value != 'Positive'){
} this._neighbourhoodForm.controls.neighbour_reference_remark.setValidators([Validators.required]);
else{ this._neighbourhoodForm.controls.neighbour_reference_remark.updateValueAndValidity();
this._neighbourhoodForm.controls.neighbour_reference_remark.clearValidators(); }
this._neighbourhoodForm.controls.neighbour_reference_remark.updateValueAndValidity(); else{
} this._neighbourhoodForm.controls.neighbour_reference_remark.clearValidators();
this._neighbourhoodForm.controls.neighbour_reference_remark.updateValueAndValidity();
}
}
// } // }
// if(formData.check_type==1){ // if(formData.check_type==1){

View File

@ -261,7 +261,7 @@ export class QueriesDocsComponent implements OnInit {
let control:any=<FormArray>this.docsCollectedForm.controls['docs_to_be_sighted'] let control:any=<FormArray>this.docsCollectedForm.controls['docs_to_be_sighted']
this.docs_array_value.forEach((data,index)=>{ this.docs_array_value.forEach((data,index)=>{
control.push(this.createDocsArray(data)) control.push(this.createDocsArray(data))
control.controls[index].addControl(data.pd_doc_to_be_collect_id,new FormControl('',Validators.required)) control.controls[index].addControl(data.pd_doc_to_be_collect_id,new FormControl('',this.fk_pd_type != '2' ? Validators.required : []))
}) })
} }
} }
@ -415,14 +415,14 @@ export class QueriesDocsComponent implements OnInit {
if(value == 'yes'){ if(value == 'yes'){
// this.camera_btn[index]=true // this.camera_btn[index]=true
control.controls[index].removeControl('reason') control.controls[index].removeControl('reason')
control.controls[index].addControl('img',new FormControl('',Validators.required)) control.controls[index].addControl('img',new FormControl(''))
// control.controls[index].addControl('is_new',new FormControl('',Validators.required)) // control.controls[index].addControl('is_new',new FormControl('',Validators.required))
} }
else if(value == 'no'){ else if(value == 'no'){
// this.camera_btn[index]=false // this.camera_btn[index]=false
control.controls[index].removeControl('img') control.controls[index].removeControl('img')
control.controls[index].removeControl('is_new') control.controls[index].removeControl('is_new')
control.controls[index].addControl('reason',new FormControl('',Validators.required)); control.controls[index].addControl('reason',new FormControl('',this.fk_pd_type != '2' ? Validators.required : []));
} }
} }