Fairoj : SMC CREDIT pd consoles are removed

This commit is contained in:
venbatechnologies@gmail.com 2021-04-15 13:06:21 +05:30
parent 01d4fd6d9d
commit af2985ac13
6 changed files with 147 additions and 180 deletions

View File

@ -49,11 +49,9 @@ export class QuesTemplateComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.sales_pd_section_to_fetch = localStorage.getItem('commonSettings') 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 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.
// 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 = 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(","); // this.sales_pd_section_to_fetch = values.join(",");
console.log(this.sales_pd_section_to_fetch);
// debugger; // debugger;
} }
ngOnChanges(){ 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) 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('sec'+this.local_ques_JSON.section_id).then(resultData=>{
// this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{ // 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 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) { if(this.curr_pd_info.smc_credit_pd && this.curr_pd_info.smc_credit_pd != null) {
// this.getSalesPDSectionFromApi(this.sales_pd_id); // this.getSalesPDSectionFromApi(this.sales_pd_id);
// console.log(this.curr_pd_info.saved_sections );
// debugger; // debugger;
if(this.curr_pd_info.saved_sections) { if(this.curr_pd_info.saved_sections) {
this.proceedToGetDataFromSmcCredit() this.proceedToGetDataFromSmcCredit()
@ -190,7 +187,6 @@ else {
this.raw_data_Section=response['records'][0] this.raw_data_Section=response['records'][0]
this.original_result_data=response['records'][0].section_data this.original_result_data=response['records'][0].section_data
this.original_result_data=JSON.parse(this.original_result_data); this.original_result_data=JSON.parse(this.original_result_data);
console.log(this.original_result_data);
// debugger; // debugger;
// this.original_result_data.questions=this.original_result_data.questions.filter(val=>val.question_key == 'selfie_with_person_met') // this.original_result_data.questions=this.original_result_data.questions.filter(val=>val.question_key == 'selfie_with_person_met')
this.checkGroupandPatchValues() this.checkGroupandPatchValues()
@ -275,7 +271,6 @@ else {
// ]}` // ]}`
// img_values = JSON.parse(img_values) // img_values = JSON.parse(img_values)
let createPhotoStructure:any=this.quesAnsForm.value.questions 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) { if(img_values.img_data.length > 0) {
// img_values.img_data.forEach(img_obj=>{ // img_values.img_data.forEach(img_obj=>{
for(let img_obj of img_values.img_data) { 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 findRootIndex = createPhotoStructure.findIndex(val=>val.question_key == img_obj.img_key)
let current_control_obj:any =[] let current_control_obj:any =[]
current_control_obj = createPhotoStructure[findRootIndex] current_control_obj = createPhotoStructure[findRootIndex]
console.log(createPhotoStructure[findRootIndex])
if(img_obj.is_multiple != '1'){ if(img_obj.is_multiple != '1'){
current_control_obj.answer_value = img_obj.img_url current_control_obj.answer_value = img_obj.img_url
} }
@ -292,7 +286,6 @@ else {
// img_obj.img_data.forEach(multi_obj=>{ // img_obj.img_data.forEach(multi_obj=>{
for(let multi_obj of img_obj.img_data) { for(let multi_obj of img_obj.img_data) {
if(multi_obj) { if(multi_obj) {
// console.log(multi_obj)
let temp_obj:any = [] let temp_obj:any = []
temp_obj.length = 0; temp_obj.length = 0;
@ -334,7 +327,6 @@ else {
} }
} }
proceedonChangeProperty(local_value_obj?){ proceedonChangeProperty(local_value_obj?){
console.log("On Change Property",this.quesAnsForm.value.questions);
this.quesAnsForm.controls.questions['controls'].forEach((val,p_i)=>{ this.quesAnsForm.controls.questions['controls'].forEach((val,p_i)=>{
@ -350,7 +342,6 @@ else {
} }
// JSON QUESTION CHANGE FOR SINGLE // JSON QUESTION CHANGE FOR SINGLE
console.log("key",p_i,this.quesAnsForm.value)
if (this.original_result_data.questions[p_i] != undefined) { 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) { 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 // ADDING THE QUESTION TO FETCHED DATA ARRAY
@ -361,9 +352,9 @@ else {
// REMOVING THE QUESTION TO FETCHED DATA ARRAY // REMOVING THE QUESTION TO FETCHED DATA ARRAY
else { 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) 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 --- // --- END OF REMOVING QUESTION ---
} }
@ -403,7 +394,7 @@ else {
// setTimeout(()=>{ // setTimeout(()=>{
let form_c=single_ques let form_c=single_ques
let form_control=this.quesAnsForm.value.questions[p_i].questions_group[g_i].questions[s_i] 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 let local__g_data=this.original_result_data.questions[p_i].questions_group[g_i].questions
if(local__g_data[s_i] != undefined){ if(local__g_data[s_i] != undefined){
if(form_control.question_key != local__g_data[s_i].question_key){ 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); this.quesAnsForm.get('questions').patchValue(this.original_result_data.questions);
console.log(this.quesAnsForm)
} }
setStep(index: number) { setStep(index: number) {
this.step = index; this.step = index;
@ -466,14 +456,12 @@ this.proceedonChangeProperty(modified)
if (event.type === HttpEventType.UploadProgress) { if (event.type === HttpEventType.UploadProgress) {
// This is an upload progress event. Compute and show the % done: // This is an upload progress event. Compute and show the % done:
const percentDone = Math.round(100 * event.loaded / event.total); const percentDone = Math.round(100 * event.loaded / event.total);
console.log(`File is ${percentDone}% uploaded.`);
} else if (event instanceof HttpResponse) { } else if (event instanceof HttpResponse) {
console.log('File is completely uploaded!');
} }
} }
addData(group_index, parent_index, data, event, options?: any, single_ques?) { 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 ) data=data.filter(group_indi=>!group_indi.hasOwnProperty('additional_field') && group_indi.additional_field != 1 )
if (options == 'camera') { if (options == 'camera') {
@ -485,7 +473,6 @@ this.proceedonChangeProperty(modified)
// this.cameraProvider.addWatermarks(res).then(watermarkedImage => { // this.cameraProvider.addWatermarks(res).then(watermarkedImage => {
// single_ques.controls.answer_value.setValue(watermarkedImage) // single_ques.controls.answer_value.setValue(watermarkedImage)
// // this.sales_pd_id = Number(this.sales_pd_id) // // 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) ) { // // 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) // 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_loader.setValue(false);
// single_ques.controls.is_saved.setValue(false); // single_ques.controls.is_saved.setValue(false);
// this.salesPDProvider.clear_local_key('sec'+storage_param.section_id) // this.salesPDProvider.clear_local_key('sec'+storage_param.section_id)
// console.log("error",err);
// this.toastProvider.lenderappmessage('Network Error') // this.toastProvider.lenderappmessage('Network Error')
// this.emittedFormGroup = this.quesAnsForm.getRawValue() // this.emittedFormGroup = this.quesAnsForm.getRawValue()
// this.imageUploadCheck.emit(this.emittedFormGroup); // this.imageUploadCheck.emit(this.emittedFormGroup);
@ -553,15 +539,15 @@ this.proceedonChangeProperty(modified)
// }) // })
// } // }
// }, error => { // }, error => {
// console.log("Camera Error ", JSON.stringify(error)); //
// }) // })
// single_ques.controls.answer_value.setValue(base64) // single_ques.controls.answer_value.setValue(base64)
// console.clear(); // console.clear();
// console.log(single_ques); //
// single_ques.controls.is_image_status.setValue(true); // single_ques.controls.is_image_status.setValue(true);
// single_ques.controls.is_loader.setValue(true); // single_ques.controls.is_loader.setValue(true);
// single_ques.controls.is_saved.setValue(false); // single_ques.controls.is_saved.setValue(false);
// console.log(single_ques); //
// let control: any = parent_index['controls'].questions_group as FormArray // let control: any = parent_index['controls'].questions_group as FormArray
// control.push(this._fb.group({ 'questions': this._fb.array([]) })) // control.push(this._fb.group({ 'questions': this._fb.array([]) }))
// let sub_childControl: any = control.controls[group_index + 1].get('questions') as FormArray // 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 this.step=control.length-1
} }
onChange_checkbox(event,sec_control){ onChange_checkbox(event,sec_control){
console.log(event,sec_control)
const control=sec_control.get('answer_value') as FormArray const control=sec_control.get('answer_value') as FormArray
if(event.checked) { if(event.checked) {
@ -724,7 +709,6 @@ this.proceedonChangeProperty(modified)
creatSubField(sec_control,choosen_value){ creatSubField(sec_control,choosen_value){
let curr_answer:any=[] let curr_answer:any=[]
console.log(sec_control,choosen_value)
if(typeof(choosen_value) == 'object'){ 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 != '') 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){ if(curr_answer.length >0){
curr_answer=curr_answer[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_key',new FormControl(curr_answer.subfield_key))
sec_control.addControl('subfield_caption',new FormControl(curr_answer.subfield_caption)) sec_control.addControl('subfield_caption',new FormControl(curr_answer.subfield_caption))
sec_control.addControl('subfield_value',new FormControl('')) sec_control.addControl('subfield_value',new FormControl(''))
@ -813,7 +796,6 @@ this.proceedonChangeProperty(modified)
// onChangeProperties_value.push(JSON.parse(new_name)) // onChangeProperties_value.push(JSON.parse(new_name))
onChangeProperties_value.forEach(onChangeProperty=>{ onChangeProperties_value.forEach(onChangeProperty=>{
console.log("api",onChangeProperty)
if(onChangeProperty.purpose == 'api'){ if(onChangeProperty.purpose == 'api'){
if(onChangeProperty.api == 'getListOfStatesAndCities'){ if(onChangeProperty.api == 'getListOfStatesAndCities'){
this.salesPDProvider.getCityPincode(event.value).subscribe(res=>{ 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?){ 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){ if(form_control_obj_raw.form_controls.length > 0){
form_control_obj_raw.form_controls.forEach(form_control_obj=>{ form_control_obj_raw.form_controls.forEach(form_control_obj=>{
if(form_control_obj.value_keys != null && form_control_obj.value_keys.length > 0 ){ 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) 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 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){ 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 ques_control=group_ques.get('questions') as FormArray
let inserted_control_obj=form_control_obj let inserted_control_obj=form_control_obj
inserted_control_obj.questions.sort() inserted_control_obj.questions.sort()
@ -956,7 +935,6 @@ this.proceedonChangeProperty(modified)
if(validation_obj_raw.validations.length > 0){ if(validation_obj_raw.validations.length > 0){
validation_obj_raw.validations.forEach(validation_obj=>{ validation_obj_raw.validations.forEach(validation_obj=>{
console.log("sing",validation_obj)
//FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION //FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION
if(validation_obj.hasOwnProperty('value_keys')){ if(validation_obj.hasOwnProperty('value_keys')){
@ -983,7 +961,6 @@ this.proceedonChangeProperty(modified)
else{ else{
validation_obj.isactive='1' validation_obj.isactive='1'
let validator_single=this.questionService.setValueForValidator(validation_obj) let validator_single=this.questionService.setValueForValidator(validation_obj)
console.log(validator_single)
// // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS // // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS
this.proceedValidationSet(validation_obj,group_ques,sec_index,validator_single) 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 == validator_value_obj=group_ques.value.questions.filter(val=>val.question_key ==
validation_obj.value)[0] validation_obj.value)[0]
console.log(validator_value_obj)
validation_obj.validator=validator_value_obj.answer_value validation_obj.validator=validator_value_obj.answer_value
@ -1024,7 +1001,6 @@ this.proceedonChangeProperty(modified)
proceedValidationSet(validation_obj,group_ques,sec_index,validator_single?){ proceedValidationSet(validation_obj,group_ques,sec_index,validator_single?){
let ques_control; let ques_control;
if(validation_obj.validation_to == null){ if(validation_obj.validation_to == null){
console.log("entered",group_ques,sec_index);
ques_control=group_ques.controls.questions['controls'][sec_index] ques_control=group_ques.controls.questions['controls'][sec_index]
@ -1050,7 +1026,7 @@ this.proceedonChangeProperty(modified)
})[0] })[0]
// let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name) // let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name)
// updateMsg.push(validation_obj) // updateMsg.push(validation_obj)
console.log(other_control)
// other_control.controls.answer_value.setValidators(validator_single) // other_control.controls.answer_value.setValidators(validator_single)
// if(validation_obj.isactive == '1'){ // if(validation_obj.isactive == '1'){
// other_control.controls.answer_value.setValidators(validator_single) // other_control.controls.answer_value.setValidators(validator_single)
@ -1064,12 +1040,12 @@ this.proceedonChangeProperty(modified)
// other_control.controls.validations.setValue(updateMsg); // other_control.controls.validations.setValue(updateMsg);
// validation_obj.validator=validator_single // validation_obj.validator=validator_single
let new_validations_obj=this.updateValidationMsg(other_control,validation_obj) 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,'') this.questionService.settingArrayofValidators({validations:new_validations_obj},other_control,'')
} }
} }
updateValidationMsg(ques_control,validation_obj){ 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) let updateMsg=ques_control.value.validations.filter(val=>val.name != validation_obj.name)
updateMsg.push(validation_obj) updateMsg.push(validation_obj)
ques_control.controls.validations.setValue(updateMsg); 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){ if(return_val.filter(val=>val == false).length > 0){
break; break;
} }
} }
console.log(return_val)
if(return_val.length > 0){ if(return_val.length > 0){
if(return_val.filter(res=>res == false).length > 0){ if(return_val.filter(res=>res == false).length > 0){
send_val = false send_val = false
@ -1187,8 +1163,7 @@ this.proceedonChangeProperty(modified)
// return sum_val }());` // return sum_val }());`
let val= eval(submitProperty.expression); let val= eval(submitProperty.expression)
console.log(val)
return val return val
} }
@ -1236,7 +1211,7 @@ this.proceedonChangeProperty(modified)
} }
public findInvalidControls() { public findInvalidControls() {
const controls = this.quesAnsForm.get('questions')['controls']; const controls = this.quesAnsForm.get('questions')['controls'];
console.log(controls)
for (const name in controls) { for (const name in controls) {
if (controls[name].invalid) { if (controls[name].invalid) {
let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid'));
@ -1307,7 +1282,6 @@ this.proceedonChangeProperty(modified)
// } // }
// //END OF IMAGE SAVE REQUEST CHECK // //END OF IMAGE SAVE REQUEST CHECK
let checkProperty=this.onSubmitProperty() let checkProperty=this.onSubmitProperty()
console.log("check rp",checkProperty)
if(checkProperty == false){ if(checkProperty == false){
return; return;
} }
@ -1328,7 +1302,6 @@ this.proceedonChangeProperty(modified)
}) })
return; return;
} }
console.log(this.quesAnsForm.dirty)
// if(this.quesAnsForm.dirty){ // if(this.quesAnsForm.dirty){
if(this.local_ques_JSON.section_id == 1 || this.submit_btn){ if(this.local_ques_JSON.section_id == 1 || this.submit_btn){
let result = this.curr_pd_info.smc_credit_pd let result = this.curr_pd_info.smc_credit_pd
@ -1370,7 +1343,6 @@ this.proceedonChangeProperty(modified)
params.questions=this.questions_JSON.questions params.questions=this.questions_JSON.questions
params.is_completed=false params.is_completed=false
setTimeout(()=>{ setTimeout(()=>{
console.log('emiiter')
this.emitter.emit(params) this.emitter.emit(params)
}) })
},1200) },1200)
@ -1394,7 +1366,6 @@ this.proceedonChangeProperty(modified)
}); });
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed',result);
if(result && result != 'cancel') { if(result && result != 'cancel') {
this.saveSalesPDAPI(section_data) this.saveSalesPDAPI(section_data)
} }
@ -1432,7 +1403,7 @@ this.proceedonChangeProperty(modified)
if(apiresult['records'] != true && typeof(apiresult['records']) != 'object'){ if(apiresult['records'] != true && typeof(apiresult['records']) != 'object'){
this.curr_pd_info.smc_credit_pd = String(apiresult['records']) this.curr_pd_info.smc_credit_pd = String(apiresult['records'])
this.curr_pd_info.rand_string= String(apiresult['rand_string']) 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_pd_id_PRIMARYKEY',String(apiresult['records'])).then(local_result=>{
// this.salesPDProvider.insertData_Replace('sales_rand_string',String(apiresult['rand_string'])).then(()=>{ // this.salesPDProvider.insertData_Replace('sales_rand_string',String(apiresult['rand_string'])).then(()=>{
if(!this.submit_btn){ if(!this.submit_btn){
@ -1553,7 +1524,7 @@ this.proceedonChangeProperty(modified)
// SENDING SALES PD SECTION 9 STRUCTURE(photographs) // SENDING SALES PD SECTION 9 STRUCTURE(photographs)
ngOnDestroy(){ ngOnDestroy(){
// console.clear() // console.clear()
console.log("dirty check",this.quesAnsForm.dirty)
if(this.local_ques_JSON.section_id == 9 && this.emittedFormGroup != null){ if(this.local_ques_JSON.section_id == 9 && this.emittedFormGroup != null){
// FOR SENDING THE IMAGE SECTION (SECTION ID 9) JSON Structure // FOR SENDING THE IMAGE SECTION (SECTION ID 9) JSON Structure
let form_structure=this.quesAnsForm.getRawValue().questions let form_structure=this.quesAnsForm.getRawValue().questions

View File

@ -17,11 +17,11 @@ export class QuesTemplateService {
} }
// FOR CREATING A FORM CONTROL DYNAMICALLY // FOR CREATING A FORM CONTROL DYNAMICALLY
assignFormControl_array(formgroup: FormGroup, ques_data: any) { assignFormControl_array(formgroup: FormGroup, ques_data: any) {
console.log(formgroup, ques_data)
this.curr_pd_info = this.salesPDProvider.curr_credit_pd_data this.curr_pd_info = this.salesPDProvider.curr_credit_pd_data
const control: any = formgroup.get('questions') as FormArray const control: any = formgroup.get('questions') as FormArray
ques_data.forEach((val, index) => { ques_data.forEach((val, index) => {
console.log("quees", val)
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
control.push(this._fb.group({ control.push(this._fb.group({
"is_repeatable": [val.is_repeatable || null], "is_repeatable": [val.is_repeatable || null],
@ -38,20 +38,20 @@ export class QuesTemplateService {
let childControl: any = control.controls[index].get('questions_group') as FormArray let childControl: any = control.controls[index].get('questions_group') as FormArray
childControl.push(this._fb.group({ 'questions': this._fb.array([]) })) 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 sub_childControl: any = childControl.controls[0].get('questions') as FormArray
val.question.forEach((group_indi, arr_index) => { val.question.forEach((group_indi, arr_index) => {
// if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){ // if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){
console.log("api pro", val.api_properties)
// let param // let param
// val.api_properties.forEach(val=>param=val) // val.api_properties.forEach(val=>param=val)
// console.log(param)
group_indi.raw_validations = group_indi.validations group_indi.raw_validations = group_indi.validations
sub_childControl.push(this.createValue(group_indi)) sub_childControl.push(this.createValue(group_indi))
this.addAdditionalControl(group_indi, sub_childControl, arr_index) this.addAdditionalControl(group_indi, sub_childControl, arr_index)
// if(group_indi.type == '5'){ // if(group_indi.type == '5'){
// sub_childControl.controls[arr_index].removeControl('answer_value'); // 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([])) // sub_childControl.controls[arr_index].addControl('answer_value',this._fb.array([]))
// } // }
// if(group_indi.type == '1'){ // if(group_indi.type == '1'){
@ -86,19 +86,19 @@ export class QuesTemplateService {
// },500) // },500)
console.log("dd112", formgroup, childControl)
// let key_list=Object.keys(val) // let key_list=Object.keys(val)
// console.log(Object.keys(val))
// key_list.forEach(key=>{ // key_list.forEach(key=>{
// childControl.controls // childControl.controls
// }) // })
} }
else { else {
// console.log("con",control)
// let key_list=Object.keys(val) // let key_list=Object.keys(val)
// console.log(Object.keys(val))
// let curr_object // let curr_object
// console.log("apikd",typeof(val.api_properties))
// if(val.api_properties != null && typeof(val.api_properties) == 'object'){ // if(val.api_properties != null && typeof(val.api_properties) == 'object'){
val.raw_validations = val.validations val.raw_validations = val.validations
control.push(this.createValue(val)) control.push(this.createValue(val))
@ -106,7 +106,7 @@ export class QuesTemplateService {
this.addAdditionalControl(val, control, index) this.addAdditionalControl(val, control, index)
// if(val.type == '5'){ // if(val.type == '5'){
// control.controls[index].removeControl('answer_value'); // control.controls[index].removeControl('answer_value');
// console.log("loop",index,control);
// control.controls[index].addControl('answer_value',this._fb.array([])) // control.controls[index].addControl('answer_value',this._fb.array([]))
// } // }
// if(val.type == '1'){ // if(val.type == '1'){
@ -117,7 +117,7 @@ export class QuesTemplateService {
// } // }
if (val.api_properties != null) { if (val.api_properties != null) {
this.apiPropertiesCall(val).then(res => { this.apiPropertiesCall(val).then(res => {
console.log("chekc", res)
if (res != false) { if (res != false) {
// val.answers=[] // val.answers=[]
// val.answers=this.convertArrayNames(val.api_properties.fields,res) // val.answers=this.convertArrayNames(val.api_properties.fields,res)
@ -184,11 +184,11 @@ export class QuesTemplateService {
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
if(val.api_properties != null && typeof(val.api_properties) == 'object'){ if(val.api_properties != null && typeof(val.api_properties) == 'object'){
let pd_info = this.curr_pd_info let pd_info = this.curr_pd_info
console.log(pd_info)
let params = val.api_properties.params let params = val.api_properties.params
if(val.api_properties.hasOwnProperty('params_type') && val.api_properties.params_type == 'expression') { if(val.api_properties.hasOwnProperty('params_type') && val.api_properties.params_type == 'expression') {
params = eval(val.api_properties.params) params = eval(val.api_properties.params)
console.log(params,this.curr_pd_info.smc_credit_pd)
// debugger; // debugger;
} }
this.salesPDProvider.api_post_method(val.api_properties.api,params,val.api_properties.api_method).subscribe(res=>{ 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'] res=res['records']
} }
resolve(res) resolve(res)
console.log(res)
// val.answers=res // val.answers=res
} }
else{ else{
@ -243,7 +243,7 @@ export class QuesTemplateService {
// user_det = JSON.parse(user_det); // user_det = JSON.parse(user_det);
switch (value_obj.answer_value) { switch (value_obj.answer_value) {
case 'CURRENT_USER': case 'CURRENT_USER':
console.log("current user", user_det)
return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name
break; break;
case "CURRENT_DESIGNATION": case "CURRENT_DESIGNATION":
@ -302,7 +302,7 @@ export class QuesTemplateService {
// FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp, // FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp,
settingArrayofValidators(data,curr_control,curr_index){ settingArrayofValidators(data,curr_control,curr_index){
console.log("entered",data);
if(data.hasOwnProperty('validations') && data.validations.length > 0 ){ if(data.hasOwnProperty('validations') && data.validations.length > 0 ){
const validList :any= []; const validList :any= [];
let validator_value let validator_value
@ -313,7 +313,7 @@ export class QuesTemplateService {
} }
else{ else{
validator_value=this.setValueForValidator(valid) validator_value=this.setValueForValidator(valid)
console.log("cc",validator_value)
} }
validList.push(validator_value); validList.push(validator_value);
@ -326,12 +326,12 @@ export class QuesTemplateService {
// let val1=`${val}` // let val1=`${val}`
// console.log(typeof(eval(val))) // console.log(typeof(eval(val)))
// console.log(eval(val)) // console.log(eval(val))
console.log(validList)
// curr_control.controls[curr_index].controls.answer_value.setValidators(validList) // curr_control.controls[curr_index].controls.answer_value.setValidators(validList)
curr_control.controls.answer_value.setValidators(validList) curr_control.controls.answer_value.setValidators(validList)
console.log("ddvdeeqq",validList)
curr_control.controls.answer_value.updateValueAndValidity() curr_control.controls.answer_value.updateValueAndValidity()
console.log("after setting validators",curr_control)
} }
} }
// END OF SETTINGARRAYOFVALIDATORS FUN // END OF SETTINGARRAYOFVALIDATORS FUN
@ -365,7 +365,7 @@ export class QuesTemplateService {
else{ else{
fy.push({fy_year:year-2+'-'+(year-1),curr:year-1}) fy.push({fy_year:year-2+'-'+(year-1),curr:year-1})
} }
console.log(fy)
for(let i=0;i<=2;i++){ for(let i=0;i<=2;i++){
fy.push({fy_year:(fy[i].curr-2)+'-'+(fy[i].curr-1),curr:fy[i].curr-1}) 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 // FOR CREATING THE CORRECT VALIDATION
setValueForValidator(value_obj){ setValueForValidator(value_obj){
console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator))
let return_value let return_value
if(value_obj != null && value_obj.hasOwnProperty('validator')){ if(value_obj != null && value_obj.hasOwnProperty('validator')){
switch(value_obj.name) switch(value_obj.name)

View File

@ -24,7 +24,7 @@ export class DynamicFormComponent implements OnInit {
ngOnInit() { ngOnInit() {
// this.form_group_name=new FormGroup({questions:this._fb.array([])}) // 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) this.form_group_name=this.questionService.assignFormControl_array(this.form_group_name,this.questions_JSON.questions)
// debugger // debugger
@ -33,16 +33,16 @@ export class DynamicFormComponent implements OnInit {
generateGroupControls() { generateGroupControls() {
if(this.json_answers && this.json_answers != null ){ if(this.json_answers && this.json_answers != null ){
this.questions_JSON.questions.forEach(parent_ques=>{ this.questions_JSON.questions.forEach(parent_ques=>{
console.log(parent_ques);
// debugger; // debugger;
// FOR ADDING THE GROUP QUES TO DISPLAY WITHOUT CONSIDERING INDEX 0 // FOR ADDING THE GROUP QUES TO DISPLAY WITHOUT CONSIDERING INDEX 0
if(parent_ques.is_repeatable == '1'){ 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) { 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].mobile_numbers= [{mobile_no:93299},{mobile_no:948392}]
this.json_answers[parent_ques.group_key].forEach((group_ques,g_i)=>{ this.json_answers[parent_ques.group_key].forEach((group_ques,g_i)=>{
console.log(parent_ques,g_i,group_ques)
// debugger; // debugger;
if(g_i != 0){ if(g_i != 0){
@ -56,16 +56,16 @@ export class DynamicFormComponent implements OnInit {
let keys= Object.keys(group_ques) let keys= Object.keys(group_ques)
keys.forEach((vv,key_index)=>{ keys.forEach((vv,key_index)=>{
if(typeof(group_ques[vv]) != 'string') { if(typeof(group_ques[vv]) != 'string') {
console.log("Entered",group_ques[vv]);
if(group_ques[vv] && group_ques[vv].length > 0) { if(group_ques[vv] && group_ques[vv].length > 0) {
// //
group_ques[vv].forEach((child_val,child_index)=>{ group_ques[vv].forEach((child_val,child_index)=>{
if(child_index != 0) { 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) let find_json = parent_ques.group_questions[g_i].filter(val=>val.hasOwnProperty('group_key') && val.group_key == vv)
if(find_json.length > 0) { if(find_json.length > 0) {
find_json = find_json[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]) 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() { ngOnChanges() {
console.log(this.questions_JSON,this.json_answers,this.questionService); // console.log(this.questions_JSON,this.json_answers,this.questionService);
// debugger // debugger
// if(this.json_answers && this.json_answers != null ){ // if(this.json_answers && this.json_answers != null ){
// this.questions_JSON.questions.forEach(parent_ques=>{ // 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([])}) // 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.valueChanges.subscribe(()=>{
// this.form_group_name.updateValueAndValidity(); // this.form_group_name.updateValueAndValidity();
// }) // })
@ -129,7 +129,7 @@ export class DynamicFormComponent implements OnInit {
control_names[val.question_key] = '' control_names[val.question_key] = ''
} }
}) })
console.log(control,json_obj.group_key,control_names,json_obj.question);
// debugger; // debugger;
json_obj.group_questions.push(json_obj.question); json_obj.group_questions.push(json_obj.question);
@ -156,19 +156,18 @@ export class DynamicFormComponent implements OnInit {
control.controls[control.length-1].updateValueAndValidity(); control.controls[control.length-1].updateValueAndValidity();
this.form_group_name.updateValueAndValidity(); this.form_group_name.updateValueAndValidity();
this.step = control.length-1 this.step = control.length-1
console.log(this.form_group_name.value);
// debugger; // debugger;
} }
// ADDING A CHILD REPEATABLE OBJ IN A EXISTING FORM ARRYA // ADDING A CHILD REPEATABLE OBJ IN A EXISTING FORM ARRYA
addSecondLevelChild(index,json_obj,parent_group) { addSecondLevelChild(index,json_obj,parent_group) {
console.log(json_obj,parent_group)
let control_names:any= {} let control_names:any= {}
let control = parent_group.get(json_obj.group_key) as FormArray let control = parent_group.get(json_obj.group_key) as FormArray
json_obj.question.map(val=>{ json_obj.question.map(val=>{
control_names[val.question_key] = '' 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); json_obj.questions_level_two.push(json_obj.question);
control.push(this._fb.group(control_names)) control.push(this._fb.group(control_names))
@ -182,38 +181,38 @@ export class DynamicFormComponent implements OnInit {
control.controls[control.length-1].updateValueAndValidity(); control.controls[control.length-1].updateValueAndValidity();
parent_group.updateValueAndValidity(); parent_group.updateValueAndValidity();
this.step_child = control.length-1 this.step_child = control.length-1
console.log(this.form_group_name.value,this.questions_JSON);
// debugger; // debugger;
} }
// REMOVE OF CHILD REPEATABLE OBJ // REMOVE OF CHILD REPEATABLE OBJ
removeSecondLevelChild(index,json_obj,parent_group) { removeSecondLevelChild(index,json_obj,parent_group) {
console.log(json_obj)
// debugger; // debugger;
let control = parent_group.get(json_obj.group_key) let control = parent_group.get(json_obj.group_key)
control.removeAt(index) control.removeAt(index)
json_obj.questions_level_two.splice(index,1) json_obj.questions_level_two.splice(index,1)
this.step_child = control.length-1 this.step_child = control.length-1
console.log(json_obj)
} }
removeData(index,json_obj) { removeData(index,json_obj) {
console.log(json_obj)
// debugger; // debugger;
let control = this.form_group_name.get(json_obj.group_key) as FormArray let control = this.form_group_name.get(json_obj.group_key) as FormArray
control.removeAt(index) control.removeAt(index)
json_obj.group_questions.splice(index,1) json_obj.group_questions.splice(index,1)
this.step = control.length-1 this.step = control.length-1
console.log(json_obj)
} }
openMatExpansionPanel() { openMatExpansionPanel() {
console.log("opening expansion panek",this.matExpansionPanel)
if(this.matExpansionPanel!= undefined){ if(this.matExpansionPanel!= undefined){
this.matExpansionPanel.open() this.matExpansionPanel.open()
} }
} }
openAllPanels(){ openAllPanels(){
this.Accordion.openAll(); this.Accordion.openAll();
console.log(this.Accordion);
return; return;
} }

View File

@ -44,18 +44,17 @@ export class DynamicQuestionTemplateComponent implements OnInit {
ngOnChanges() { ngOnChanges() {
this.parent_ques = this.currFormArrayObj this.parent_ques = this.currFormArrayObj
if(this.json_answers!=null && this.json_answers != undefined && this.json_answers) { 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(()=>{ // setTimeout(()=>{
console.clear() // console.clear()
console.log(this.json_answers,this.parent_ques.question_key)
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,'')
console
} }
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] || ''))
console.log(this.json_answers,this.whole_form.get(this.group_key))
// debugger; // debugger;
this.whole_form.get(this.group_key).patchValue(this.json_answers) this.whole_form.get(this.group_key).patchValue(this.json_answers)
if(this.json_answers.length > 1) { if(this.json_answers.length > 1) {
@ -66,18 +65,18 @@ export class DynamicQuestionTemplateComponent implements OnInit {
let keys= Object.keys(value) let keys= Object.keys(value)
keys.forEach(vv=>{ keys.forEach(vv=>{
console.log("ype of ",value[vv],typeof(value[vv]),this.whole_json)
// debugger; // debugger;
if(typeof(value[vv])== 'string') { 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) { 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,'')
} }
console.log("Repeatable ques",value,this.parent_ques.question_key)
} }
}) })
@ -105,14 +104,14 @@ export class DynamicQuestionTemplateComponent implements OnInit {
// debugger; // debugger;
if(this.parent_ques.type == '8') { if(this.parent_ques.type == '8') {
console.log("Initial",this.parent_ques.answers)
if(this.parent_ques.answers && this.parent_ques.answers.length > 0){ if(this.parent_ques.answers && this.parent_ques.answers.length > 0){
this.ngxFilteredValue.next(this.parent_ques.answers.slice()) this.ngxFilteredValue.next(this.parent_ques.answers.slice())
// this.filterList() // this.filterList()
} }
else{ else{
setTimeout(()=>{ setTimeout(()=>{
console.log("last",this.parent_ques.answers)
if(this.parent_ques.answers && this.parent_ques.answers.length > 0){ if(this.parent_ques.answers && this.parent_ques.answers.length > 0){
this.ngxFilteredValue.next(this.parent_ques.answers.slice()) this.ngxFilteredValue.next(this.parent_ques.answers.slice())
// this.filterList() // this.filterList()
@ -124,7 +123,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
} }
filterList() { filterList() {
this.commonFilterCtrl.valueChanges.pipe().subscribe(()=>{ 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) { 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') 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){ onChange_checkbox(event,sec_control){
console.log(event,sec_control)
const control=this.formGroupN.get(sec_control.question_key) as FormArray const control=this.formGroupN.get(sec_control.question_key) as FormArray
if(event.checked) { if(event.checked) {
@ -170,7 +169,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
} }
} }
onChangeProperty(event,sec_control,question_key,options?,sec_index?){ onChangeProperty(event,sec_control,question_key,options?,sec_index?){
console.log(sec_control);
// this.fileredSearchValue=[] // this.fileredSearchValue=[]
if(sec_control && sec_control.answers!= null && sec_control.answers.length > 0){ 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.push(JSON.parse(new_name))
onChangeProperties_value.forEach(onChangeProperty=>{ onChangeProperties_value.forEach(onChangeProperty=>{
console.log("api",onChangeProperty)
if(onChangeProperty.purpose == 'api'){ if(onChangeProperty.purpose == 'api'){
if(onChangeProperty.api == 'getListOfStatesAndCities'){ if(onChangeProperty.api == 'getListOfStatesAndCities'){
// console.log(event.value,onChangeProperty.params) // 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))) // console.log(JSON.parse(updatedParams),updatedParams,JSON.parse(JSON.stringify(updatedParams)))
// debugger; // debugger;
let params={records:{state_id:event.value}} let params={records:{state_id:event.value}}
console.log("after",onChangeProperty)
this.quesService.apiCall(onChangeProperty.api,params,onChangeProperty.api_method).subscribe(res=>{ this.quesService.apiCall(onChangeProperty.api,params,onChangeProperty.api_method).subscribe(res=>{
if(res['dataStatus']){ if(res['dataStatus']){
this.local_city=res['records'].cities this.local_city=res['records'].cities
@ -311,7 +310,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
if(onChangeProperty.purpose == 'FORM_CTRL'){ if(onChangeProperty.purpose == 'FORM_CTRL'){
// if(options == 2){ // if(options == 2){
console.log(sec_control)
// debugger; // debugger;
this.creteNewField(onChangeProperty,this.formGroupN,sec_control,sec_index) 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 ?) { 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 ) { 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
for(let index_str of curr_obj.arr_include) { 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) { if(vv.question_key == curr_obj.insert_control) {
vv.is_hidden = true vv.is_hidden = true
}}) }})
console.log("sdfffffffffff",this.whole_json,curr_obj.insert_control);
} }
if(formArray.value.length < 2) { if(formArray.value.length < 2) {
console.log("1 OBJ RETURN")
return; return;
} }
value_index = curr_index-1 value_index = curr_index-1
@ -357,24 +356,24 @@ export class DynamicQuestionTemplateComponent implements OnInit {
value_index = curr_index value_index = curr_index
} }
for(let value of curr_obj.value_keys) { 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] : '' let control_value = formArray.getRawValue()[value_index] ? formArray.getRawValue()[value_index][value] : ''
if(control_value) { if(control_value) {
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) {
console.log("Current index",curr_index,this.json_index)
this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1) this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1)
} }
console.log("No Control RETURN")
return return
} }
} }
} }
if(expression_value) { if(expression_value) {
let calc_exp=eval(expression_value) let calc_exp=eval(expression_value)
console.log(calc_exp)
if(calc_exp){ if(calc_exp){
if(typeof(calc_exp) == 'number'){ if(typeof(calc_exp) == 'number'){
calc_exp = calc_exp.toFixed(2) calc_exp = calc_exp.toFixed(2)
@ -382,7 +381,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
if(curr_obj.insert_control) { if(curr_obj.insert_control) {
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) {
console.log("Current index",curr_index,this.json_index)
this.setModifiedValuetoControl_frommultiple(curr_obj,formArray,curr_index+1) 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 // for setting the modified value to another or same control while field change
setModifiedValuetoControl(curr_obj,form_control_obj,curr_index) { 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){ if(curr_obj && curr_obj.value_keys.length > 0){
let expression_value=curr_obj.expression let expression_value=curr_obj.expression
// curr_obj.value_keys.forEach(val=>{ // 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) 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) == 'string' || typeof(calc_exp) == 'number' ) ){
// if(typeof(calc_exp) == 'number'){ // if(typeof(calc_exp) == 'number'){
// calc_exp = calc_exp.toFixed(2) // calc_exp = calc_exp.toFixed(2)
@ -437,7 +436,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
curr_json = curr_json.question curr_json = curr_json.question
} }
} }
console.log(curr_json);
if(curr_json) { if(curr_json) {
curr_question_obj = curr_json.filter(val=>val.question_key == curr_obj.insert_control) curr_question_obj = curr_json.filter(val=>val.question_key == curr_obj.insert_control)
if(curr_question_obj && curr_question_obj.length > 0) { 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?){ 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){ if(form_control_obj_raw.form_controls.length > 0){
form_control_obj_raw.form_controls.forEach(form_control_obj=>{ form_control_obj_raw.form_controls.forEach(form_control_obj=>{
if(form_control_obj.value_keys != null && form_control_obj.value_keys.length > 0 ){ 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) expression_value=expression_value.split(res).join(control_value_obj)
} }
}) })
console.log("Expression",expression_value)
let calc_exp=eval(expression_value) let calc_exp=eval(expression_value)
console.log("Expression result",calc_exp)
if(calc_exp != false){ if(calc_exp != false){
if(form_control_obj.questions.length > 0){ if(form_control_obj.questions.length > 0){
let question_index_after let question_index_after
@ -484,7 +483,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
question_index_after= arr.indexOf(val) 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 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){ 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 ques_control=this.whole_json
let inserted_control_obj=form_control_obj let inserted_control_obj=form_control_obj
// inserted_control_obj.questions.sort() // inserted_control_obj.questions.sort()
// inserted_control_obj.questions.reverse() // inserted_control_obj.questions.reverse()
console.log("check ddddddddddd",inserted_control_obj.questions)
inserted_control_obj.questions.forEach((val,index)=>{ inserted_control_obj.questions.forEach((val,index)=>{
if(val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { if(val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
if(options == 1) { if(options == 1) {
let check_dup=ques_control.filter(control_key=>control_key.group_key == val.group_key) 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){ if(check_dup.length == 0){
this.formGroupN.addControl(val.group_key,this._fb.array([])) this.formGroupN.addControl(val.group_key,this._fb.array([]))
// val.question.reverse() // val.question.reverse()
@ -524,7 +523,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
inserted_control_obj.questions[index].question = question_temp inserted_control_obj.questions[index].question = question_temp
childControl.push(this._fb.group(control_names)) childControl.push(this._fb.group(control_names))
val.group_questions[0].forEach((group_indi,arr_index)=>{ val.group_questions[0].forEach((group_indi,arr_index)=>{
console.log("sd",childControl)
this.quesService.addAdditionalControl(group_indi, childControl.controls[0], arr_index) 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) { addOrRemoveControl(val,ques_control,question_index_after,options,paren_ques) {
if(options == 1){ if(options == 1){
let check_dup=ques_control.filter(control_key=>control_key.question_key == val.question_key) let check_dup=ques_control.filter(control_key=>control_key.question_key == val.question_key)
console.log(check_dup,this.formGroupN);
// let check_dup = [] // let check_dup = []
if(check_dup.length == 0){ if(check_dup.length == 0){
@ -561,11 +560,11 @@ export class DynamicQuestionTemplateComponent implements OnInit {
this.formGroupN.addControl(val.question_key,new FormControl('')) this.formGroupN.addControl(val.question_key,new FormControl(''))
this.quesService.addAdditionalControl(val, this.formGroupN, question_index_after+1,"") this.quesService.addAdditionalControl(val, this.formGroupN, question_index_after+1,"")
} }
console.log("After adding control",this.whole_json,this.formGroupN,this.whole_form);
} }
} }
else{ else{
console.log("Delete",ques_control)
ques_control.forEach((control_key,index)=>{ ques_control.forEach((control_key,index)=>{
if(paren_ques.hasOwnProperty('is_repeatable') && paren_ques.is_repeatable == '1') { if(paren_ques.hasOwnProperty('is_repeatable') && paren_ques.is_repeatable == '1') {
if(control_key.group_key == paren_ques.group_key){ 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.controls[val.question_key].reset()
this.formGroupN.removeControl(paren_ques.group_key); this.formGroupN.removeControl(paren_ques.group_key);
} }
console.log(this.formGroupN,this.whole_json)
} }
else{ else{
if(control_key.question_key == val.question_key){ if(control_key.question_key == val.question_key){
@ -595,14 +594,14 @@ export class DynamicQuestionTemplateComponent implements OnInit {
this.addOrRemoveControl(val,ques_control,'',2,val) 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){ setValidations_onChange(validation_obj_raw,group_ques,sec_control,sec_index){
if(validation_obj_raw.validations.length > 0){ if(validation_obj_raw.validations.length > 0){
validation_obj_raw.validations.forEach(validation_obj=>{ validation_obj_raw.validations.forEach(validation_obj=>{
console.log("sing",validation_obj)
//FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION //FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION
if(validation_obj.hasOwnProperty('value_keys')){ 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) expression_value=expression_value.split(res).join(validator_value_obj)
// } // }
}) })
console.log("Validation expresseion final ",expression_value)
// validation_obj.value=expression_value // validation_obj.value=expression_value
validation_obj.validator=eval(expression_value) validation_obj.validator=eval(expression_value)
@ -628,7 +627,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
else{ else{
validation_obj.isactive='1' validation_obj.isactive='1'
let validator_single=this.quesService.setValueForValidator(validation_obj) let validator_single=this.quesService.setValueForValidator(validation_obj)
console.log(validator_single)
// // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS // // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS
this.proceedValidationSet(validation_obj,group_ques,sec_control,validator_single) 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] validator_value_obj=this.formGroupN.value[ validation_obj.value]
console.log(validator_value_obj)
validation_obj.validator=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?){ proceedValidationSet(validation_obj,group_ques,sec_control,validator_single?){
let ques_control; let ques_control;
if(validation_obj.validation_to == null){ if(validation_obj.validation_to == null){
console.log("entered",group_ques,sec_control);
ques_control=this.whole_json[this.json_index] ques_control=this.whole_json[this.json_index]
@ -687,7 +686,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
} }
else{ else{
ques_control=this.whole_json[this.json_index] ques_control=this.whole_json[this.json_index]
console.log(ques_control,this.whole_json,this.json_index)
let other_control = ques_control let other_control = ques_control
if(ques_control.hasOwnProperty('is_repeatable') && ques_control.is_repeatable == '2') { if(ques_control.hasOwnProperty('is_repeatable') && ques_control.is_repeatable == '2') {
return; return;
@ -699,7 +698,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
// })[0] // })[0]
// let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name) // let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name)
// updateMsg.push(validation_obj) // updateMsg.push(validation_obj)
console.log("OTHER CONTROL",other_control)
// other_control.controls.answer_value.setValidators(validator_single) // other_control.controls.answer_value.setValidators(validator_single)
// if(validation_obj.isactive == '1'){ // if(validation_obj.isactive == '1'){
// other_control.controls.answer_value.setValidators(validator_single) // other_control.controls.answer_value.setValidators(validator_single)
@ -713,12 +712,12 @@ export class DynamicQuestionTemplateComponent implements OnInit {
// other_control.controls.validations.setValue(updateMsg); // other_control.controls.validations.setValue(updateMsg);
// validation_obj.validator=validator_single // validation_obj.validator=validator_single
let new_validations_obj=this.updateValidationMsg(other_control,validation_obj) 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,'') this.quesService.settingArrayofValidators({validations:new_validations_obj,question_key:validation_obj.validation_to},this.formGroupN,'')
} }
} }
newAnswerCreateDialog(choosed_answer_obj,curr_ques_obj) { newAnswerCreateDialog(choosed_answer_obj,curr_ques_obj) {
console.log(curr_ques_obj,choosed_answer_obj)
if(choosed_answer_obj.is_others == '-1') { if(choosed_answer_obj.is_others == '-1') {
this.formGroupN.get(curr_ques_obj.question_key).setValue('') this.formGroupN.get(curr_ques_obj.question_key).setValue('')
let dialog = this.matDialog.open(AnswerOptionCreateDialogComponent,{ let dialog = this.matDialog.open(AnswerOptionCreateDialogComponent,{
@ -730,10 +729,9 @@ export class DynamicQuestionTemplateComponent implements OnInit {
}) })
dialog.afterClosed().subscribe(rr=>{ dialog.afterClosed().subscribe(rr=>{
if(rr.update && rr.address_for_display && rr.address_for_display.length > 0) { 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.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 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 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) this.formGroupN.get(curr_ques_obj.question_key).patchValue(lastAddress)
} }
@ -744,7 +742,6 @@ export class DynamicQuestionTemplateComponent implements OnInit {
} }
} }
updateValidationMsg(ques_control,validation_obj){ updateValidationMsg(ques_control,validation_obj){
console.log("updae msg",ques_control,validation_obj);
if(!ques_control) { if(!ques_control) {
return; return;
} }

View File

@ -19,11 +19,11 @@ export class QuesFormService {
} }
// FOR CREATING A FORM CONTROL DYNAMICALLY // FOR CREATING A FORM CONTROL DYNAMICALLY
assignFormControl_array(formgroup: FormGroup, ques_data: any) { assignFormControl_array(formgroup: FormGroup, ques_data: any) {
console.log(formgroup, ques_data)
const control: any = formgroup const control: any = formgroup
ques_data.forEach((val, index) => { ques_data.forEach((val, index) => {
console.log("quees", val)
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') { if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
// control.push(this._fb.group({ // control.push(this._fb.group({
// "is_repeatable": [val.is_repeatable || null], // "is_repeatable": [val.is_repeatable || null],
@ -36,7 +36,7 @@ export class QuesFormService {
let childControl: any = control.get(val.group_key) as FormArray let childControl: any = control.get(val.group_key) as FormArray
// childControl.push(this._fb.group({ 'questions': this._fb.array([]) })) // 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 sub_childControl: any = childControl.controls[0].get('questions') as FormArray
let control_names:any={} let control_names:any={}
ques_data[index].group_questions = [] ques_data[index].group_questions = []
@ -82,7 +82,7 @@ export class QuesFormService {
// } // }
// sub_childControl.push(this.createValue(group_indi)) // sub_childControl.push(this.createValue(group_indi))
}) })
console.log(control_names, childControl.at(0));
// debugger // debugger
// val.questions[0]=val.question; // val.questions[0]=val.question;
if(childControl.value.length == 0) { if(childControl.value.length == 0) {
@ -94,14 +94,14 @@ export class QuesFormService {
// control_names[childControl.at(0)] ='' // control_names[childControl.at(0)] =''
let previous_added_controls = childControl.at(0).controls let previous_added_controls = childControl.at(0).controls
control_names = Object.assign(previous_added_controls,control_names) control_names = Object.assign(previous_added_controls,control_names)
console.log(control_names);
// debugger; // debugger;
childControl.setControl(0,this._fb.group(control_names)) childControl.setControl(0,this._fb.group(control_names))
} }
console.log(formgroup.value);
// debugger; // debugger;
val.group_questions[0].forEach((group_indi,arr_index)=>{ 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) { 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)=> { 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) this.addAdditionalControl(child_val, childControl.at(0).get(group_indi.group_key).controls[0], child_index)
@ -120,7 +120,7 @@ export class QuesFormService {
// },500) // },500)
console.log("dd112", formgroup, childControl)
// let key_list=Object.keys(val) // let key_list=Object.keys(val)
// console.log(Object.keys(val)) // console.log(Object.keys(val))
// key_list.forEach(key=>{ // key_list.forEach(key=>{
@ -158,7 +158,7 @@ export class QuesFormService {
} }
else{ else{
this.apiPropertiesCall(val).then(res => { this.apiPropertiesCall(val).then(res => {
console.log("chekc", res)
if (res != false) { if (res != false) {
// val.answers=[] // val.answers=[]
// val.answers=this.convertArrayNames(val.api_properties.fields,res) // 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 // FUNCTIONAL TO HANDLE THE CREATION OF CHILD REPEABLE 2
addLevelTwoControls(curr_obj:any,child_control,group_ques,valQues,group_index) { addLevelTwoControls(curr_obj:any,child_control,group_ques,valQues,group_index) {
console.log(child_control)
// CURR VALUE(MULTI ARRAY) // CURR VALUE(MULTI ARRAY)
const question_temp:any = JSON.parse(JSON.stringify(curr_obj.questions_level_two)); const question_temp:any = JSON.parse(JSON.stringify(curr_obj.questions_level_two));
group_ques[group_index].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].question = question_temp
valQues[group_index].questions_level_two = [] valQues[group_index].questions_level_two = []
valQues[group_index].questions_level_two.push(question_temp) valQues[group_index].questions_level_two.push(question_temp)
console.log(group_ques[group_index],question_temp);
// debugger; // debugger;
let group_key:any = {} let group_key:any = {}
group_key[curr_obj.group_key] = this._fb.array([]) group_key[curr_obj.group_key] = this._fb.array([])
child_control.push(this._fb.group(group_key)) 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; // debugger;
let levelTwoChildCtrl: any = child_control.at(0).get(curr_obj.group_key) as FormArray let levelTwoChildCtrl: any = child_control.at(0).get(curr_obj.group_key) as FormArray
let control_names:any={} let control_names:any={}
curr_obj.questions_level_two[0].forEach((val,arr_index)=>{ curr_obj.questions_level_two[0].forEach((val,arr_index)=>{
console.log("Level 2",val)
val.raw_validations = val.validations val.raw_validations = val.validations
control_names[val.question_key] = '' 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)) levelTwoChildCtrl.push(this._fb.group(control_names))
// console.log(formgroup.value); // console.log(formgroup.value);
@ -292,7 +291,7 @@ export class QuesFormService {
res = res.filter(vv=>vv[filter_properties.key_name] == filter_properties.value) res = res.filter(vv=>vv[filter_properties.key_name] == filter_properties.value)
} }
resolve(res) resolve(res)
console.log(res)
// val.answers=res // val.answers=res
} }
else{ else{
@ -348,7 +347,7 @@ export class QuesFormService {
let answer_value_loc=''; let answer_value_loc='';
let answers_from_client=[] let answers_from_client=[]
if(data_json.hasOwnProperty('answer_value') && data_json.answer_value != '' || null){ 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) let values_for_cli:any = this.getAnswerValue(data_json)
if(values_for_cli.flag == 1){ if(values_for_cli.flag == 1){
answer_value_loc=values_for_cli.values answer_value_loc=values_for_cli.values
@ -371,7 +370,7 @@ export class QuesFormService {
user_det = JSON.parse(user_det); user_det = JSON.parse(user_det);
switch (value_obj.answer_value) { switch (value_obj.answer_value) {
case 'CURRENT_USER': case 'CURRENT_USER':
console.log("current user", user_det)
return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name return_value.values = user_det.user_first_name + ' ' + user_det.user_last_name
break; break;
case "CURRENT_DESIGNATION": case "CURRENT_DESIGNATION":
@ -396,7 +395,7 @@ export class QuesFormService {
// --END OF GETANSWERVALUE FUN // --END OF GETANSWERVALUE FUN
addAdditionalControl(data,curr_control,curr_index,purpose?){ addAdditionalControl(data,curr_control,curr_index,purpose?){
console.log(curr_control);
//FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY //FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY
if(data.type == '5'){ if(data.type == '5'){
// curr_control.controls[curr_index].removeControl('answer_value'); // 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, // FOR SETTING THE ARRAY OF VALIDATORS COMING FROM JSON Temp,
settingArrayofValidators(data,curr_control,curr_index){ settingArrayofValidators(data,curr_control,curr_index){
console.log("entered",data,curr_control);
if(data.hasOwnProperty('validations') && data.validations.length > 0 ){ if(data.hasOwnProperty('validations') && data.validations.length > 0 ){
const validList :any= []; const validList :any= [];
let validator_value let validator_value
@ -469,7 +468,7 @@ export class QuesFormService {
} }
else{ else{
validator_value=this.setValueForValidator(valid) validator_value=this.setValueForValidator(valid)
console.log("cc",validator_value)
} }
validList.push(validator_value); validList.push(validator_value);
@ -482,14 +481,14 @@ export class QuesFormService {
// let val1=`${val}` // let val1=`${val}`
// console.log(typeof(eval(val))) // console.log(typeof(eval(val)))
// console.log(eval(val)) // console.log(eval(val))
console.log(validList)
// curr_control.controls[curr_index].controls.answer_value.setValidators(validList) // curr_control.controls[curr_index].controls.answer_value.setValidators(validList)
if(curr_control.controls[data.question_key]) { if(curr_control.controls[data.question_key]) {
curr_control.controls[data.question_key].setValidators(validList) curr_control.controls[data.question_key].setValidators(validList)
console.log("ddvdeeqq",validList)
curr_control.controls[data.question_key].updateValueAndValidity() curr_control.controls[data.question_key].updateValueAndValidity()
} }
console.log("after setting validators",curr_control.controls[data.question_key])
// debugger; // debugger;
} }
} }
@ -525,7 +524,7 @@ export class QuesFormService {
else{ else{
fy.push({fy_year:year-2+'-'+(year-1),curr:year-1}) fy.push({fy_year:year-2+'-'+(year-1),curr:year-1})
} }
console.log(fy)
for(let i=0;i<=2;i++){ for(let i=0;i<=2;i++){
fy.push({fy_year:(fy[i].curr-2)+'-'+(fy[i].curr-1),curr:fy[i].curr-1}) 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 // FOR CREATING THE CORRECT VALIDATION
setValueForValidator(value_obj){ setValueForValidator(value_obj){
console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator))
let return_value let return_value
if(value_obj != null && value_obj.hasOwnProperty('validator')){ if(value_obj != null && value_obj.hasOwnProperty('validator')){
switch(value_obj.name) switch(value_obj.name)

View File

@ -60,7 +60,7 @@ export class FormComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
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()
@ -68,10 +68,11 @@ export class FormComponent implements OnInit {
else{ else{
this.getExcelData(); this.getExcelData();
} }
this.loadTemplate()
} }
loadTemplate() { loadTemplate() {
// 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=>{
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} 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=>{ this.pdTriggerService.loadCreditPDTemplate(params).subscribe(result=>{
@ -87,7 +88,7 @@ export class FormComponent implements OnInit {
question_template =JSON.parse(question_template.template); question_template =JSON.parse(question_template.template);
this.commonFormGroup = new FormGroup({}) this.commonFormGroup = new FormGroup({})
this.questions_JSON = question_template; this.questions_JSON = question_template;
console.log(this.questions_JSON); // console.log(this.questions_JSON);
// setTimeout(() => { // setTimeout(() => {
// this.covidAnswers = null // this.covidAnswers = null
// console.log("cleared") // console.log("cleared")
@ -108,7 +109,7 @@ export class FormComponent implements OnInit {
question_template =JSON.parse(question_template.template); question_template =JSON.parse(question_template.template);
this.commonFormGroup = new FormGroup({}) this.commonFormGroup = new FormGroup({})
this.questions_JSON = question_template; this.questions_JSON = question_template;
console.log(this.questions_JSON); // console.log(this.questions_JSON);
// setTimeout(() => { // setTimeout(() => {
// this.covidAnswers = null // this.covidAnswers = null
// console.log("cleared") // 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') { 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"} // 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(()=>{ // setTimeout(()=>{
// this.commonFormGroup.patchValue(data) // this.commonFormGroup.patchValue(data)
@ -159,7 +160,7 @@ export class FormComponent implements OnInit {
// formValues[val.key_name] = val.value // formValues[val.key_name] = val.value
// } // }
// }) // })
console.log(formValues) // console.log(formValues)
// debugger; // debugger;
if(re_uploaded && re_uploaded == '1') { if(re_uploaded && re_uploaded == '1') {
this.commonFormGroup.patchValue(formValues) this.commonFormGroup.patchValue(formValues)
@ -176,7 +177,7 @@ export class FormComponent implements OnInit {
}) })
} }
getLocalFormId() { getLocalFormId() {
console.log(this.pd_all_details) // console.log(this.pd_all_details)
switch(this.pd_all_details.form_id) { switch(this.pd_all_details.form_id) {
case '5': case '5':
return 2 return 2
@ -216,7 +217,7 @@ export class FormComponent implements OnInit {
// this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index // this.myStepper.selectedIndex = this.stepperInfo[index].stepper_index
// } // }
for (const name in <any>(this.commonFormGroup.controls)) { for (const name in <any>(this.commonFormGroup.controls)) {
console.log(this.commonFormGroup.controls[name],name) // console.log(this.commonFormGroup.controls[name],name)
if (this.commonFormGroup.controls[name].invalid) { if (this.commonFormGroup.controls[name].invalid) {
invalid.push(name); invalid.push(name);
let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid')); let invalidFields = [].slice.call(document.getElementsByClassName('ng-invalid'));