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.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html index 05a11f623..176fd02f3 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/dynamic-form/dynamic-question-template/dynamic-question-template.component.html @@ -19,6 +19,31 @@ {{validation.message}} + + + {{parent_ques.question}} + + + + {{val.answer}} + + + {{"₹"}} {{formGroupN.value[parent_ques.question_key] | numberToWords}} + + + + + {{validation.message}} + + +
{{parent_ques.question}}
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 2a21fa810..099848b76 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 @@ -1,6 +1,8 @@ import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormArray, FormControl } from '@angular/forms'; import { QuesFormService } from '../ques-form/ques-form.service'; +import { startWith, map } from 'rxjs/operators'; +import { Observable } from 'rxjs'; @Component({ selector: 'app-dynamic-question-template', @@ -18,9 +20,17 @@ export class DynamicQuestionTemplateComponent implements OnInit { @Input() json_answers:any; local_city: any; local_pincode: any; + autoCompleteAns:Observable constructor(private quesService:QuesFormService) { } - ngOnInit() {} + ngOnInit() { + if(this.parent_ques.type == '9' && this.parent_ques.answers && this.parent_ques.answers.length > 0) { + this.autoCompleteAns =this.formGroupN.get(this.parent_ques.question_key).valueChanges.pipe( + startWith(''), + map(value => this.autoCompleteFilter(value)) + ) + } + } ngOnChanges() { this.parent_ques = this.currFormArrayObj @@ -28,7 +38,7 @@ export class DynamicQuestionTemplateComponent implements OnInit { 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(()=>{ - 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.formGroupN.get(this.parent_ques.question_key).patchValue(this.json_answers[this.parent_ques.question_key]) @@ -38,6 +48,16 @@ export class DynamicQuestionTemplateComponent implements OnInit { },700) } } + autoCompleteFilter(value:string): string[] { + if(value) { + const filterValue = value.toLowerCase(); + + return this.parent_ques.answers.filter(option => option.answer.toLowerCase().indexOf(filterValue) === 0); + } + else { + return this.parent_ques.answers + } + } onChange_checkbox(event,sec_control){ console.log(event,sec_control) const control=this.formGroupN.get(sec_control.question_key) as FormArray diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts index 010e9d10b..c9aacb7f7 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.ts @@ -234,6 +234,9 @@ export class FinalRemarksComponent implements OnInit { recommendationPositiveCtrl.push(this.CreateRecommendationPositive(objs)); }); } + else { + this.addRecommendationPositive() + } if (data.records.recommendation_refer_to_credit.length > 0) { let recommendationReferToCredit: any = this._finalRemarkForm.get('recommendation_refer_to_credit') as FormArray; data.records.recommendation_refer_to_credit.forEach((val, index) => { @@ -241,6 +244,9 @@ export class FinalRemarksComponent implements OnInit { recommendationReferToCredit.push(this.CreateRecommendationReferToCredit(objs)); }); } + else { + this.addRecommendationReferToCredit() + } if (data.records.recommendation_negative.length > 0) { let recommendationNegativeCtrl: any = this._finalRemarkForm.get('recommendation_negative') as FormArray; data.records.recommendation_negative.forEach((val, index) => { @@ -248,6 +254,9 @@ export class FinalRemarksComponent implements OnInit { recommendationNegativeCtrl.push(this.CreateRecommendationNegative(objs)); }); } + else { + this.addRecommendationNegative() + } this._finalRemarkForm.controls.is_service_provided.setValue(data.records.is_service_provided); diff --git a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts index fde0cf085..42fbb3731 100755 --- a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts @@ -360,9 +360,7 @@ export class PdTrigerService { catchError(this.handleError('operation', [])) ) } - loadCreditPDTemplate(params) { - return this._http.post(this.apiUrl+'loadCreditPDTemplate', params) - } + // load PD question answers getAnswersForPD(list: any): Observable { @@ -957,4 +955,16 @@ export class PdTrigerService { covid19Ques() { return this._http.get('../../../assets/sample_covid19_ques.json') } + + loadCreditPDTemplate(params) { + return this._http.post(this.apiUrl+'loadCreditPDTemplate', params) + + // dummy data + // return this._http.get('../../../assets/sample_covid19_ques.json').map(result=>{ + // console.log(result) + // let apivalue ={dataStatus:true,records:{template:JSON.stringify(result)}} + // console.log(apivalue) + // return apivalue + // }) + } } diff --git a/ng6-seed/src/assets/sample_covid19_ques.json b/ng6-seed/src/assets/sample_covid19_ques.json index 3f418f3bf..b4d884221 100644 --- a/ng6-seed/src/assets/sample_covid19_ques.json +++ b/ng6-seed/src/assets/sample_covid19_ques.json @@ -3,318 +3,11 @@ "section_name":"Covid 19 Questions", "onsubmit":null, "questions":[ - { - - "question":"State", - "question_key":"state", - "type":"3", - "answers":null, - "api_properties":{ - "api":"getListOfMaster", - "api_method":"POST", - "params":{ - "master_name":"STATE" - }, - "fields":[ - "state_id", - "name" - ] - }, - "onchange_properties":[ - { - "purpose":"api", - "api":"getListOfStatesAndCities", - "api_method":"POST", - "params":{"records":{"state_id":"value_of_answer"}}, - "fields":[ - "state_id", - "name" - ], - "local_variable":"local_city" - } - ], - "is_repeatable":null, - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"State Required", - "value":null - } - ] - }, - { - "question":"City", - "question_key":"city", - "type":"3", - "answers":null, - "api_properties":"local_city", - "onchange_properties":null, - "is_repeatable":null, - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"CIty Required", - "value":null - } - ] - }, - { - "question":[ - { - "question":"Name", - "question_key":"name", - "place_holder":"Enter text", - "type":"1", - "api_properties":null, - "answers":null, - "onchange_properties":null, - "is_repeatable":null, - "field_type":"string", - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Name Required", - "value":null - }, - { - "name":"pattern", - "isactive":"1", - "validator":"[A-Za-z ]*", - "message":"alphabets only ", - "value":null - } - ] - }, - { - "question":"Share Holding (%)", - "question_key":"share_holding", - "place_holder":"Enter number", - "type":"1", - "api_properties":null, - "answers":null, - "onchange_properties":null, - "is_repeatable":null, - "field_type":"num", - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Share value Required", - "value":null - }, - { - "name":"max", - "validator":"100", - "isactive":"1", - "message":"Number must be less than 100", - "value":null - } - ] - }, - { - "question":"Vintage in Current Business", - "question_key":"vintage_in_current_biz", - "place_holder":"Enter in years", - "type":"1", - "api_properties":null, - "answers":null, - "is_repeatable":null, - "field_type":"num", - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Current vintage Required", - "value":null - }, - { - "name":"pattern", - "isactive":"1", - "validator":"[0-9]{0,3}", - "message":"Year should be 3 digit", - "value":null - } - ], - "onchange_properties":[ - { - "purpose":"validations", - "validations":[ - { - "name":"max", - "isactive":"1", - "validator":"", - "message":"should be less or equal to Total Work Exp", - "value":"total_work_exp", - "validation_to":null, - "value_keys":null - } - ] - }, - { - "purpose":"FORM_CTRL", - "form_controls":[ - { - "insert_index":"total_work_exp", - "expression":"(total_work_exp > vintage_in_current_biz)", - "value_keys":[ - "total_work_exp", - "vintage_in_current_biz" - ], - "questions":[ - { - "question_key":"previous_experience_details", - "question":"Previous Experience Details", - "place_holder":"Enter text", - "type":"1", - "api_properties":null, - "answers":null, - "onchange_properties":null, - "is_repeatable":null, - "field_type":"string", - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Previous Experience Required", - "value":null - } - ] - } - ] - } - ] - } - ] - }, - { - "question":"Total Work Exp", - "question_key":"total_work_exp", - "place_holder":"Enter in years", - "type":"1", - "api_properties":null, - "answers":null, - "is_repeatable":null, - "field_type":"num", - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Total experience Required", - "value":null - }, - { - "name":"maxLength", - "isactive":"1", - "validator":"2", - "message":"Year should be two digit", - "value":null - } - ], - "onchange_properties":[ - { - "purpose":"validations", - "validations":[ - { - "name":"min", - "isactive":"1", - "validator":"", - "message":"should be greater or equal to current work exp", - "value":"vintage_in_current_biz", - "validation_to":null, - "value_keys":null - } - ] - }, - { - "purpose":"FORM_CTRL", - "form_controls":[ - { - "insert_index":"total_work_exp", - "expression":"(total_work_exp > vintage_in_current_biz)", - "value_keys":[ - "total_work_exp", - "vintage_in_current_biz" - ], - "questions":[ - { - "question":"Previous Experience Details", - "question_key":"previous_experience_details", - "place_holder":"Enter text", - "type":"1", - "api_properties":null, - "answers":null, - "onchange_properties":null, - "is_repeatable":null, - "field_type":"string", - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Previous Experience Required", - "value":null - } - ] - } - ] - } - ] - } - ] - }, - { - "question":"Started Business", - "question_key":"started_biz", - "type":"3", - "api_properties":null, - "onchange_properties":null, - "is_repeatable":null, - "answers":[ - { - "answer_id":"Yes", - "answer":"Yes", - "subfield_key":"", - "subfield_caption":"", - "subfield_type":"" - }, - { - "answer_id":"No", - "answer":"No", - "subfield_key":"", - "subfield_caption":"", - "subfield_type":"" - } - ], - "validations":[ - { - "name":"required", - "isactive":"1", - "validator":"Validators.required", - "message":"Started Business Required", - "value":null - } - ] - } - ], - "is_repeatable":"1", - "group_title":"Details of Key Stakeholders in the Business", - "group_key":"section_3" - }, { - "question":" Is your business adversely impacted by coronavirus outbreak? ", + "question":" Is your business adversely impacted by coronavirus outbreak ?", "question_key":"business_impacted_by_covid19", "type":"2", - "field_width":"45", + "field_width":"100", "answers":[ { "answer_id":"Yes", @@ -338,18 +31,16 @@ ], "questions":[ { - "question":"Choose any one", + "question":"Choose any", "question_key":"business_impacted_by_covid19_Yes", - "type":"3", - "field_width":"45", + "place_holder":"", + "field_type":"string", + "type":"9", + "field_width":"100", "api_properties":null, "onchange_properties":null, "is_repeatable":null, "answers":[ - { - "answer_id":"", - "answer":"Select" - }, { "answer_id":"Employees/labour not available", "answer":"Employees/labour not available" @@ -392,18 +83,16 @@ ], "questions":[ { - "question":"Choose any one", + "question":"Choose any", "question_key":"business_impacted_by_covid19_No", - "type":"3", - "field_width":"45", + "place_holder":"", + "field_type":"string", + "type":"9", + "field_width":"100", "api_properties":null, "onchange_properties":null, "is_repeatable":null, "answers":[ - { - "answer_id":"", - "answer":"Select" - }, { "answer_id":"Business falls under essential services like chemist", "answer":"Business falls under essential services like chemist" @@ -443,7 +132,7 @@ "question":" Did you avail the loan moratorium facility on your existing loans which is extended by your bank or financial institution? ", "question_key":"avail_loan_moratorium_facility", "type":"2", - "field_width":"45", + "field_width":"100", "onchange_properties":[], "api_properties":null, "answers":[ @@ -471,7 +160,7 @@ "question":"Are you planning to avail/ or already availed any loan or any other term facility for your business or personal use?", "question_key":"avail_any_loan", "type":"2", - "field_width":"45", + "field_width":"100", "api_properties":null, "answers":[ { @@ -495,7 +184,7 @@ ], "questions":[ { - "question":"Please specify amount,lender etc.", + "question":"Please specify amount, lender etc.", "question_key":"avail_any_loan_Yes", "type":"7", "field_width":"100", @@ -533,7 +222,7 @@ "question_key":"sales_or_revenue_amt", "place_holder":"Enter amount", "type":"1", - "field_width":"45", + "field_width":"100", "answers":null, "api_properties":null, "is_repeatable":null, @@ -552,7 +241,7 @@ "question":"Is turnover mentioned above validated?", "question_key":"mentioned_turover_validated", "type":"2", - "field_width":"45", + "field_width":"100", "api_properties":null, "answers":[ { @@ -576,20 +265,22 @@ ], "questions":[ { - "question":"Choose any one", + "question":"Choose any", "question_key":"mentioned_turover_validated_Yes", - "type":"3", - "field_width":"45", + "place_holder":"", + "field_type":"string", + "type":"9", + "field_width":"100", "api_properties":null, "onchange_properties":null, "is_repeatable":null, "answers":[ + { + "answer_id":"Bills", + "answer":"Bills" + }, { - "answer_id":"", - "answer":"Select" - }, - { - "answer_id":"Bills", + "answer_id":"Gst returns", "answer":"Gst returns" }, {