Fairoj : Smc credit pd borrower section question not displayed issue fixed
This commit is contained in:
parent
deb7beaa94
commit
69b96f4e5d
@ -16,6 +16,7 @@ export class DynamicFormComponent implements OnInit {
|
|||||||
@Input() questions_JSON:any;
|
@Input() questions_JSON:any;
|
||||||
@Input() json_answers:any;
|
@Input() json_answers:any;
|
||||||
step: number=0;
|
step: number=0;
|
||||||
|
isDefaultGenerated:boolean = false
|
||||||
step_child:number = 0
|
step_child:number = 0
|
||||||
@ViewChild('mapanel') matExpansionPanel:MatExpansionPanel
|
@ViewChild('mapanel') matExpansionPanel:MatExpansionPanel
|
||||||
@ViewChild('accordion') Accordion: MatAccordion
|
@ViewChild('accordion') Accordion: MatAccordion
|
||||||
@ -31,7 +32,8 @@ export class DynamicFormComponent implements OnInit {
|
|||||||
this.generateGroupControls();
|
this.generateGroupControls();
|
||||||
}
|
}
|
||||||
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=>{
|
this.questions_JSON.questions.forEach(parent_ques=>{
|
||||||
|
|
||||||
// debugger;
|
// debugger;
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { startWith, map } from 'rxjs/operators';
|
|||||||
import { Observable, ReplaySubject } from 'rxjs';
|
import { Observable, ReplaySubject } from 'rxjs';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { AnswerOptionCreateDialogComponent } from '../../answer-option-create-dialog/answer-option-create-dialog.component';
|
import { AnswerOptionCreateDialogComponent } from '../../answer-option-create-dialog/answer-option-create-dialog.component';
|
||||||
|
import { LoaderService } from 'app/shared/loaderService/loader.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dynamic-question-template',
|
selector: 'app-dynamic-question-template',
|
||||||
@ -27,7 +28,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
autoCompleteAns:Observable<string[]>
|
autoCompleteAns:Observable<string[]>
|
||||||
public commonFilterCtrl:FormControl = new FormControl();
|
public commonFilterCtrl:FormControl = new FormControl();
|
||||||
public ngxFilteredValue:ReplaySubject<any> = new ReplaySubject<any>(1);
|
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() {
|
ngOnInit() {
|
||||||
this.parent_ques = this.currFormArrayObj
|
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) {
|
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.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){
|
else if(this.json_answers!=null && this.json_answers != undefined && this.json_answers){
|
||||||
// this.formGroupN.patchValue((this.json_answers[this.group_key] || ''))
|
// 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) {
|
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]
|
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(()=>{
|
// setTimeout(()=>{
|
||||||
// this.json_answers = null
|
// this.json_answers = null
|
||||||
// },700)
|
// },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);
|
// 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);
|
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=[]
|
// this.fileredSearchValue=[]
|
||||||
|
|
||||||
@ -325,12 +336,12 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
// for calculation field from multiple arr values
|
// for calculation field from multiple arr values
|
||||||
if(onChangeProperty.purpose == 'answer_value_arr') {
|
if(onChangeProperty.purpose == 'answer_value_arr') {
|
||||||
let index = JSON.parse(JSON.stringify(this.json_index))
|
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 ) {
|
if(curr_obj && curr_obj.value_keys.length > 0 && curr_obj.arr_include.length > 0 ) {
|
||||||
let expression_value=curr_obj.expression
|
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] : ''
|
let control_value = formArray.getRawValue()[value_index] ? formArray.getRawValue()[value_index][value] : ''
|
||||||
if(control_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)
|
expression_value = expression_value.split(value+'['+index_str+']').join(control_value)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(formArray.value.length > curr_index+1) {
|
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
|
return
|
||||||
@ -373,6 +392,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(expression_value) {
|
if(expression_value) {
|
||||||
|
|
||||||
let calc_exp=eval(expression_value)
|
let calc_exp=eval(expression_value)
|
||||||
|
|
||||||
if(calc_exp){
|
if(calc_exp){
|
||||||
@ -383,7 +403,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
formArray.controls[curr_index].controls[curr_obj.insert_control].setValue(calc_exp)
|
formArray.controls[curr_index].controls[curr_obj.insert_control].setValue(calc_exp)
|
||||||
if(formArray.value.length > curr_index+1) {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,8 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<!-- <form [formGroup]="docsCollectedForm"> -->
|
<!-- <form [formGroup]="docsCollectedForm"> -->
|
||||||
<mat-dialog-content style="border-bottom: 2px solid #e2412f8f;" >
|
<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 *ngIf="questions_JSON.questions.length > 0">
|
||||||
<!-- <mat-card-header>
|
<!-- <mat-card-header>
|
||||||
<mat-card-title>
|
<mat-card-title>
|
||||||
|
|||||||
@ -31,6 +31,7 @@ export class FormComponent implements OnInit {
|
|||||||
commonFormGroup:FormGroup;
|
commonFormGroup:FormGroup;
|
||||||
form_answers: any;
|
form_answers: any;
|
||||||
@ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent
|
@ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent
|
||||||
|
is_loading: boolean = false;
|
||||||
constructor(notifier: NotifierService,
|
constructor(notifier: NotifierService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -64,6 +65,7 @@ export class FormComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
//alert(this.formanswers)
|
//alert(this.formanswers)
|
||||||
//alert(this.quesService.formanswers);
|
//alert(this.quesService.formanswers);
|
||||||
|
this.loadTemplate()
|
||||||
console.log("answered",this.pd_all_details.is_answered)
|
console.log("answered",this.pd_all_details.is_answered)
|
||||||
if(this.pd_all_details.is_answered == '1') {
|
if(this.pd_all_details.is_answered == '1') {
|
||||||
this.getSectionData()
|
this.getSectionData()
|
||||||
@ -71,9 +73,9 @@ export class FormComponent implements OnInit {
|
|||||||
else{
|
else{
|
||||||
this.getExcelData();
|
this.getExcelData();
|
||||||
}
|
}
|
||||||
this.loadTemplate()
|
|
||||||
}
|
}
|
||||||
loadTemplate() {
|
loadTemplate() {
|
||||||
|
this.is_loading = true
|
||||||
// let localId = this.getLocalFormId()
|
// let localId = this.getLocalFormId()
|
||||||
// console.log("d",this.pd_all_details.form_id,Number(this.pd_all_details.form_id))
|
// 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=>{
|
// 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() {
|
getSectionData() {
|
||||||
@ -134,6 +139,7 @@ export class FormComponent implements OnInit {
|
|||||||
formValues = JSON.parse(records.json)
|
formValues = JSON.parse(records.json)
|
||||||
// console.log(this.form)
|
// console.log(this.form)
|
||||||
this.quesService.formanswers= formValues
|
this.quesService.formanswers= formValues
|
||||||
|
this.loaderService.showMatSpinnerDialog("")
|
||||||
// setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
// this.quesService.formanswers = null
|
// this.quesService.formanswers = null
|
||||||
// },2000)
|
// },2000)
|
||||||
@ -169,6 +175,7 @@ export class FormComponent implements OnInit {
|
|||||||
this.commonFormGroup.patchValue(formValues)
|
this.commonFormGroup.patchValue(formValues)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
this.loaderService.showMatSpinnerDialog("")
|
||||||
this.quesService.formanswers= formValues
|
this.quesService.formanswers= formValues
|
||||||
// setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
// this.quesService.formanswers = null
|
// this.quesService.formanswers = null
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user