Fairoj : Smc credit pd borrower section question not displayed issue fixed

This commit is contained in:
venbatechnologies@gmail.com 2021-05-24 16:33:39 +05:30
parent deb7beaa94
commit 69b96f4e5d
4 changed files with 42 additions and 12 deletions

View File

@ -16,6 +16,7 @@ export class DynamicFormComponent implements OnInit {
@Input() questions_JSON:any;
@Input() json_answers:any;
step: number=0;
isDefaultGenerated:boolean = false
step_child:number = 0
@ViewChild('mapanel') matExpansionPanel:MatExpansionPanel
@ViewChild('accordion') Accordion: MatAccordion
@ -31,7 +32,8 @@ export class DynamicFormComponent implements OnInit {
this.generateGroupControls();
}
generateGroupControls() {
if(this.json_answers && this.json_answers != null ){
if(this.json_answers && this.json_answers != null){
this.isDefaultGenerated = true;
this.questions_JSON.questions.forEach(parent_ques=>{
// debugger;

View File

@ -5,6 +5,7 @@ import { startWith, map } from 'rxjs/operators';
import { Observable, ReplaySubject } from 'rxjs';
import { MatDialog } from '@angular/material';
import { AnswerOptionCreateDialogComponent } from '../../answer-option-create-dialog/answer-option-create-dialog.component';
import { LoaderService } from 'app/shared/loaderService/loader.service';
@Component({
selector: 'app-dynamic-question-template',
@ -27,7 +28,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
autoCompleteAns:Observable<string[]>
public commonFilterCtrl:FormControl = new FormControl();
public ngxFilteredValue:ReplaySubject<any> = new ReplaySubject<any>(1);
constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog) { }
constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog, private loaderService:LoaderService) { }
ngOnInit() {
this.parent_ques = this.currFormArrayObj
@ -50,7 +51,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
if(this.json_answers!=null && this.json_answers != undefined && this.json_answers && !this.group_key) {
this.formGroupN.get(this.parent_ques.question_key).patchValue((this.json_answers[this.parent_ques.question_key] || ''))
this.onChangeProperty({value:this.json_answers[this.parent_ques.question_key]},this.parent_ques,'')
this.onChangeProperty({value:this.json_answers[this.parent_ques.question_key]},this.parent_ques,'','','','TS')
}
else if(this.json_answers!=null && this.json_answers != undefined && this.json_answers){
// this.formGroupN.patchValue((this.json_answers[this.group_key] || ''))
@ -74,7 +75,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
if(this.whole_form.get(this.group_key) && this.whole_json.length > 0) {
let curr_obj=this.whole_json.filter(vl=>vl.question_key == vv)[0]
this.onChangeProperty({value:value[vv]},curr_obj,'')
this.onChangeProperty({value:value[vv]},curr_obj,'','','','TS')
}
}
@ -98,7 +99,12 @@ export class DynamicQuestionTemplateComponent implements OnInit {
// setTimeout(()=>{
// this.json_answers = null
// },700)
this.quesService.formanswers=null;
// if(this.json_answers == )
// console.log("KEY TO BE FIND",this.json_index,this.whole_json)
setTimeout(() => {
// this.quesService.formanswers=null;
this.loaderService.closeMatSpinnerDialog();
},0)
}
// console.log(this.parent_ques,this.formGroupN,this.whole_json ,this.json_answers);
@ -169,7 +175,12 @@ export class DynamicQuestionTemplateComponent implements OnInit {
control.removeAt(i);
}
}
onChangeProperty(event,sec_control,question_key,options?,sec_index?){
onChangeProperty(event,sec_control,question_key,options?,sec_index?,from?){
console.log(from,"sadf")
if(!from && from != 'TS' && this.quesService.formanswers != null) {
console.log("Value changes",from);
this.quesService.formanswers = null
}
// this.fileredSearchValue=[]
@ -325,12 +336,12 @@ export class DynamicQuestionTemplateComponent implements OnInit {
// for calculation field from multiple arr values
if(onChangeProperty.purpose == 'answer_value_arr') {
let index = JSON.parse(JSON.stringify(this.json_index))
this.setModifiedValuetoControl_frommultiple(onChangeProperty,this.whole_form.get(this.group_key),index)
this.setModifiedValuetoControl_frommultiple(onChangeProperty,this.whole_form.get(this.group_key),index,sec_control)
}
})
}
}
setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index ?) {
setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index ?,sec_control?) {
if(curr_obj && curr_obj.value_keys.length > 0 && curr_obj.arr_include.length > 0 ) {
let expression_value=curr_obj.expression
@ -360,12 +371,20 @@ export class DynamicQuestionTemplateComponent implements OnInit {
let control_value = formArray.getRawValue()[value_index] ? formArray.getRawValue()[value_index][value] : ''
if(control_value) {
if(sec_control.type == '1' && sec_control.field_type == 'num' || sec_control.field_type == 'numtoword') {
let val = Number(control_value)
if(val == undefined || isNaN(val)) {
control_value = 0
}
}
expression_value = expression_value.split(value+'['+index_str+']').join(control_value)
}
else{
if(formArray.value.length > curr_index+1) {
this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1)
this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1,sec_control)
}
return
@ -373,6 +392,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
}
}
if(expression_value) {
let calc_exp=eval(expression_value)
if(calc_exp){
@ -383,7 +403,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
formArray.controls[curr_index].controls[curr_obj.insert_control].setValue(calc_exp)
if(formArray.value.length > curr_index+1) {
this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1)
this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1,sec_control)
}
}
}

View File

@ -12,7 +12,8 @@
</h2>
<!-- <form [formGroup]="docsCollectedForm"> -->
<mat-dialog-content style="border-bottom: 2px solid #e2412f8f;" >
<h5 style="text-align: center;" *ngIf="questions_JSON.questions.length == 0">No Templates Found</h5>
<h5 style="text-align: center;" *ngIf="questions_JSON.questions.length == 0 && !is_loading">No Templates Found</h5>
<h5 style="text-align: center;" *ngIf="questions_JSON.questions.length == 0 && is_loading">Loading...</h5>
<mat-card *ngIf="questions_JSON.questions.length > 0">
<!-- <mat-card-header>
<mat-card-title>

View File

@ -31,6 +31,7 @@ export class FormComponent implements OnInit {
commonFormGroup:FormGroup;
form_answers: any;
@ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent
is_loading: boolean = false;
constructor(notifier: NotifierService,
private fb: FormBuilder,
private route: ActivatedRoute,
@ -64,6 +65,7 @@ export class FormComponent implements OnInit {
ngOnInit() {
//alert(this.formanswers)
//alert(this.quesService.formanswers);
this.loadTemplate()
console.log("answered",this.pd_all_details.is_answered)
if(this.pd_all_details.is_answered == '1') {
this.getSectionData()
@ -71,9 +73,9 @@ export class FormComponent implements OnInit {
else{
this.getExcelData();
}
this.loadTemplate()
}
loadTemplate() {
this.is_loading = true
// let localId = this.getLocalFormId()
// console.log("d",this.pd_all_details.form_id,Number(this.pd_all_details.form_id))
// this.pdTriggerService.loadTemplate(Number(this.pd_all_details.form_id)).subscribe(result=>{
@ -122,6 +124,9 @@ export class FormComponent implements OnInit {
}
})
}
this.is_loading = false
},err => {
this.is_loading = false
})
}
getSectionData() {
@ -134,6 +139,7 @@ export class FormComponent implements OnInit {
formValues = JSON.parse(records.json)
// console.log(this.form)
this.quesService.formanswers= formValues
this.loaderService.showMatSpinnerDialog("")
// setTimeout(()=>{
// this.quesService.formanswers = null
// },2000)
@ -169,6 +175,7 @@ export class FormComponent implements OnInit {
this.commonFormGroup.patchValue(formValues)
}
else {
this.loaderService.showMatSpinnerDialog("")
this.quesService.formanswers= formValues
// setTimeout(()=>{
// this.quesService.formanswers = null