From af2985ac13899ea4911282d1e07c43cadee0ff45 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 15 Apr 2021 13:06:21 +0530 Subject: [PATCH] Fairoj : SMC CREDIT pd consoles are removed --- .../ques-template/ques-template.component.ts | 65 +++-------- .../ques-template/ques-template.service.ts | 48 ++++---- .../dynamic-form/dynamic-form.component.ts | 41 ++++--- .../dynamic-question-template.component.ts | 105 +++++++++--------- .../ques-form/ques-form.service.ts | 51 +++++---- .../start-pd/forms/form/form.component.ts | 17 +-- 6 files changed, 147 insertions(+), 180 deletions(-) diff --git a/ng6-seed/src/app/lender-credit-pd/ques-template/ques-template.component.ts b/ng6-seed/src/app/lender-credit-pd/ques-template/ques-template.component.ts index 22f49a8..bfcdd74 100644 --- a/ng6-seed/src/app/lender-credit-pd/ques-template/ques-template.component.ts +++ b/ng6-seed/src/app/lender-credit-pd/ques-template/ques-template.component.ts @@ -49,11 +49,9 @@ export class QuesTemplateComponent implements OnInit { ngOnInit() { this.sales_pd_section_to_fetch = localStorage.getItem('commonSettings') this.sales_pd_section_to_fetch = JSON.parse(this.sales_pd_section_to_fetch).sales_pd_section_to_fetch - // console.log(this.sales_pd_section_to_fetch,Object.keys(this.sales_pd_section_to_fetch),Object['value'](this.sales_pd_section_to_fetch)); // this.sales_pd_section_to_fetch= Object. // this.sales_pd_section_to_fetch = Object.keys(this.sales_pd_section_to_fetch).map(key =>{let temp=[]; temp.push(this.sales_pd_section_to_fetch[key]); return temp}); // this.sales_pd_section_to_fetch = values.join(","); -console.log(this.sales_pd_section_to_fetch); // debugger; } ngOnChanges(){ @@ -77,7 +75,7 @@ console.log(this.sales_pd_section_to_fetch); } this.quesAnsForm=this.questionService.assignFormControl_array(this.quesAnsForm,this.local_ques_JSON.questions) - console.log(this.quesAnsForm); + // this.salesPDProvider.getData_fromLocal('sec'+this.local_ques_JSON.section_id).then(resultData=>{ // this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{ @@ -106,7 +104,6 @@ console.log(this.sales_pd_section_to_fetch); this.sales_pd_id = this.curr_pd_info.fk_sales_pd_id if(this.curr_pd_info.smc_credit_pd && this.curr_pd_info.smc_credit_pd != null) { // this.getSalesPDSectionFromApi(this.sales_pd_id); - // console.log(this.curr_pd_info.saved_sections ); // debugger; if(this.curr_pd_info.saved_sections) { this.proceedToGetDataFromSmcCredit() @@ -190,7 +187,6 @@ else { this.raw_data_Section=response['records'][0] this.original_result_data=response['records'][0].section_data this.original_result_data=JSON.parse(this.original_result_data); - console.log(this.original_result_data); // debugger; // this.original_result_data.questions=this.original_result_data.questions.filter(val=>val.question_key == 'selfie_with_person_met') this.checkGroupandPatchValues() @@ -275,7 +271,6 @@ else { // ]}` // img_values = JSON.parse(img_values) let createPhotoStructure:any=this.quesAnsForm.value.questions - // console.log("update Image fun",this.quesAnsForm.value,img_values,this.quesAnsForm.get('questions')['controls'][0],this.photoStructure) if(img_values.img_data.length > 0) { // img_values.img_data.forEach(img_obj=>{ for(let img_obj of img_values.img_data) { @@ -283,7 +278,6 @@ else { let findRootIndex = createPhotoStructure.findIndex(val=>val.question_key == img_obj.img_key) let current_control_obj:any =[] current_control_obj = createPhotoStructure[findRootIndex] - console.log(createPhotoStructure[findRootIndex]) if(img_obj.is_multiple != '1'){ current_control_obj.answer_value = img_obj.img_url } @@ -292,7 +286,6 @@ else { // img_obj.img_data.forEach(multi_obj=>{ for(let multi_obj of img_obj.img_data) { if(multi_obj) { - // console.log(multi_obj) let temp_obj:any = [] temp_obj.length = 0; @@ -334,7 +327,6 @@ else { } } proceedonChangeProperty(local_value_obj?){ - console.log("On Change Property",this.quesAnsForm.value.questions); this.quesAnsForm.controls.questions['controls'].forEach((val,p_i)=>{ @@ -350,7 +342,6 @@ else { } // JSON QUESTION CHANGE FOR SINGLE - console.log("key",p_i,this.quesAnsForm.value) if (this.original_result_data.questions[p_i] != undefined) { if (this.quesAnsForm.value.questions[p_i].is_repeatable != 1 && this.quesAnsForm.value.questions[p_i].question_key !== this.original_result_data.questions[p_i].question_key) { // ADDING THE QUESTION TO FETCHED DATA ARRAY @@ -361,9 +352,9 @@ else { // REMOVING THE QUESTION TO FETCHED DATA ARRAY else { - console.log("Else part>>", this.quesAnsForm.value.questions[p_i].question_key, this.original_result_data.questions[p_i].question_key, val) + this.original_result_data.questions.splice(p_i, 1) - console.log("after", this.original_result_data.questions, this.quesAnsForm.value.questions) + } // --- END OF REMOVING QUESTION --- } @@ -403,7 +394,7 @@ else { // setTimeout(()=>{ let form_c=single_ques let form_control=this.quesAnsForm.value.questions[p_i].questions_group[g_i].questions[s_i] - console.log(this.original_result_data.questions[p_i],p_i,this.original_result_data) + let local__g_data=this.original_result_data.questions[p_i].questions_group[g_i].questions if(local__g_data[s_i] != undefined){ if(form_control.question_key != local__g_data[s_i].question_key){ @@ -449,7 +440,6 @@ this.proceedonChangeProperty(modified) this.quesAnsForm.get('questions').patchValue(this.original_result_data.questions); - console.log(this.quesAnsForm) } setStep(index: number) { this.step = index; @@ -466,14 +456,12 @@ this.proceedonChangeProperty(modified) if (event.type === HttpEventType.UploadProgress) { // This is an upload progress event. Compute and show the % done: const percentDone = Math.round(100 * event.loaded / event.total); - console.log(`File is ${percentDone}% uploaded.`); } else if (event instanceof HttpResponse) { - console.log('File is completely uploaded!'); } } addData(group_index, parent_index, data, event, options?: any, single_ques?) { - console.clear(); + data=data.filter(group_indi=>!group_indi.hasOwnProperty('additional_field') && group_indi.additional_field != 1 ) if (options == 'camera') { @@ -485,7 +473,6 @@ this.proceedonChangeProperty(modified) // this.cameraProvider.addWatermarks(res).then(watermarkedImage => { // single_ques.controls.answer_value.setValue(watermarkedImage) // // this.sales_pd_id = Number(this.sales_pd_id) - // // console.log(this.sales_pd_id) // // if(this.networkDetection.getCurrentNetworkStatus() == ConnectionStatus.online && (typeof(this.sales_pd_id) == 'string' ? !this.sales_pd_id.includes('local') : true) ) { // single_ques.controls.is_image_status.setValue(true) @@ -537,7 +524,6 @@ this.proceedonChangeProperty(modified) // single_ques.controls.is_loader.setValue(false); // single_ques.controls.is_saved.setValue(false); // this.salesPDProvider.clear_local_key('sec'+storage_param.section_id) - // console.log("error",err); // this.toastProvider.lenderappmessage('Network Error') // this.emittedFormGroup = this.quesAnsForm.getRawValue() // this.imageUploadCheck.emit(this.emittedFormGroup); @@ -553,15 +539,15 @@ this.proceedonChangeProperty(modified) // }) // } // }, error => { - // console.log("Camera Error ", JSON.stringify(error)); + // // }) // single_ques.controls.answer_value.setValue(base64) // console.clear(); -// console.log(single_ques); +// // single_ques.controls.is_image_status.setValue(true); // single_ques.controls.is_loader.setValue(true); // single_ques.controls.is_saved.setValue(false); -// console.log(single_ques); +// // let control: any = parent_index['controls'].questions_group as FormArray // control.push(this._fb.group({ 'questions': this._fb.array([]) })) // let sub_childControl: any = control.controls[group_index + 1].get('questions') as FormArray @@ -711,7 +697,6 @@ this.proceedonChangeProperty(modified) this.step=control.length-1 } onChange_checkbox(event,sec_control){ - console.log(event,sec_control) const control=sec_control.get('answer_value') as FormArray if(event.checked) { @@ -724,7 +709,6 @@ this.proceedonChangeProperty(modified) creatSubField(sec_control,choosen_value){ let curr_answer:any=[] - console.log(sec_control,choosen_value) if(typeof(choosen_value) == 'object'){ curr_answer =sec_control.value.answers.filter(val=>choosen_value.filter(arr_val=>arr_val == val.answer_id).length > 0 && val.hasOwnProperty('subfield_key') && val.subfield_key != '' && val.subfield_caption != '') } @@ -733,7 +717,6 @@ this.proceedonChangeProperty(modified) } if(curr_answer.length >0){ curr_answer=curr_answer[0] - console.log(curr_answer) sec_control.addControl('subfield_key',new FormControl(curr_answer.subfield_key)) sec_control.addControl('subfield_caption',new FormControl(curr_answer.subfield_caption)) sec_control.addControl('subfield_value',new FormControl('')) @@ -813,7 +796,6 @@ this.proceedonChangeProperty(modified) // onChangeProperties_value.push(JSON.parse(new_name)) onChangeProperties_value.forEach(onChangeProperty=>{ - console.log("api",onChangeProperty) if(onChangeProperty.purpose == 'api'){ if(onChangeProperty.api == 'getListOfStatesAndCities'){ this.salesPDProvider.getCityPincode(event.value).subscribe(res=>{ @@ -883,7 +865,6 @@ this.proceedonChangeProperty(modified) } } creteNewField(form_control_obj_raw,group_ques,sec_control,sec_index,purpose?){ - console.log(group_ques,form_control_obj_raw,sec_index); if(form_control_obj_raw.form_controls.length > 0){ form_control_obj_raw.form_controls.forEach(form_control_obj=>{ if(form_control_obj.value_keys != null && form_control_obj.value_keys.length > 0 ){ @@ -915,7 +896,6 @@ this.proceedonChangeProperty(modified) question_index_after= arr.indexOf(val) } }) - console.log(question_index_after,sec_index); this.createControl(form_control_obj,group_ques,question_index_after,1) //FOR ADD CONTOL } } @@ -927,7 +907,6 @@ this.proceedonChangeProperty(modified) } } createControl(form_control_obj,group_ques,question_index_after,options){ - console.log(form_control_obj,group_ques,question_index_after) let ques_control=group_ques.get('questions') as FormArray let inserted_control_obj=form_control_obj inserted_control_obj.questions.sort() @@ -956,7 +935,6 @@ this.proceedonChangeProperty(modified) if(validation_obj_raw.validations.length > 0){ validation_obj_raw.validations.forEach(validation_obj=>{ - console.log("sing",validation_obj) //FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION if(validation_obj.hasOwnProperty('value_keys')){ @@ -983,7 +961,6 @@ this.proceedonChangeProperty(modified) else{ validation_obj.isactive='1' let validator_single=this.questionService.setValueForValidator(validation_obj) - console.log(validator_single) // // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS this.proceedValidationSet(validation_obj,group_ques,sec_index,validator_single) } @@ -997,7 +974,7 @@ this.proceedonChangeProperty(modified) validator_value_obj=group_ques.value.questions.filter(val=>val.question_key == validation_obj.value)[0] - console.log(validator_value_obj) + validation_obj.validator=validator_value_obj.answer_value @@ -1024,7 +1001,6 @@ this.proceedonChangeProperty(modified) proceedValidationSet(validation_obj,group_ques,sec_index,validator_single?){ let ques_control; if(validation_obj.validation_to == null){ - console.log("entered",group_ques,sec_index); ques_control=group_ques.controls.questions['controls'][sec_index] @@ -1050,7 +1026,7 @@ this.proceedonChangeProperty(modified) })[0] // let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name) // updateMsg.push(validation_obj) - console.log(other_control) + // other_control.controls.answer_value.setValidators(validator_single) // if(validation_obj.isactive == '1'){ // other_control.controls.answer_value.setValidators(validator_single) @@ -1064,12 +1040,12 @@ this.proceedonChangeProperty(modified) // other_control.controls.validations.setValue(updateMsg); // validation_obj.validator=validator_single let new_validations_obj=this.updateValidationMsg(other_control,validation_obj) - console.log("new validations obj",new_validations_obj,other_control) + this.questionService.settingArrayofValidators({validations:new_validations_obj},other_control,'') } } updateValidationMsg(ques_control,validation_obj){ - console.log("updae msg",ques_control,validation_obj); + let updateMsg=ques_control.value.validations.filter(val=>val.name != validation_obj.name) updateMsg.push(validation_obj) ques_control.controls.validations.setValue(updateMsg); @@ -1127,12 +1103,12 @@ this.proceedonChangeProperty(modified) // }) // }) } - // console.log(return_val.filter(val=>val == false).length > 0) + if(return_val.filter(val=>val == false).length > 0){ break; } } - console.log(return_val) + if(return_val.length > 0){ if(return_val.filter(res=>res == false).length > 0){ send_val = false @@ -1187,8 +1163,7 @@ this.proceedonChangeProperty(modified) // return sum_val }());` - let val= eval(submitProperty.expression); - console.log(val) + let val= eval(submitProperty.expression) return val } @@ -1236,7 +1211,7 @@ this.proceedonChangeProperty(modified) } public findInvalidControls() { const controls = this.quesAnsForm.get('questions')['controls']; - console.log(controls) + for (const name in controls) { if (controls[name].invalid) { let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); @@ -1307,7 +1282,6 @@ this.proceedonChangeProperty(modified) // } // //END OF IMAGE SAVE REQUEST CHECK let checkProperty=this.onSubmitProperty() - console.log("check rp",checkProperty) if(checkProperty == false){ return; } @@ -1328,7 +1302,6 @@ this.proceedonChangeProperty(modified) }) return; } - console.log(this.quesAnsForm.dirty) // if(this.quesAnsForm.dirty){ if(this.local_ques_JSON.section_id == 1 || this.submit_btn){ let result = this.curr_pd_info.smc_credit_pd @@ -1370,7 +1343,6 @@ this.proceedonChangeProperty(modified) params.questions=this.questions_JSON.questions params.is_completed=false setTimeout(()=>{ - console.log('emiiter') this.emitter.emit(params) }) },1200) @@ -1394,7 +1366,6 @@ this.proceedonChangeProperty(modified) }); dialogRef.afterClosed().subscribe(result => { - console.log('The dialog was closed',result); if(result && result != 'cancel') { this.saveSalesPDAPI(section_data) } @@ -1432,7 +1403,7 @@ this.proceedonChangeProperty(modified) if(apiresult['records'] != true && typeof(apiresult['records']) != 'object'){ this.curr_pd_info.smc_credit_pd = String(apiresult['records']) this.curr_pd_info.rand_string= String(apiresult['rand_string']) - console.log("sdfffffffffffffff",this.curr_pd_info,this.salesPDProvider.curr_credit_pd_data) + // this.salesPDProvider.insertData_Replace('sales_pd_id_PRIMARYKEY',String(apiresult['records'])).then(local_result=>{ // this.salesPDProvider.insertData_Replace('sales_rand_string',String(apiresult['rand_string'])).then(()=>{ if(!this.submit_btn){ @@ -1553,7 +1524,7 @@ this.proceedonChangeProperty(modified) // SENDING SALES PD SECTION 9 STRUCTURE(photographs) ngOnDestroy(){ // console.clear() - console.log("dirty check",this.quesAnsForm.dirty) + if(this.local_ques_JSON.section_id == 9 && this.emittedFormGroup != null){ // FOR SENDING THE IMAGE SECTION (SECTION ID 9) JSON Structure let form_structure=this.quesAnsForm.getRawValue().questions diff --git a/ng6-seed/src/app/lender-credit-pd/services/ques-template/ques-template.service.ts b/ng6-seed/src/app/lender-credit-pd/services/ques-template/ques-template.service.ts index 426756b..979a9d7 100644 --- a/ng6-seed/src/app/lender-credit-pd/services/ques-template/ques-template.service.ts +++ b/ng6-seed/src/app/lender-credit-pd/services/ques-template/ques-template.service.ts @@ -17,11 +17,11 @@ export class QuesTemplateService { } // FOR CREATING A FORM CONTROL DYNAMICALLY assignFormControl_array(formgroup: FormGroup, ques_data: any) { - console.log(formgroup, ques_data) + this.curr_pd_info = this.salesPDProvider.curr_credit_pd_data const control: any = formgroup.get('questions') as FormArray ques_data.forEach((val, index) => { - console.log("quees", val) + if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { control.push(this._fb.group({ "is_repeatable": [val.is_repeatable || null], @@ -38,20 +38,20 @@ export class QuesTemplateService { let childControl: any = control.controls[index].get('questions_group') as FormArray childControl.push(this._fb.group({ 'questions': this._fb.array([]) })) - console.log("cc", childControl, control, index) + let sub_childControl: any = childControl.controls[0].get('questions') as FormArray val.question.forEach((group_indi, arr_index) => { // if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){ - console.log("api pro", val.api_properties) + // let param // val.api_properties.forEach(val=>param=val) - // console.log(param) + group_indi.raw_validations = group_indi.validations sub_childControl.push(this.createValue(group_indi)) this.addAdditionalControl(group_indi, sub_childControl, arr_index) // if(group_indi.type == '5'){ // sub_childControl.controls[arr_index].removeControl('answer_value'); - // console.log("loop",arr_index,sub_childControl); + // sub_childControl.controls[arr_index].addControl('answer_value',this._fb.array([])) // } // if(group_indi.type == '1'){ @@ -86,19 +86,19 @@ export class QuesTemplateService { // },500) - console.log("dd112", formgroup, childControl) + // let key_list=Object.keys(val) - // console.log(Object.keys(val)) + // key_list.forEach(key=>{ // childControl.controls // }) } else { - // console.log("con",control) + // let key_list=Object.keys(val) - // console.log(Object.keys(val)) + // let curr_object - // console.log("apikd",typeof(val.api_properties)) + // if(val.api_properties != null && typeof(val.api_properties) == 'object'){ val.raw_validations = val.validations control.push(this.createValue(val)) @@ -106,7 +106,7 @@ export class QuesTemplateService { this.addAdditionalControl(val, control, index) // if(val.type == '5'){ // control.controls[index].removeControl('answer_value'); - // console.log("loop",index,control); + // control.controls[index].addControl('answer_value',this._fb.array([])) // } // if(val.type == '1'){ @@ -117,7 +117,7 @@ export class QuesTemplateService { // } if (val.api_properties != null) { this.apiPropertiesCall(val).then(res => { - console.log("chekc", res) + if (res != false) { // val.answers=[] // val.answers=this.convertArrayNames(val.api_properties.fields,res) @@ -184,11 +184,11 @@ export class QuesTemplateService { return new Promise((resolve,reject)=>{ if(val.api_properties != null && typeof(val.api_properties) == 'object'){ let pd_info = this.curr_pd_info - console.log(pd_info) + let params = val.api_properties.params if(val.api_properties.hasOwnProperty('params_type') && val.api_properties.params_type == 'expression') { params = eval(val.api_properties.params) - console.log(params,this.curr_pd_info.smc_credit_pd) + // debugger; } this.salesPDProvider.api_post_method(val.api_properties.api,params,val.api_properties.api_method).subscribe(res=>{ @@ -197,7 +197,7 @@ export class QuesTemplateService { res=res['records'] } resolve(res) - console.log(res) + // val.answers=res } else{ @@ -243,7 +243,7 @@ export class QuesTemplateService { // user_det = JSON.parse(user_det); switch (value_obj.answer_value) { case 'CURRENT_USER': - console.log("current user", user_det) + return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name break; case "CURRENT_DESIGNATION": @@ -302,7 +302,7 @@ export class QuesTemplateService { // FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp, settingArrayofValidators(data,curr_control,curr_index){ - console.log("entered",data); + if(data.hasOwnProperty('validations') && data.validations.length > 0 ){ const validList :any= []; let validator_value @@ -313,7 +313,7 @@ export class QuesTemplateService { } else{ validator_value=this.setValueForValidator(valid) - console.log("cc",validator_value) + } validList.push(validator_value); @@ -326,12 +326,12 @@ export class QuesTemplateService { // let val1=`${val}` // console.log(typeof(eval(val))) // console.log(eval(val)) - console.log(validList) + // curr_control.controls[curr_index].controls.answer_value.setValidators(validList) curr_control.controls.answer_value.setValidators(validList) - console.log("ddvdeeqq",validList) + curr_control.controls.answer_value.updateValueAndValidity() - console.log("after setting validators",curr_control) + } } // END OF SETTINGARRAYOFVALIDATORS FUN @@ -365,7 +365,7 @@ export class QuesTemplateService { else{ fy.push({fy_year:year-2+'-'+(year-1),curr:year-1}) } - console.log(fy) + for(let i=0;i<=2;i++){ fy.push({fy_year:(fy[i].curr-2)+'-'+(fy[i].curr-1),curr:fy[i].curr-1}) } @@ -375,7 +375,7 @@ export class QuesTemplateService { // FOR CREATING THE CORRECT VALIDATION setValueForValidator(value_obj){ - console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator)) + let return_value if(value_obj != null && value_obj.hasOwnProperty('validator')){ switch(value_obj.name) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts index 17cc53f..798f51d 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-form/dynamic-form.component.ts @@ -24,7 +24,7 @@ export class DynamicFormComponent implements OnInit { ngOnInit() { // this.form_group_name=new FormGroup({questions:this._fb.array([])}) - console.log(this.questions_JSON,this.json_answers,this.questionService); + // console.log(this.questions_JSON,this.json_answers,this.questionService); this.form_group_name=this.questionService.assignFormControl_array(this.form_group_name,this.questions_JSON.questions) // debugger @@ -33,16 +33,16 @@ export class DynamicFormComponent implements OnInit { generateGroupControls() { if(this.json_answers && this.json_answers != null ){ this.questions_JSON.questions.forEach(parent_ques=>{ - console.log(parent_ques); + // debugger; // FOR ADDING THE GROUP QUES TO DISPLAY WITHOUT CONSIDERING INDEX 0 if(parent_ques.is_repeatable == '1'){ if(this.json_answers[parent_ques.group_key] && this.json_answers[parent_ques.group_key].length > this.form_group_name.value[parent_ques.group_key].length) { - console.log(this.json_answers[parent_ques.group_key]); + // this.json_answers[parent_ques.group_key].mobile_numbers= [{mobile_no:93299},{mobile_no:948392}] this.json_answers[parent_ques.group_key].forEach((group_ques,g_i)=>{ - console.log(parent_ques,g_i,group_ques) + // debugger; if(g_i != 0){ @@ -56,16 +56,16 @@ export class DynamicFormComponent implements OnInit { let keys= Object.keys(group_ques) keys.forEach((vv,key_index)=>{ if(typeof(group_ques[vv]) != 'string') { - console.log("Entered",group_ques[vv]); + if(group_ques[vv] && group_ques[vv].length > 0) { // group_ques[vv].forEach((child_val,child_index)=>{ if(child_index != 0) { - console.log(parent_ques,this.form_group_name.get(parent_ques.group_key)['controls'][g_i],parent_ques,vv,g_i) + let find_json = parent_ques.group_questions[g_i].filter(val=>val.hasOwnProperty('group_key') && val.group_key == vv) if(find_json.length > 0) { find_json = find_json[0] - console.log(find_json,child_index,g_i) + this.addSecondLevelChild(g_i,find_json,this.form_group_name.get(parent_ques.group_key)['controls'][g_i]) } @@ -81,7 +81,7 @@ export class DynamicFormComponent implements OnInit { } } ngOnChanges() { - console.log(this.questions_JSON,this.json_answers,this.questionService); + // console.log(this.questions_JSON,this.json_answers,this.questionService); // debugger // if(this.json_answers && this.json_answers != null ){ // this.questions_JSON.questions.forEach(parent_ques=>{ @@ -107,7 +107,7 @@ export class DynamicFormComponent implements OnInit { // } // this.form_group_name=new FormGroup({questions:this._fb.array([])}) - console.log(this.form_group_name.getRawValue()); + // this.form_group_name.valueChanges.subscribe(()=>{ // this.form_group_name.updateValueAndValidity(); // }) @@ -129,7 +129,7 @@ export class DynamicFormComponent implements OnInit { control_names[val.question_key] = '' } }) - console.log(control,json_obj.group_key,control_names,json_obj.question); + // debugger; json_obj.group_questions.push(json_obj.question); @@ -156,19 +156,18 @@ export class DynamicFormComponent implements OnInit { control.controls[control.length-1].updateValueAndValidity(); this.form_group_name.updateValueAndValidity(); this.step = control.length-1 - console.log(this.form_group_name.value); + // debugger; } // ADDING A CHILD REPEATABLE OBJ IN A EXISTING FORM ARRYA addSecondLevelChild(index,json_obj,parent_group) { - console.log(json_obj,parent_group) + let control_names:any= {} let control = parent_group.get(json_obj.group_key) as FormArray json_obj.question.map(val=>{ control_names[val.question_key] = '' }) - console.log(control,json_obj.group_key,control_names,json_obj.question); - // debugger; + json_obj.questions_level_two.push(json_obj.question); control.push(this._fb.group(control_names)) @@ -182,38 +181,38 @@ export class DynamicFormComponent implements OnInit { control.controls[control.length-1].updateValueAndValidity(); parent_group.updateValueAndValidity(); this.step_child = control.length-1 - console.log(this.form_group_name.value,this.questions_JSON); + // debugger; } // REMOVE OF CHILD REPEATABLE OBJ removeSecondLevelChild(index,json_obj,parent_group) { - console.log(json_obj) + // debugger; let control = parent_group.get(json_obj.group_key) control.removeAt(index) json_obj.questions_level_two.splice(index,1) this.step_child = control.length-1 - console.log(json_obj) + } removeData(index,json_obj) { - console.log(json_obj) + // debugger; let control = this.form_group_name.get(json_obj.group_key) as FormArray control.removeAt(index) json_obj.group_questions.splice(index,1) this.step = control.length-1 - console.log(json_obj) + } openMatExpansionPanel() { - console.log("opening expansion panek",this.matExpansionPanel) + if(this.matExpansionPanel!= undefined){ this.matExpansionPanel.open() } } openAllPanels(){ this.Accordion.openAll(); - console.log(this.Accordion); + return; } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts index f3ef598..eb59530 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.ts @@ -44,18 +44,17 @@ export class DynamicQuestionTemplateComponent implements OnInit { ngOnChanges() { this.parent_ques = this.currFormArrayObj if(this.json_answers!=null && this.json_answers != undefined && this.json_answers) { - // console.log("ddddddddddddddd",this.json_answers[this.parent_ques.question_key],this.parent_ques) + // setTimeout(()=>{ - console.clear() - console.log(this.json_answers,this.parent_ques.question_key) + // console.clear() + 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,'') - console } else if(this.json_answers!=null && this.json_answers != undefined && this.json_answers){ // this.formGroupN.patchValue((this.json_answers[this.group_key] || '')) - console.log(this.json_answers,this.whole_form.get(this.group_key)) + // debugger; this.whole_form.get(this.group_key).patchValue(this.json_answers) if(this.json_answers.length > 1) { @@ -66,18 +65,18 @@ export class DynamicQuestionTemplateComponent implements OnInit { let keys= Object.keys(value) keys.forEach(vv=>{ - console.log("ype of ",value[vv],typeof(value[vv]),this.whole_json) + // debugger; if(typeof(value[vv])== 'string') { - // console.log("ype of ",typeof(value[vv])) + - // console.log("ansssssssssssssssssssssssssssss",this.json_answers[vv],vv,this.whole_json.filter(vl=>vl.question_key == vv)) + 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,'') } - console.log("Repeatable ques",value,this.parent_ques.question_key) + } }) @@ -105,14 +104,14 @@ export class DynamicQuestionTemplateComponent implements OnInit { // debugger; if(this.parent_ques.type == '8') { - console.log("Initial",this.parent_ques.answers) + if(this.parent_ques.answers && this.parent_ques.answers.length > 0){ this.ngxFilteredValue.next(this.parent_ques.answers.slice()) // this.filterList() } else{ setTimeout(()=>{ - console.log("last",this.parent_ques.answers) + if(this.parent_ques.answers && this.parent_ques.answers.length > 0){ this.ngxFilteredValue.next(this.parent_ques.answers.slice()) // this.filterList() @@ -124,7 +123,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } filterList() { this.commonFilterCtrl.valueChanges.pipe().subscribe(()=>{ - console.log("valuechanges",this.parent_ques) + if(this.parent_ques.type == '8' && this.parent_ques.answers && this.parent_ques.answers.length > 0) { this.applyFilter(this.commonFilterCtrl.value,this.ngxFilteredValue,this.parent_ques.answers,'answer') } @@ -159,7 +158,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } onChange_checkbox(event,sec_control){ - console.log(event,sec_control) + const control=this.formGroupN.get(sec_control.question_key) as FormArray if(event.checked) { @@ -170,7 +169,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } onChangeProperty(event,sec_control,question_key,options?,sec_index?){ - console.log(sec_control); + // this.fileredSearchValue=[] if(sec_control && sec_control.answers!= null && sec_control.answers.length > 0){ @@ -238,7 +237,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { // onChangeProperties_value.push(JSON.parse(new_name)) onChangeProperties_value.forEach(onChangeProperty=>{ - console.log("api",onChangeProperty) + if(onChangeProperty.purpose == 'api'){ if(onChangeProperty.api == 'getListOfStatesAndCities'){ // console.log(event.value,onChangeProperty.params) @@ -249,7 +248,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { // console.log(JSON.parse(updatedParams),updatedParams,JSON.parse(JSON.stringify(updatedParams))) // debugger; let params={records:{state_id:event.value}} - console.log("after",onChangeProperty) + this.quesService.apiCall(onChangeProperty.api,params,onChangeProperty.api_method).subscribe(res=>{ if(res['dataStatus']){ this.local_city=res['records'].cities @@ -311,7 +310,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { if(onChangeProperty.purpose == 'FORM_CTRL'){ // if(options == 2){ - console.log(sec_control) + // debugger; this.creteNewField(onChangeProperty,this.formGroupN,sec_control,sec_index) // } @@ -331,7 +330,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index ?) { - console.log(curr_obj,formArray,this.json_index); + if(curr_obj && curr_obj.value_keys.length > 0 && curr_obj.arr_include.length > 0 ) { let expression_value=curr_obj.expression for(let index_str of curr_obj.arr_include) { @@ -345,10 +344,10 @@ export class DynamicQuestionTemplateComponent implements OnInit { if(vv.question_key == curr_obj.insert_control) { vv.is_hidden = true }}) - console.log("sdfffffffffff",this.whole_json,curr_obj.insert_control); + } if(formArray.value.length < 2) { - console.log("1 OBJ RETURN") + return; } value_index = curr_index-1 @@ -357,24 +356,24 @@ export class DynamicQuestionTemplateComponent implements OnInit { value_index = curr_index } for(let value of curr_obj.value_keys) { - console.log("dsf",value_index,value,value+'['+index_str+']',index_str) + let control_value = formArray.getRawValue()[value_index] ? formArray.getRawValue()[value_index][value] : '' if(control_value) { expression_value = expression_value.split(value+'['+index_str+']').join(control_value) } else{ if(formArray.value.length > curr_index+1) { - console.log("Current index",curr_index,this.json_index) + this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1) } - console.log("No Control RETURN") + return } } } if(expression_value) { let calc_exp=eval(expression_value) - console.log(calc_exp) + if(calc_exp){ if(typeof(calc_exp) == 'number'){ calc_exp = calc_exp.toFixed(2) @@ -382,7 +381,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { if(curr_obj.insert_control) { formArray.controls[curr_index].controls[curr_obj.insert_control].setValue(calc_exp) if(formArray.value.length > curr_index+1) { - console.log("Current index",curr_index,this.json_index) + this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1) } } @@ -393,7 +392,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } // for setting the modified value to another or same control while field change setModifiedValuetoControl(curr_obj,form_control_obj,curr_index) { - console.log(curr_obj,form_control_obj,curr_index) + if(curr_obj && curr_obj.value_keys.length > 0){ let expression_value=curr_obj.expression // curr_obj.value_keys.forEach(val=>{ @@ -408,9 +407,9 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } // }) - console.log(expression_value) + let calc_exp=eval(expression_value) - console.log(calc_exp, (typeof(calc_exp) == 'string' || typeof(calc_exp) == 'number' )) + if( (typeof(calc_exp) == 'string' || typeof(calc_exp) == 'number' ) ){ // if(typeof(calc_exp) == 'number'){ // calc_exp = calc_exp.toFixed(2) @@ -437,7 +436,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { curr_json = curr_json.question } } - console.log(curr_json); + if(curr_json) { curr_question_obj = curr_json.filter(val=>val.question_key == curr_obj.insert_control) if(curr_question_obj && curr_question_obj.length > 0) { @@ -452,7 +451,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } creteNewField(form_control_obj_raw,group_ques,sec_control,sec_index,purpose?){ - console.log(group_ques,form_control_obj_raw,sec_index); + if(form_control_obj_raw.form_controls.length > 0){ form_control_obj_raw.form_controls.forEach(form_control_obj=>{ if(form_control_obj.value_keys != null && form_control_obj.value_keys.length > 0 ){ @@ -472,9 +471,9 @@ export class DynamicQuestionTemplateComponent implements OnInit { expression_value=expression_value.split(res).join(control_value_obj) } }) - console.log("Expression",expression_value) + let calc_exp=eval(expression_value) - console.log("Expression result",calc_exp) + if(calc_exp != false){ if(form_control_obj.questions.length > 0){ let question_index_after @@ -484,7 +483,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { question_index_after= arr.indexOf(val) } }) - console.log("after result",question_index_after,sec_index); + this.createControl(form_control_obj,group_ques,question_index_after,1) //FOR ADD CONTOL } } @@ -496,17 +495,17 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } createControl(form_control_obj,group_ques,question_index_after,options){ - console.log(form_control_obj,group_ques,question_index_after) + let ques_control=this.whole_json let inserted_control_obj=form_control_obj // inserted_control_obj.questions.sort() // inserted_control_obj.questions.reverse() - console.log("check ddddddddddd",inserted_control_obj.questions) + inserted_control_obj.questions.forEach((val,index)=>{ if(val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { if(options == 1) { let check_dup=ques_control.filter(control_key=>control_key.group_key == val.group_key) - console.log(check_dup,this.formGroupN); + if(check_dup.length == 0){ this.formGroupN.addControl(val.group_key,this._fb.array([])) // val.question.reverse() @@ -524,7 +523,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { inserted_control_obj.questions[index].question = question_temp childControl.push(this._fb.group(control_names)) val.group_questions[0].forEach((group_indi,arr_index)=>{ - console.log("sd",childControl) + this.quesService.addAdditionalControl(group_indi, childControl.controls[0], arr_index) }) } @@ -546,7 +545,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { addOrRemoveControl(val,ques_control,question_index_after,options,paren_ques) { if(options == 1){ let check_dup=ques_control.filter(control_key=>control_key.question_key == val.question_key) - console.log(check_dup,this.formGroupN); + // let check_dup = [] if(check_dup.length == 0){ @@ -561,11 +560,11 @@ export class DynamicQuestionTemplateComponent implements OnInit { this.formGroupN.addControl(val.question_key,new FormControl('')) this.quesService.addAdditionalControl(val, this.formGroupN, question_index_after+1,"") } - console.log("After adding control",this.whole_json,this.formGroupN,this.whole_form); + } } else{ - console.log("Delete",ques_control) + ques_control.forEach((control_key,index)=>{ if(paren_ques.hasOwnProperty('is_repeatable') && paren_ques.is_repeatable == '1') { if(control_key.group_key == paren_ques.group_key){ @@ -573,7 +572,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { // this.formGroupN.controls[val.question_key].reset() this.formGroupN.removeControl(paren_ques.group_key); } - console.log(this.formGroupN,this.whole_json) + } else{ if(control_key.question_key == val.question_key){ @@ -595,14 +594,14 @@ export class DynamicQuestionTemplateComponent implements OnInit { this.addOrRemoveControl(val,ques_control,'',2,val) }) } - console.log(getSubQuestion,question_obj,this.whole_json) + } setValidations_onChange(validation_obj_raw,group_ques,sec_control,sec_index){ if(validation_obj_raw.validations.length > 0){ validation_obj_raw.validations.forEach(validation_obj=>{ - console.log("sing",validation_obj) + //FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION if(validation_obj.hasOwnProperty('value_keys')){ @@ -616,7 +615,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { expression_value=expression_value.split(res).join(validator_value_obj) // } }) - console.log("Validation expresseion final ",expression_value) + // validation_obj.value=expression_value validation_obj.validator=eval(expression_value) @@ -628,7 +627,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { else{ validation_obj.isactive='1' let validator_single=this.quesService.setValueForValidator(validation_obj) - console.log(validator_single) + // // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS this.proceedValidationSet(validation_obj,group_ques,sec_control,validator_single) } @@ -641,7 +640,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { validator_value_obj=this.formGroupN.value[ validation_obj.value] - console.log(validator_value_obj) + validation_obj.validator=validator_value_obj @@ -668,7 +667,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { proceedValidationSet(validation_obj,group_ques,sec_control,validator_single?){ let ques_control; if(validation_obj.validation_to == null){ - console.log("entered",group_ques,sec_control); + ques_control=this.whole_json[this.json_index] @@ -687,7 +686,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { } else{ ques_control=this.whole_json[this.json_index] - console.log(ques_control,this.whole_json,this.json_index) + let other_control = ques_control if(ques_control.hasOwnProperty('is_repeatable') && ques_control.is_repeatable == '2') { return; @@ -699,7 +698,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { // })[0] // let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name) // updateMsg.push(validation_obj) - console.log("OTHER CONTROL",other_control) + // other_control.controls.answer_value.setValidators(validator_single) // if(validation_obj.isactive == '1'){ // other_control.controls.answer_value.setValidators(validator_single) @@ -713,12 +712,12 @@ export class DynamicQuestionTemplateComponent implements OnInit { // other_control.controls.validations.setValue(updateMsg); // validation_obj.validator=validator_single let new_validations_obj=this.updateValidationMsg(other_control,validation_obj) - console.log("new validations obj",new_validations_obj,other_control) + this.quesService.settingArrayofValidators({validations:new_validations_obj,question_key:validation_obj.validation_to},this.formGroupN,'') } } newAnswerCreateDialog(choosed_answer_obj,curr_ques_obj) { - console.log(curr_ques_obj,choosed_answer_obj) + if(choosed_answer_obj.is_others == '-1') { this.formGroupN.get(curr_ques_obj.question_key).setValue('') let dialog = this.matDialog.open(AnswerOptionCreateDialogComponent,{ @@ -730,10 +729,9 @@ export class DynamicQuestionTemplateComponent implements OnInit { }) dialog.afterClosed().subscribe(rr=>{ if(rr.update && rr.address_for_display && rr.address_for_display.length > 0) { - console.log(curr_ques_obj.answers,curr_ques_obj.answers.length -2,rr.address_for_display) // curr_ques_obj.answers.splice(curr_ques_obj.answers.length -1,0,{answer:rr.address_for_display,answer_id:rr.address_for_display}) curr_ques_obj.answers = rr.address_for_display - console.log(curr_ques_obj.answers,curr_ques_obj.answers[curr_ques_obj.answers.length-2].answer_id) + let lastAddress = curr_ques_obj.answers[curr_ques_obj.answers.length-1].answer_id && curr_ques_obj.answers[curr_ques_obj.answers.length-1].answer_id != null && curr_ques_obj.answers[curr_ques_obj.answers.length-1].is_others != -1 ? curr_ques_obj.answers[curr_ques_obj.answers.length-1].answer_id : curr_ques_obj.answers[curr_ques_obj.answers.length-2].answer_id this.formGroupN.get(curr_ques_obj.question_key).patchValue(lastAddress) } @@ -744,7 +742,6 @@ export class DynamicQuestionTemplateComponent implements OnInit { } } updateValidationMsg(ques_control,validation_obj){ - console.log("updae msg",ques_control,validation_obj); if(!ques_control) { return; } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts index 82ba84e..45df8e5 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/ques-form/ques-form.service.ts @@ -19,11 +19,11 @@ export class QuesFormService { } // FOR CREATING A FORM CONTROL DYNAMICALLY assignFormControl_array(formgroup: FormGroup, ques_data: any) { - console.log(formgroup, ques_data) + const control: any = formgroup ques_data.forEach((val, index) => { - console.log("quees", val) + if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { // control.push(this._fb.group({ // "is_repeatable": [val.is_repeatable || null], @@ -36,7 +36,7 @@ export class QuesFormService { let childControl: any = control.get(val.group_key) as FormArray // childControl.push(this._fb.group({ 'questions': this._fb.array([]) })) - console.log("cc", childControl, control, index) + // let sub_childControl: any = childControl.controls[0].get('questions') as FormArray let control_names:any={} ques_data[index].group_questions = [] @@ -82,7 +82,7 @@ export class QuesFormService { // } // sub_childControl.push(this.createValue(group_indi)) }) - console.log(control_names, childControl.at(0)); + // debugger // val.questions[0]=val.question; if(childControl.value.length == 0) { @@ -94,14 +94,14 @@ export class QuesFormService { // control_names[childControl.at(0)] ='' let previous_added_controls = childControl.at(0).controls control_names = Object.assign(previous_added_controls,control_names) - console.log(control_names); + // debugger; childControl.setControl(0,this._fb.group(control_names)) } - console.log(formgroup.value); + // debugger; val.group_questions[0].forEach((group_indi,arr_index)=>{ - console.log("sd",childControl,group_indi) + if(group_indi.is_repeatable == '2' && group_indi.hasOwnProperty('questions_level_two') && group_indi.questions_level_two.length > 0) { group_indi.questions_level_two[0].forEach((child_val,child_index)=> { this.addAdditionalControl(child_val, childControl.at(0).get(group_indi.group_key).controls[0], child_index) @@ -120,7 +120,7 @@ export class QuesFormService { // },500) - console.log("dd112", formgroup, childControl) + // let key_list=Object.keys(val) // console.log(Object.keys(val)) // key_list.forEach(key=>{ @@ -158,7 +158,7 @@ export class QuesFormService { } else{ this.apiPropertiesCall(val).then(res => { - console.log("chekc", res) + if (res != false) { // val.answers=[] // val.answers=this.convertArrayNames(val.api_properties.fields,res) @@ -189,7 +189,7 @@ export class QuesFormService { // FUNCTIONAL TO HANDLE THE CREATION OF CHILD REPEABLE 2 addLevelTwoControls(curr_obj:any,child_control,group_ques,valQues,group_index) { - console.log(child_control) + // CURR VALUE(MULTI ARRAY) const question_temp:any = JSON.parse(JSON.stringify(curr_obj.questions_level_two)); group_ques[group_index].questions_level_two = [] @@ -200,18 +200,17 @@ export class QuesFormService { valQues[group_index].question = question_temp valQues[group_index].questions_level_two = [] valQues[group_index].questions_level_two.push(question_temp) - console.log(group_ques[group_index],question_temp); + // debugger; let group_key:any = {} group_key[curr_obj.group_key] = this._fb.array([]) child_control.push(this._fb.group(group_key)) - console.log(child_control) - console.log(child_control.at(0),child_control.controls[0].controls[curr_obj.group_key]) + // debugger; let levelTwoChildCtrl: any = child_control.at(0).get(curr_obj.group_key) as FormArray let control_names:any={} curr_obj.questions_level_two[0].forEach((val,arr_index)=>{ - console.log("Level 2",val) + val.raw_validations = val.validations control_names[val.question_key] = '' @@ -236,7 +235,7 @@ export class QuesFormService { } }) - console.log(group_ques[group_index]) + levelTwoChildCtrl.push(this._fb.group(control_names)) // console.log(formgroup.value); @@ -292,7 +291,7 @@ export class QuesFormService { res = res.filter(vv=>vv[filter_properties.key_name] == filter_properties.value) } resolve(res) - console.log(res) + // val.answers=res } else{ @@ -348,7 +347,7 @@ export class QuesFormService { let answer_value_loc=''; let answers_from_client=[] if(data_json.hasOwnProperty('answer_value') && data_json.answer_value != '' || null){ - console.log(data_json,control) + let values_for_cli:any = this.getAnswerValue(data_json) if(values_for_cli.flag == 1){ answer_value_loc=values_for_cli.values @@ -371,7 +370,7 @@ export class QuesFormService { user_det = JSON.parse(user_det); switch (value_obj.answer_value) { case 'CURRENT_USER': - console.log("current user", user_det) + return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name break; case "CURRENT_DESIGNATION": @@ -396,7 +395,7 @@ export class QuesFormService { // --END OF GETANSWERVALUE FUN addAdditionalControl(data,curr_control,curr_index,purpose?){ - console.log(curr_control); + //FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY if(data.type == '5'){ // curr_control.controls[curr_index].removeControl('answer_value'); @@ -458,7 +457,7 @@ export class QuesFormService { // FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp, settingArrayofValidators(data,curr_control,curr_index){ - console.log("entered",data,curr_control); + if(data.hasOwnProperty('validations') && data.validations.length > 0 ){ const validList :any= []; let validator_value @@ -469,7 +468,7 @@ export class QuesFormService { } else{ validator_value=this.setValueForValidator(valid) - console.log("cc",validator_value) + } validList.push(validator_value); @@ -482,14 +481,14 @@ export class QuesFormService { // let val1=`${val}` // console.log(typeof(eval(val))) // console.log(eval(val)) - console.log(validList) + // curr_control.controls[curr_index].controls.answer_value.setValidators(validList) if(curr_control.controls[data.question_key]) { curr_control.controls[data.question_key].setValidators(validList) - console.log("ddvdeeqq",validList) + curr_control.controls[data.question_key].updateValueAndValidity() } - console.log("after setting validators",curr_control.controls[data.question_key]) + // debugger; } } @@ -525,7 +524,7 @@ export class QuesFormService { else{ fy.push({fy_year:year-2+'-'+(year-1),curr:year-1}) } - console.log(fy) + for(let i=0;i<=2;i++){ fy.push({fy_year:(fy[i].curr-2)+'-'+(fy[i].curr-1),curr:fy[i].curr-1}) } @@ -536,7 +535,7 @@ export class QuesFormService { // FOR CREATING THE CORRECT VALIDATION setValueForValidator(value_obj){ - console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator)) + let return_value if(value_obj != null && value_obj.hasOwnProperty('validator')){ switch(value_obj.name) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts index bc39124..2ad755c 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/form/form.component.ts @@ -60,7 +60,7 @@ export class FormComponent implements OnInit { } ngOnInit() { - this.loadTemplate() + console.log("answered",this.pd_all_details.is_answered) if(this.pd_all_details.is_answered == '1') { this.getSectionData() @@ -68,10 +68,11 @@ export class FormComponent implements OnInit { else{ this.getExcelData(); } + this.loadTemplate() } loadTemplate() { // 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=>{ let params = {"fk_entity_id":this.pd_all_details.pdmaster_details.fk_lender_id,"fk_product_id":this.pd_all_details.pdmaster_details.fk_product_id,"pd_form_id":this.pd_all_details.form_id,"fk_pd_id":this.pd_all_details.pdmaster_details.pd_id} this.pdTriggerService.loadCreditPDTemplate(params).subscribe(result=>{ @@ -87,7 +88,7 @@ export class FormComponent implements OnInit { question_template =JSON.parse(question_template.template); this.commonFormGroup = new FormGroup({}) this.questions_JSON = question_template; - console.log(this.questions_JSON); + // console.log(this.questions_JSON); // setTimeout(() => { // this.covidAnswers = null // console.log("cleared") @@ -108,7 +109,7 @@ export class FormComponent implements OnInit { question_template =JSON.parse(question_template.template); this.commonFormGroup = new FormGroup({}) this.questions_JSON = question_template; - console.log(this.questions_JSON); + // console.log(this.questions_JSON); // setTimeout(() => { // this.covidAnswers = null // console.log("cleared") @@ -137,7 +138,7 @@ export class FormComponent implements OnInit { } } if(this.pd_all_details.pdmaster_details.re_uploaded == '1' && this.pd_all_details.is_reupload_data_fetched != '1') { - console.log("Reuploaded excel") + // console.log("Reuploaded excel") // let data = {"permanant_employees_person_met":"1","temporary_employees_person_met":"2","permanant_employees_cm":"3","temporary_employees_cm":"45","permanant_employees_salary":"55","temporary_employees_salary":"55","common_remarks":"dummy datas"} // setTimeout(()=>{ // this.commonFormGroup.patchValue(data) @@ -159,7 +160,7 @@ export class FormComponent implements OnInit { // formValues[val.key_name] = val.value // } // }) - console.log(formValues) + // console.log(formValues) // debugger; if(re_uploaded && re_uploaded == '1') { this.commonFormGroup.patchValue(formValues) @@ -176,7 +177,7 @@ export class FormComponent implements OnInit { }) } getLocalFormId() { - console.log(this.pd_all_details) + // console.log(this.pd_all_details) switch(this.pd_all_details.form_id) { case '5': return 2 @@ -216,7 +217,7 @@ export class FormComponent implements OnInit { // this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index // } for (const name in (this.commonFormGroup.controls)) { - console.log(this.commonFormGroup.controls[name],name) + // console.log(this.commonFormGroup.controls[name],name) if (this.commonFormGroup.controls[name].invalid) { invalid.push(name); let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid'));