template qustions changes : kdk
This commit is contained in:
parent
e3decf18df
commit
8876f65e19
@ -87,15 +87,15 @@ export class TemplatesService {
|
||||
|
||||
getTemplateIDQuesAnsDetails(temp_id: number): Observable<any>{
|
||||
// Add safe, URL encoded search parameter if there is a search term
|
||||
return this._http.post<any[]>(this.apiUrl + "getTemplateQuestionAnswers", {'template_id': temp_id });
|
||||
return this._http.post<any[]>(this.apiUrl + "getScorecardDetails", {'templateid': temp_id });
|
||||
}
|
||||
|
||||
|
||||
updateTempateIDQuesAnsDetails(Records: any): Observable<any>{
|
||||
let records = Records.map(item=>{
|
||||
item.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record
|
||||
item.updatedon = currentdate;
|
||||
item.createdon = item.createdon == null ? currentdate : item.createdon;
|
||||
// item.updatedon = currentdate;
|
||||
// item.createdon = item.createdon == null ? currentdate : item.createdon;
|
||||
item.fk_createdby = item.fk_createdby == null ? this._aws.getlocale() : item.fk_createdby;
|
||||
|
||||
// item.answers = item.answers.map(subItem=>{
|
||||
@ -104,7 +104,7 @@ export class TemplatesService {
|
||||
// })//to get Current date and Time for when the Record is created
|
||||
return item;
|
||||
});
|
||||
return this._http.post<any[]>(this.apiUrl + "saveTemplateQuestionAnswers", {'records': records });
|
||||
return this._http.post<any[]>(this.apiUrl + "saveScoreCardQuestions", {'records': records });
|
||||
}
|
||||
|
||||
getRemaningQuestionCategory(data: any): Observable<any>{
|
||||
@ -112,12 +112,14 @@ export class TemplatesService {
|
||||
return this._http.post<any[]>(this.apiUrl + "getQuestionsForTemplateCreation", {"template_id": data.template_id, "category_id": data.category_id});
|
||||
}
|
||||
|
||||
|
||||
getFormIdRemainingQuestionsDetails(data: any) : Observable<any> {
|
||||
let records = {"templateid": data.template_id, "formid": data.form_id, "categoryid": data.category_id};
|
||||
return this._http.post<any[]>(this.apiUrl + "getFormAndQuestionKeys", { "records" : records} );
|
||||
}
|
||||
|
||||
// get Master Details ==============================
|
||||
|
||||
|
||||
// get templates master details list
|
||||
// get templates master details list
|
||||
getLenderMasterListDetails(): Observable<any> {
|
||||
return this._http.get<any[]>(this.apiUrl + "getListOfLenders");
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
|
||||
|
||||
|
||||
<form [formGroup]="_editquestionAnswerForm" (submit)="onSubmit()">
|
||||
<div formArrayName="temp_questions" class="example-full-width" style="font-size:1.2rem !important;">
|
||||
<table style="width:100%">
|
||||
@ -11,12 +14,12 @@
|
||||
</div>
|
||||
<div fxFlex="1 1 auto" class="ml-xs" fxFlex="20%">
|
||||
<mat-form-field style="width: 35%; text-align: center" appearance="outline">
|
||||
<input matInput formControlName="question_weightage">
|
||||
<input matInput formControlName="weightage">
|
||||
</mat-form-field> <span> % </span>
|
||||
<mat-error *ngIf="submitted && ques['controls'].question_weightage.hasError('required')" class="mat-text-warn">Ques. WT is Required.!</mat-error>
|
||||
<mat-error *ngIf="submitted && ques['controls'].weightage.hasError('required')" class="mat-text-warn">Ques. WT is Required.!</mat-error>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="10%">
|
||||
<button (click)="removeLanguage(i)" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"
|
||||
<button (click)="removeLanguage(i, $event); false;" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"
|
||||
type="button"><mat-icon>delete</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
@ -28,7 +31,7 @@
|
||||
<div fxLayout="row" fxLayout.xs="column" fxLayoutGap="0.5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="1 1 auto" class="ml-xs" fxFlex="80%">
|
||||
<div>
|
||||
<span> {{i_ans+1}}. </span><span style="color:#f44336">{{answ.get('answer').value}}</span>
|
||||
<span> {{i_ans+1}}. </span><span style="color:#f44336">{{answ.get('name').value}}</span>
|
||||
</div>
|
||||
<!--<mat-form-field>
|
||||
<input matInput formControlName="answer">
|
||||
@ -36,12 +39,12 @@
|
||||
</div>
|
||||
<div fxFlex="1 1 auto" class="ml-xs" fxFlex="20%">
|
||||
<mat-form-field style="padding: 0 !important; margin: 0 !important; width: 45px !important; text-align: center;">
|
||||
<input matInput formControlName="template_answer_weightage">
|
||||
<input matInput formControlName="score">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
<mat-error *ngIf="submitted && answ['controls'].template_answer_weightage.hasError('required')" class="mat-text-warn">Score Required.!</mat-error>
|
||||
<mat-error *ngIf="submitted && answ['controls'].score.hasError('required')" class="mat-text-warn">Score Required.!</mat-error>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -32,6 +32,7 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
countries = ['d', 'd', 'd', 'd', 'd', 'd'];
|
||||
regularDistribution = 100 / 3;
|
||||
|
||||
|
||||
@Input() CaterogyQuesAns: any;
|
||||
|
||||
_editquestionAnswerForm: FormGroup;
|
||||
@ -83,37 +84,65 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
}
|
||||
|
||||
setModelFirstFormDate(record) {
|
||||
// let val = record;
|
||||
// let vals = {
|
||||
// question_id: val.question_id,
|
||||
// question: val.question,
|
||||
// template_question_id: val.template_question_id,
|
||||
// fk_template_id: val.fk_template_id == null ? this.CaterogyQuesAns.fk_template_id : val.fk_template_id,
|
||||
// fk_question_id: val.fk_question_id == null ? val.question_id : val.fk_question_id,
|
||||
// question_weightage: val.question_weightage,
|
||||
// fk_template_question_category_id: val.fk_template_question_category_id == null ? this.CaterogyQuesAns.fk_question_category_id : val.fk_template_question_category_id,
|
||||
// question_answerable_by: val.question_answerable_by,
|
||||
// isactive: val.isactive == null ? 1 : val.isactive,
|
||||
// answers: val.answers
|
||||
// };
|
||||
|
||||
let val = record;
|
||||
let vals = {
|
||||
question_id: val.question_id,
|
||||
question_key_mapping_id: val.question_key_mapping_id,
|
||||
fk_form_id: val.fk_form_id,
|
||||
question: val.question,
|
||||
template_question_id: val.template_question_id,
|
||||
fk_template_id: val.fk_template_id == null ? this.CaterogyQuesAns.fk_template_id : val.fk_template_id,
|
||||
fk_question_id: val.fk_question_id == null ? val.question_id : val.fk_question_id,
|
||||
question_weightage: val.question_weightage,
|
||||
fk_template_question_category_id: val.fk_template_question_category_id == null ? this.CaterogyQuesAns.fk_question_category_id : val.fk_template_question_category_id,
|
||||
question_answerable_by: val.question_answerable_by,
|
||||
isactive: val.isactive == null ? 1 : val.isactive,
|
||||
answers: val.answers
|
||||
score_question_id: val.score_question_id == null ? val.question_id : val.score_question_id,
|
||||
fk_key: val.fk_key == null ? val.key : val.fk_key,
|
||||
weightage: val.weightage,
|
||||
isactive: val.isactive == null ? 1 : val.isactive
|
||||
};
|
||||
if(record.answers !== undefined){
|
||||
vals['answers'] = val.answers;
|
||||
}
|
||||
this.addLanguage(vals, null);
|
||||
}
|
||||
|
||||
setFirstFormDate(record) {
|
||||
if (record.length > 0) {
|
||||
for (let val of record) {
|
||||
let vals = {
|
||||
question_id: val.question_id,
|
||||
question: val.question,
|
||||
template_question_id: val.template_question_id,
|
||||
fk_template_id: val.fk_template_id == null ? this.CaterogyQuesAns.fk_template_id : val.fk_template_id,
|
||||
fk_question_id: val.fk_question_id == null ? val.question_id : val.fk_question_id,
|
||||
question_weightage: val.question_weightage,
|
||||
fk_template_question_category_id: val.fk_template_question_category_id == null ? this.CaterogyQuesAns.fk_template_question_category_id : val.fk_template_question_category_id,
|
||||
question_answerable_by: val.question_answerable_by,
|
||||
isactive: val.isactive == null ? 1 : val.isactive,
|
||||
answers: val.answers
|
||||
};
|
||||
// let vals = {
|
||||
// question_id: val.question_id,
|
||||
// question: val.question,
|
||||
// template_question_id: val.template_question_id,
|
||||
// fk_template_id: val.fk_template_id == null ? this.CaterogyQuesAns.fk_template_id : val.fk_template_id,
|
||||
// fk_question_id: val.fk_question_id == null ? val.question_id : val.fk_question_id,
|
||||
// question_weightage: val.question_weightage,
|
||||
// fk_template_question_category_id: val.fk_template_question_category_id == null ? this.CaterogyQuesAns.fk_template_question_category_id : val.fk_template_question_category_id,
|
||||
// question_answerable_by: val.question_answerable_by,
|
||||
// isactive: val.isactive == null ? 1 : val.isactive,
|
||||
// answers: val.answers
|
||||
// };
|
||||
let vals = {
|
||||
question_key_mapping_id: val.question_key_mapping_id,
|
||||
fk_form_id: val.fk_form_id,
|
||||
question: val.question,
|
||||
fk_template_id: val.fk_template_id == null ? this.CaterogyQuesAns.fk_template_id : val.fk_template_id,
|
||||
score_question_id: val.score_question_id == null ? val.question_id : val.score_question_id,
|
||||
fk_key: val.fk_key == null ? val.key : val.fk_key,
|
||||
weightage: val.weightage,
|
||||
isactive: val.isactive == null ? 1 : val.isactive
|
||||
};
|
||||
if(val.answers !== undefined){
|
||||
vals['answers'] = val.answers;
|
||||
}
|
||||
this.addLanguage(vals, null);
|
||||
}
|
||||
}
|
||||
@ -122,13 +151,12 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
setAnswers(record, i) {
|
||||
for (let val of record) {
|
||||
let vals = {
|
||||
question_answer_id: val.question_answer_id,
|
||||
answer: val.answer,
|
||||
template_answer_weightage_id: val.template_answer_weightage_id,
|
||||
fk_template_question_id: val.fk_template_question_id,
|
||||
fk_question_answer_id: val.fk_question_answer_id == null ? val.question_answer_id : val.fk_question_answer_id,
|
||||
template_answer_weightage: val.template_answer_weightage,
|
||||
template_answer_remark: val.template_answer_remark,
|
||||
id: val.id,
|
||||
name: val.name,
|
||||
answer: val.answer == null ? val.id : val.answer,
|
||||
score: val.score,
|
||||
fk_score_question_id: val.fk_score_question_id,
|
||||
score_answer_id: val.score_answer_id,
|
||||
isactive: val.isactive
|
||||
};
|
||||
this.addAnswerData(vals, null, i);
|
||||
@ -145,12 +173,12 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
|
||||
initAnswerData(data) {
|
||||
return this._formBuilder.group({
|
||||
id: [data.id],
|
||||
name: [data.name],
|
||||
answer: [data.answer],
|
||||
template_answer_weightage_id: [data.template_answer_weightage_id],
|
||||
fk_template_question_id: [data.fk_template_question_id],
|
||||
fk_question_answer_id: [data.fk_question_answer_id],
|
||||
template_answer_weightage: [data.template_answer_weightage, Validators.compose([Validators.required])],
|
||||
template_answer_remark: [data.template_answer_remark],
|
||||
score: [data.score, Validators.compose([Validators.required])],
|
||||
fk_score_question_id: [data.fk_score_question_id],
|
||||
score_answer_id: [data.score_answer_id],
|
||||
isactive: [data.isactive]
|
||||
});
|
||||
}
|
||||
@ -160,15 +188,14 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
// Dynamic Form field creation Functionality : START ===>
|
||||
initAnswers(data) {
|
||||
return this._formBuilder.group({
|
||||
question_id: [data.question_id],
|
||||
question_key_mapping_id: [data.question_key_mapping_id],
|
||||
fk_form_id: [data.fk_form_id],
|
||||
question: [data.question],
|
||||
template_question_id: [data.template_question_id],
|
||||
fk_template_id: [data.fk_template_id],
|
||||
fk_question_id: [data.fk_question_id],
|
||||
question_weightage: [data.question_weightage, Validators.compose([Validators.required])],
|
||||
fk_template_question_category_id: [data.fk_template_question_category_id],
|
||||
score_question_id: [data.score_question_id],
|
||||
weightage: [data.weightage, Validators.compose([Validators.required])],
|
||||
fk_key: [data.fk_key],
|
||||
isactive: [data.isactive],
|
||||
question_answerable_by: [data.question_answerable_by],
|
||||
answers: this._formBuilder.array([
|
||||
// this.setAnswers(data.answers)
|
||||
])
|
||||
@ -189,16 +216,20 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
} else {
|
||||
const control = <FormArray>this._editquestionAnswerForm.controls['temp_questions'];
|
||||
control.push(this.initAnswers(data));
|
||||
this.setAnswers(data.answers, control.length - 1);
|
||||
if(data.answers !== undefined) {
|
||||
this.setAnswers(data.answers, control.length - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// =========== : END
|
||||
|
||||
|
||||
removeLanguage(inx) {
|
||||
removeLanguage(inx, e) {
|
||||
e.stopPropagation();
|
||||
// let value = <FormArray>this._editquestionAnswerForm.controls['temp_questions'].indexOf(inx);
|
||||
let value = (<FormArray>this._editquestionAnswerForm.controls['temp_questions']).at(inx).get('template_question_id').value;
|
||||
if (value == null) {
|
||||
let value = (<FormArray>this._editquestionAnswerForm.controls['temp_questions']).at(inx).get('question_key_mapping_id').value;
|
||||
|
||||
if (value !== null) {
|
||||
const control = <FormArray>this._editquestionAnswerForm.controls['temp_questions'];
|
||||
control.removeAt(inx);
|
||||
} else {
|
||||
@ -219,7 +250,7 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
|
||||
|
||||
let val = formValues.temp_questions;
|
||||
let totalScore = val.map(value => { return Number(value.question_weightage); }).reduce((acc, value) => { return acc + value; }, 0);
|
||||
let totalScore = val.map(value => { return Number(value.weightage); }).reduce((acc, value) => { return acc + value; }, 0);
|
||||
|
||||
if (totalScore == 100) {
|
||||
if (!this.checkDuplicateInObject(formValues.temp_questions)) {
|
||||
@ -255,7 +286,7 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
inputArray.map((item, index) => {
|
||||
let currentVal = inputArray[index];
|
||||
for (let i = index + 1; i < inputArray.length; i++) {
|
||||
if (currentVal.question_id === inputArray[i].question_id) {
|
||||
if (currentVal.question_key_mapping_id === inputArray[i].question_key_mapping_id) {
|
||||
console.log('duplication: ' + i);
|
||||
this.dublicateRerdIndex = i;
|
||||
seenDuplicate = true;
|
||||
@ -277,15 +308,37 @@ export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
],
|
||||
templateUrl: './dialog-category-question-list.html'
|
||||
})
|
||||
export class DialogOverviewExampleDialog {
|
||||
export class DialogOverviewExampleDialog implements OnInit {
|
||||
|
||||
public m_questions: any;
|
||||
|
||||
public m_question_forms: any;
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<DialogOverviewExampleDialog>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: DialogData,
|
||||
private templatesService: TemplatesService,
|
||||
private mastersService: MastersService) {
|
||||
this.getCategoryRemainingQuesMasters();
|
||||
// this.getCategoryRemainingQuesMasters();
|
||||
this.getPdFormListMaster();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
//Called after the constructor, initializing input properties, and the first call to ngOnChanges.
|
||||
//Add 'implements OnInit' to the class.
|
||||
|
||||
// this.m_question_forms = [{
|
||||
// "form_id" : "1",
|
||||
// "form_name" : "Form 1"
|
||||
// },{
|
||||
// "form_id" : "2",
|
||||
// "form_name" : "Form 2"
|
||||
// },{
|
||||
// "form_id" : "3",
|
||||
// "form_name" : "Form 3"
|
||||
// },{
|
||||
// "form_id" : "4",
|
||||
// "form_name" : "Form 4"
|
||||
// }]
|
||||
}
|
||||
|
||||
onNoClick(ques): void {
|
||||
@ -295,8 +348,11 @@ export class DialogOverviewExampleDialog {
|
||||
errorRecord: string;
|
||||
noRecordFound: boolean;
|
||||
|
||||
getCategoryRemainingQuesMasters() {
|
||||
this.templatesService.getRemaningQuestionCategory(this.data).subscribe(
|
||||
getCategoryRemainingQuesMasters(form_id) {
|
||||
let data = this.data;
|
||||
data['form_id'] = form_id;
|
||||
this.m_questions = [];
|
||||
this.templatesService.getFormIdRemainingQuestionsDetails(data).subscribe(
|
||||
data => {
|
||||
if (data.status === 200 && data.dataStatus) {
|
||||
this.noRecordFound = true;
|
||||
@ -311,4 +367,24 @@ export class DialogOverviewExampleDialog {
|
||||
);
|
||||
}
|
||||
|
||||
getPdFormListMaster() {
|
||||
this.mastersService.getAllMasterData('PDFORMS').subscribe(
|
||||
data => {
|
||||
if (data.status === 200 && data.dataStatus) {
|
||||
this.noRecordFound = true;
|
||||
this.m_question_forms = data.records;
|
||||
} else {
|
||||
this.noRecordFound = false;
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.noRecordFound = true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
selectedFormTypes(e) {
|
||||
this.getCategoryRemainingQuesMasters(e.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,22 @@
|
||||
<div style="max-height: 480px;">
|
||||
<div *ngIf="noRecordFound">
|
||||
<mat-card class="listHover" style="width: 580px; padding: 6px;" *ngFor="let question of m_questions">
|
||||
<span (click)="onNoClick(question)">{{question.question}}</span>
|
||||
<mat-dialog-content class="mat-typography">
|
||||
|
||||
<mat-card style="width: 580px; min-height: 120px; padding: 6px;">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Forms List *" (selectionChange)="selectedFormTypes($event)">
|
||||
<mat-option *ngFor="let forms of m_question_forms" [value]="forms.form_id">{{ forms.pd_form_name }}</mat-option>
|
||||
</mat-select>
|
||||
<!--<mat-error *ngIf="submitted && answ['controls'].fk_lender_id.hasError('required')" class="mat-text-warn">Lender Type Required.!</mat-error>-->
|
||||
</mat-form-field>
|
||||
|
||||
<div style="max-height: 480px;">
|
||||
<div *ngIf="noRecordFound">
|
||||
<mat-card class="listHover" style="width: 480px; padding: 6px;" *ngFor="let question of m_questions">
|
||||
<span (click)="onNoClick(question)">{{question.question}}</span>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div *ngIf="!noRecordFound" style="width: 320px;">
|
||||
<h5 style="color: red;">No Records Found.!</h5>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div *ngIf="!noRecordFound" style="width: 320px;">
|
||||
<h5 style="color: red;">No Records Found.!</h5>
|
||||
</div>
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
Loading…
Reference in New Issue
Block a user