Fairoj : autocomple field added in dynamic question template and final remarks issue fixed
This commit is contained in:
parent
4a55269567
commit
fbeb5b28ce
@ -19,6 +19,31 @@
|
||||
{{validation.message}}</mat-error>
|
||||
</ng-container>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width:100%"
|
||||
*ngIf="parent_ques.type == '9'">
|
||||
<mat-label>{{parent_ques.question}}</mat-label>
|
||||
<input matInput [type]="parent_ques.field_type == 'num' || parent_ques.field_type == 'numtoword' ? 'number' : parent_ques.field_type== 'string' ? 'text' : parent_ques.field_type"
|
||||
[formControlName]="parent_ques.question_key" [placeholder]="parent_ques.place_holder"
|
||||
(change)="onChangeProperty($event,parent_ques,parent_ques.question_key)"
|
||||
[matAutocomplete]="auto">
|
||||
<mat-autocomplete #auto="matAutocomplete">
|
||||
<mat-option *ngFor="let val of autoCompleteAns | async" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer"
|
||||
>
|
||||
<span>{{val.answer}}</span>
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
<mat-hint
|
||||
*ngIf="formGroupN.value[parent_ques.question_key] != '' && parent_ques.field_type == 'numtoword'"
|
||||
align="end" style="font-size: 12px;">{{"₹"}} {{formGroupN.value[parent_ques.question_key] | numberToWords}}
|
||||
</mat-hint>
|
||||
<!-- <mat-hint align="end" style="font-size: 11.5px;color: gray;" *ngIf="parent_ques.get('is_amt_in_words').value == true">One Lack</mat-hint> -->
|
||||
<ng-container *ngFor="let validation of parent_ques.validations" ngProjectAs="mat-error">
|
||||
<mat-error align="end" *ngIf="formGroupN.get(parent_ques.question_key).hasError(validation.name.toLowerCase())">
|
||||
{{validation.message}}</mat-error>
|
||||
</ng-container>
|
||||
</mat-form-field>
|
||||
|
||||
<!-- <mat-form-field> -->
|
||||
<div class="radio-gap" *ngIf="parent_ques.type == '2'">
|
||||
<mat-label>{{parent_ques.question}}</mat-label><br />
|
||||
|
||||
@ -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<string[]>
|
||||
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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<any> {
|
||||
@ -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
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user