templates edit screens added : kdk
This commit is contained in:
parent
4a66e305c0
commit
6154d876e4
41
ng6-seed/package-lock.json
generated
41
ng6-seed/package-lock.json
generated
@ -4273,8 +4273,7 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -4295,14 +4294,12 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -4317,20 +4314,17 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -4447,8 +4441,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -4460,7 +4453,6 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -4475,7 +4467,6 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -4483,14 +4474,12 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
@ -4509,7 +4498,6 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -4590,8 +4578,7 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -4603,7 +4590,6 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -4689,8 +4675,7 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -4726,7 +4711,6 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -4746,7 +4730,6 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -4790,14 +4773,12 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,9 +1,121 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { of } from 'rxjs';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
/** Imported Service Files Are., */
|
||||
import { AwsService } from '../../../AwsService/aws.service';
|
||||
/** Consant Value For Created Date And Updated Date */
|
||||
const currentdate = new Date().toJSON().slice(0, 19).replace('T', ' ');
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TemplatesService {
|
||||
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
|
||||
|
||||
constructor(private _http: HttpClient,
|
||||
private _aws: AwsService) { }
|
||||
|
||||
// get templates master details list
|
||||
getTemplatesMasterListDetails(cid: any): Observable<any> {
|
||||
// Add safe, URL encoded search parameter if there is a search term
|
||||
const options = cid ?
|
||||
{ params: new HttpParams().set('cid', cid) } : {};
|
||||
return this._http.get<any[]>(this.apiUrl + "listAllTemplates/any", options);
|
||||
}
|
||||
|
||||
getTemplateIDNameDetails(temp_id: number): Observable<any>{
|
||||
// Add safe, URL encoded search parameter if there is a search term
|
||||
return this._http.post<any[]>(this.apiUrl + "getTemplateMaster", {'template_id': temp_id });
|
||||
}
|
||||
|
||||
updateTempateIDNameDetails(Records: any): Observable<any>{
|
||||
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record
|
||||
Records.updatedon = currentdate;//to get Current date and Time for when the Record is created
|
||||
return this._http.post<any[]>(this.apiUrl + "saveNewTemplateName", {'records': Records });
|
||||
}
|
||||
|
||||
getTemplateIDLenderDetails(temp_id: number): Observable<any>{
|
||||
// Add safe, URL encoded search parameter if there is a search term
|
||||
return this._http.post<any[]>(this.apiUrl + "getTemplateLenders", {'template_id': temp_id });
|
||||
}
|
||||
|
||||
updateTempateIDLenderDetails(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;//to get Current date and Time for when the Record is created
|
||||
return item;
|
||||
});
|
||||
return this._http.post<any[]>(this.apiUrl + "saveTemplateLenderDetails", {'records': records });
|
||||
}
|
||||
|
||||
|
||||
getTemplateIDCategoryDetails(temp_id: number): Observable<any>{
|
||||
// Add safe, URL encoded search parameter if there is a search term
|
||||
return this._http.post<any[]>(this.apiUrl + "getTemplateCategories", {'template_id': temp_id });
|
||||
}
|
||||
|
||||
updateTempateIDCategoryDetails(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;//to get Current date and Time for when the Record is created
|
||||
return item;
|
||||
});
|
||||
return this._http.post<any[]>(this.apiUrl + "saveTemplateCategoryDetails", {'records': records });
|
||||
}
|
||||
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
|
||||
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.answers = item.answers.map(subItem=>{
|
||||
// subItem.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record
|
||||
// subItem.updatedon = currentdate;
|
||||
// })//to get Current date and Time for when the Record is created
|
||||
return item;
|
||||
});
|
||||
return this._http.post<any[]>(this.apiUrl + "saveTemplateQuestionAnswers", {'records': records });
|
||||
}
|
||||
|
||||
getRemaningQuestionCategory(data: any): Observable<any>{
|
||||
// Add safe, URL encoded search parameter if there is a search term
|
||||
return this._http.post<any[]>(this.apiUrl + "getQuestionsForTemplateCreation", {"template_id": data.template_id, "category_id": data.category_id});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// get Master Details ==============================
|
||||
|
||||
|
||||
// get templates master details list
|
||||
getLenderMasterListDetails(): Observable<any> {
|
||||
return this._http.get<any[]>(this.apiUrl + "getListOfLenders");
|
||||
}
|
||||
|
||||
getProductsMasterListDetails(): Observable<any> {
|
||||
return this._http.get<any[]>(this.apiUrl + "getListOfProducts ");
|
||||
}
|
||||
|
||||
getCustomerSegmentsMasterListDetails(): Observable<any> {
|
||||
return this._http.get<any[]>(this.apiUrl + "getListOfCustomerSegments");
|
||||
}
|
||||
|
||||
getCategoryMasterListDetails(): Observable<any> {
|
||||
return this._http.get<any[]>(this.apiUrl + "getListOfCategories");
|
||||
}
|
||||
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
|
||||
@ -1,16 +1,20 @@
|
||||
|
||||
<!--<pre>{{ templateCategoryRecord | json }}</pre>
|
||||
<pre> {{ m_category | json}}</pre>-->
|
||||
|
||||
<form [formGroup]="_editTempCategoryFrom" (submit)="onSubmit()">
|
||||
<div formArrayName="temp_category" class="example-full-width">
|
||||
<mat-list role="list">
|
||||
<mat-list-item style="margin: 2px 0;" *ngFor="let answ of _editTempCategoryFrom.controls.temp_category['controls']; let i=index ; let last = last;"
|
||||
role="listitem">
|
||||
<div [formGroupName]="i">
|
||||
<table>
|
||||
<tr *ngFor="let answ of _editTempCategoryFrom.controls.temp_category['controls']; let i=index ; let last = last;">
|
||||
<td>
|
||||
<div [formGroupName]="i">
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Category" formControlName="fk_category_id">
|
||||
<mat-option *ngFor="let category of m_categoryList" [value]="category.fk_category_id">{{ category.name }}</mat-option>
|
||||
<mat-select placeholder="Category" formControlName="fk_question_category_id">
|
||||
<mat-option *ngFor="let category of m_category" [value]="category.question_category_id">{{ category.category_name }}</mat-option>
|
||||
</mat-select>
|
||||
<!--<mat-error *ngIf="submitted && f.fk_category_id.hasError('required')" class="mat-text-warn">You must Select Lender Type.</mat-error>-->
|
||||
<mat-error *ngIf="submitted && i == dublicateRerdIndex "> This Category Already Exist.!</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
@ -23,13 +27,46 @@
|
||||
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<button *ngIf="last" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Add More" matTooltipPosition="above" (click)="addLanguage($event); false"><mat-icon>add</mat-icon></button>
|
||||
<button *ngIf="last" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Add More" matTooltipPosition="above" (click)="addLanguage(null, $event); false"><mat-icon>add</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
<mat-error *ngIf="submitted && i == dublicateRerdIndex "> This Category Already Exist.!</mat-error>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!--<mat-card role="list">-->
|
||||
<!--<mat-card style="width: 70%;" *ngFor="let answ of _editTempCategoryFrom.controls.temp_category['controls']; let i=index ; let last = last;"
|
||||
role="listitem">
|
||||
<div [formGroupName]="i">
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Category" formControlName="fk_question_category_id">
|
||||
<mat-option *ngFor="let category of m_category" [value]="category.question_category_id">{{ category.category_name }}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && i == dublicateRerdIndex "> This Category Already Exist.!</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field style="width: 25%; text-align: center" appearance="outline">
|
||||
<input matInput formControlName="weightage">
|
||||
</mat-form-field> <span>%</span>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<button *ngIf="_editTempCategoryFrom.controls.temp_category.controls.length > 1" (click)="removeLanguage(i)" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
|
||||
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<button *ngIf="last" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Add More" matTooltipPosition="above" (click)="addLanguage(null, $event); false"><mat-icon>add</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<mat-error *ngIf="submitted && i == dublicateRerdIndex "> This Category Already Exist.!</mat-error>
|
||||
</mat-card>-->
|
||||
<!--</mat-card>-->
|
||||
</div>
|
||||
<div class="row" style="text-align:right;">
|
||||
<!--<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>-->
|
||||
|
||||
@ -1,85 +1,191 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy, Input } from '@angular/core';
|
||||
import { Component, ViewChild, OnInit, OnDestroy, Input, AfterViewInit } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
|
||||
import { FormGroup, FormControl, FormBuilder, Validators , FormArray} from '@angular/forms';
|
||||
import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { TemplatesService } from './../../../../service/templates/templates.service';
|
||||
import { MastersService } from './../../../../service/masters/masters.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-template-edit-category',
|
||||
templateUrl: './edit-category.component.html',
|
||||
styleUrls: ['./edit-category.component.scss']
|
||||
})
|
||||
export class EditCategoryComponent implements OnInit, OnDestroy {
|
||||
export class EditCategoryComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
|
||||
@Input() questionId: number;
|
||||
@Input() questionId: number;
|
||||
|
||||
public _editTempCategoryFrom: FormGroup;
|
||||
public submitted = false;
|
||||
public templateCategoryRecord: any;
|
||||
|
||||
public m_category: any;
|
||||
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
|
||||
constructor(
|
||||
private _formBuilder: FormBuilder,
|
||||
public dialog: MatDialog) {
|
||||
notifier: NotifierService,
|
||||
private templatesService: TemplatesService,
|
||||
private mastersService: MastersService,
|
||||
private _formBuilder: FormBuilder) {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.initalLoadFormData();
|
||||
if(this.categoryList.length > 0){
|
||||
for (let val of this.categoryList) {
|
||||
// alert(JSON.stringify(val));
|
||||
let vals = val;
|
||||
this.addLanguage(vals['fk_category_id'], vals['name'], vals['weightage'], null);
|
||||
}
|
||||
}
|
||||
this.initalLoadFormData();
|
||||
this.getCategoryMasters();
|
||||
this.getTemplateCategoryDetails();
|
||||
|
||||
this._editTempCategoryFrom = this._formBuilder.group({
|
||||
temp_category: this._formBuilder.array([
|
||||
// this.initAnswers(),
|
||||
])
|
||||
})
|
||||
|
||||
// if(this.categoryList.length > 0){
|
||||
// for (let val of this.categoryList) {
|
||||
// // alert(JSON.stringify(val));
|
||||
// let vals = val;
|
||||
// this.addLanguage(vals['fk_category_id'], vals['name'], vals['weightage'], null);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
initalLoadFormData(){
|
||||
ngAfterViewInit() {
|
||||
// this.getTemplateCategoryDetails();
|
||||
}
|
||||
|
||||
setFormDatas(record) {
|
||||
if (record.length > 0) {
|
||||
for (let val of record) {
|
||||
let vals = {
|
||||
template_category_weightage_id: val.template_category_weightage_id,
|
||||
fk_question_category_id: val.fk_question_category_id,
|
||||
fk_template_id: val.fk_template_id,
|
||||
weightage: val.weightage,
|
||||
isactive: val.isactive,
|
||||
};
|
||||
this.addLanguage(vals, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Dynamic Form field creation Functionality : START ===>
|
||||
initAnswers(data) {
|
||||
return this._formBuilder.group({
|
||||
template_category_weightage_id: [data.template_category_weightage_id],
|
||||
fk_question_category_id: [data.fk_question_category_id, Validators.compose([Validators.required])],
|
||||
fk_template_id: [data.fk_template_id],
|
||||
weightage: [data.weightage, Validators.compose([Validators.required])],
|
||||
isactive: [data.isactive],
|
||||
});
|
||||
}
|
||||
addLanguage(data, e) {
|
||||
if (data == null) {
|
||||
let newDate = {
|
||||
template_category_weightage_id: null,
|
||||
fk_template_id: this.questionId,
|
||||
fk_question_category_id: null,
|
||||
weightage: null,
|
||||
isactive: 1,
|
||||
}
|
||||
const control = <FormArray>this._editTempCategoryFrom.controls['temp_category'];
|
||||
control.push(this.initAnswers(newDate));
|
||||
} else {
|
||||
const control = <FormArray>this._editTempCategoryFrom.controls['temp_category'];
|
||||
control.push(this.initAnswers(data));
|
||||
}
|
||||
}
|
||||
|
||||
getTemplateCategoryDetails() {
|
||||
this.templatesService.getTemplateIDCategoryDetails(this.questionId).subscribe(
|
||||
data => {
|
||||
if (data) {
|
||||
if (data.records) {
|
||||
this.templateCategoryRecord = data.records;
|
||||
this.setFormDatas(this.templateCategoryRecord);
|
||||
// this.templateListData = data.records;
|
||||
// this.dataLength = data.records.length;
|
||||
// this.dataSource.data = this.templateListData;
|
||||
} else {
|
||||
// this.noTemplateLendersFound = true;
|
||||
}
|
||||
} else {
|
||||
// this.noTemplateLendersFound = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getCategoryMasters() {
|
||||
this.templatesService.getCategoryMasterListDetails().subscribe(
|
||||
data => {
|
||||
this.m_category = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Category Master Records Found.!');
|
||||
// this.m_category = "No Category Master Records Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
initalLoadFormData() {
|
||||
this._editTempCategoryFrom = this._formBuilder.group({
|
||||
temp_category: this._formBuilder.array([
|
||||
temp_category: this._formBuilder.array([
|
||||
// this.initAnswers(),
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
// convenience getter for easy access to form fields
|
||||
// convenience getter for easy access to form fields
|
||||
get f() { return this._editTempCategoryFrom.controls; }
|
||||
|
||||
public m_categoryList = [{
|
||||
fk_category_id: 1,
|
||||
name: 'Category List 1',
|
||||
weightage: 2,
|
||||
},{
|
||||
fk_category_id: 2,
|
||||
name: 'Category List 2',
|
||||
weightage: 5,
|
||||
},{
|
||||
fk_category_id: 3,
|
||||
name: 'Category List 2',
|
||||
weightage: 5,
|
||||
public m_categoryList = [{
|
||||
fk_category_id: 1,
|
||||
name: 'Category List 1',
|
||||
weightage: 2,
|
||||
}, {
|
||||
fk_category_id: 2,
|
||||
name: 'Category List 2',
|
||||
weightage: 5,
|
||||
}, {
|
||||
fk_category_id: 3,
|
||||
name: 'Category List 2',
|
||||
weightage: 5,
|
||||
}];
|
||||
|
||||
public categoryList = [{
|
||||
fk_category_id: 1,
|
||||
name: 'Category List 1',
|
||||
weightage: 2,
|
||||
},{
|
||||
fk_category_id: 2,
|
||||
name: 'Category List 2',
|
||||
weightage: 5,
|
||||
fk_category_id: 1,
|
||||
name: 'Category List 1',
|
||||
weightage: 2,
|
||||
}, {
|
||||
fk_category_id: 2,
|
||||
name: 'Category List 2',
|
||||
weightage: 5,
|
||||
}];
|
||||
|
||||
// Dynamic Form field creation Functionality : START ===>
|
||||
initAnswers(fk_cat_id, name, weightage) {
|
||||
return this._formBuilder.group({
|
||||
fk_category_id: [fk_cat_id, Validators.compose([Validators.required])],
|
||||
name: [name, Validators.compose([Validators.required])],
|
||||
weightage: [weightage, Validators.compose([Validators.required])],
|
||||
});
|
||||
}
|
||||
addLanguage(fk_cat_id, name, weightage, e) {
|
||||
const control = <FormArray>this._editTempCategoryFrom.controls['temp_category'];
|
||||
control.push(this.initAnswers(fk_cat_id, name, weightage));
|
||||
}
|
||||
// Dynamic Form field creation Functionality : START ===>
|
||||
// initAnswers(fk_cat_id, name, weightage) {
|
||||
// return this._formBuilder.group({
|
||||
// fk_category_id: [fk_cat_id, Validators.compose([Validators.required])],
|
||||
// name: [name, Validators.compose([Validators.required])],
|
||||
// weightage: [weightage, Validators.compose([Validators.required])],
|
||||
// });
|
||||
// }
|
||||
// addLanguage(fk_cat_id, name, weightage, e) {
|
||||
// const control = <FormArray>this._editTempCategoryFrom.controls['temp_category'];
|
||||
// control.push(this.initAnswers(fk_cat_id, name, weightage));
|
||||
// }
|
||||
removeLanguage(i: number) {
|
||||
const control = <FormArray>this._editTempCategoryFrom.controls['temp_category'];
|
||||
control.removeAt(i);
|
||||
@ -87,11 +193,71 @@ export class EditCategoryComponent implements OnInit, OnDestroy {
|
||||
|
||||
// END ===>
|
||||
|
||||
|
||||
public errorMessage: string;
|
||||
|
||||
/** To Save/Edited Popup Data */
|
||||
onSubmit() {
|
||||
this.submitted = true;
|
||||
// stop here if form is invalid
|
||||
if (this._editTempCategoryFrom.invalid) {
|
||||
alert('no');
|
||||
return;
|
||||
} else {
|
||||
var formValues = this._editTempCategoryFrom.value;
|
||||
//To Remove The "Null" With Key also
|
||||
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
|
||||
|
||||
let val = formValues.temp_category;
|
||||
|
||||
let totalScore = val.map(value => { return Number(value.weightage); }).reduce((acc, value) => { return acc + value; }, 0);
|
||||
|
||||
if (totalScore == 100) {
|
||||
if (!this.checkDuplicateInObject(formValues.temp_category)) {
|
||||
this.templatesService.updateTempateIDCategoryDetails(formValues.temp_category).subscribe(
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
console.log(dataresult);
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
const arr = <FormArray>this._editTempCategoryFrom.controls.temp_category;
|
||||
arr.controls.splice(0);
|
||||
this.getTemplateCategoryDetails();
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Something Wents Wrong Try Again.!";
|
||||
}
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Some Thing Wents Wrong Try Again.!";
|
||||
});
|
||||
} else {
|
||||
alert("duplication records occured.!");
|
||||
}
|
||||
} else {
|
||||
alert("value should equal to 100")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public dublicateRerdIndex = -1;
|
||||
|
||||
checkDuplicateInObject(inputArray) {
|
||||
this.dublicateRerdIndex = -1;
|
||||
let seenDuplicate = false;
|
||||
|
||||
inputArray.map((item, index) => {
|
||||
let currentVal = inputArray[index];
|
||||
for(let i = index+1 ; i < inputArray.length ; i++ ){
|
||||
if(currentVal.fk_question_category_id === inputArray[i].fk_question_category_id){
|
||||
console.log('duplication: ' + i);
|
||||
this.dublicateRerdIndex = i;
|
||||
seenDuplicate = true;
|
||||
}
|
||||
}
|
||||
console.log(index);
|
||||
});
|
||||
return seenDuplicate;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
<!--<pre>{{ templateLenderRecord | json}}</pre>
|
||||
|
||||
<pre> {{ m_lender | json}} </pre>
|
||||
<pre> {{ m_product | json}} </pre>
|
||||
<pre> {{ m_customerSegment | json}} </pre>-->
|
||||
|
||||
|
||||
<form [formGroup]="_editTempLenderFrom" (submit)="onSubmit()">
|
||||
<div formArrayName="temp_lender" class="example-full-width">
|
||||
<div *ngFor="let answ of _editTempLenderFrom.controls.temp_lender['controls']; let i=index">
|
||||
@ -5,39 +12,38 @@
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="0.5%" fxLayoutAlign="start center">
|
||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-select placeholder="Lender" formControlName="fk_lender_id">
|
||||
<mat-option *ngFor="let enti of entityOptions" [value]="enti.fk_lender_id">{{ enti.name }}</mat-option>
|
||||
<mat-option *ngFor="let lend of m_lender" [value]="lend.entity_id">{{ lend.full_name }}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.fk_lender_id.hasError('required')" class="mat-text-warn">You must Select Lender Type.</mat-error>
|
||||
<!--<mat-error *ngIf="submitted && fk_lender_id.hasError('required')" class="mat-text-warn">You must Select Lender Type.</mat-error>-->
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-select placeholder="Product" formControlName="fk_product_id">
|
||||
<mat-option *ngFor="let enti of entityOptions" [value]="enti.fk_product_id">{{ enti.name }}</mat-option>
|
||||
<mat-option *ngFor="let prcd of m_product" [value]="prcd.product_id">{{ prcd.product_name }}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.fk_product_id.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error>
|
||||
<!--<mat-error *ngIf="submitted && fk_product_id.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error>-->
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-select placeholder="Catergory Segment" formControlName="fk_category_segment_id">
|
||||
<mat-option *ngFor="let enti of entityOptions" [value]="enti.fk_category_segment_id">{{ enti.name }}</mat-option>
|
||||
<mat-select placeholder="Customer Segment" formControlName="fk_customer_segment">
|
||||
<mat-option *ngFor="let cusSeg of m_customerSegment" [value]="cusSeg.customer_segment_id">{{ cusSeg.customer_segment }}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="submitted && f.fk_category_segment_id.hasError('required')" class="mat-text-warn">You must Select Category Segment.</mat-error>
|
||||
<!--<mat-error *ngIf="submitted && fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error>-->
|
||||
</mat-form-field>
|
||||
|
||||
<!--<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||
<input matInput placeholder="Email" formControlName="contact_email">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
|
||||
<input matInput placeholder="Mobile Number" formControlName="contact_mobile_no">
|
||||
</mat-form-field>-->
|
||||
|
||||
<div>
|
||||
<mat-checkbox *ngIf="answ.get('template_lender_map_id').value != null" formControlName="isactive" [ngModel]="answ.get('isactive').value == 1 ? true : answ.get('isactive').value == 0 ? false : null"
|
||||
(ngModelChange)="answ.get('isactive').value = $event ? 1 : 0"></mat-checkbox>
|
||||
|
||||
<span *ngIf="_editTempLenderFrom.controls.temp_lender.controls.length > 1" (click)="removeLanguage(i)">
|
||||
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
|
||||
<button *ngIf="answ.get('template_lender_map_id').value == null" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button mat-fab class="mr-1 mb-1" color="primary" matTooltip="Add More Contact Person" matTooltipPosition="above" (click)="addLanguage($event); false"><mat-icon>add</mat-icon></button>
|
||||
<button mat-fab class="mr-1 mb-1" color="primary" matTooltip="Add More Contact Person" matTooltipPosition="above" (click)="addLanguage(null, $event); false"><mat-icon>add</mat-icon></button>
|
||||
</div>
|
||||
<div class="row" style="text-align:right;">
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
|
||||
@ -5,6 +5,11 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { TemplatesService } from './../../../../service/templates/templates.service';
|
||||
import { MastersService } from './../../../../service/masters/masters.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-template-edit-lender',
|
||||
templateUrl: './edit-lender.component.html',
|
||||
@ -14,20 +19,115 @@ export class EditLenderComponent implements OnInit {
|
||||
|
||||
|
||||
@Input() questionId: number;
|
||||
public noTemplateLendersFound: boolean;
|
||||
public templateLenderRecord: any;
|
||||
public errorMessage;
|
||||
|
||||
public m_lender : any;
|
||||
public m_product: any;
|
||||
public m_customerSegment : any;
|
||||
|
||||
public _editTempLenderFrom: FormGroup;
|
||||
public submitted = false;
|
||||
|
||||
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier : NotifierService;
|
||||
|
||||
constructor(
|
||||
notifier: NotifierService,
|
||||
private templatesService: TemplatesService,
|
||||
private mastersService: MastersService,
|
||||
private _formBuilder: FormBuilder) {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this._editTempLenderFrom = this._formBuilder.group({
|
||||
this.getTemplateLenderDetails();
|
||||
this.getLenderMasters();
|
||||
this.getProductsMasters();
|
||||
this.getCustomerSegmentMasters();
|
||||
|
||||
this._editTempLenderFrom = this._formBuilder.group({
|
||||
temp_lender: this._formBuilder.array([
|
||||
this.initAnswers(),
|
||||
// this.initAnswers(),
|
||||
])
|
||||
})
|
||||
}
|
||||
setFormDatas(record){
|
||||
if (record.length > 0) {
|
||||
for (let val of record) {
|
||||
let vals = {
|
||||
template_lender_map_id: val.template_lender_map_id,
|
||||
fk_template_id: val.fk_template_id,
|
||||
fk_lender_id: val.fk_lender_id,
|
||||
fk_product_id: val.fk_product_id,
|
||||
fk_customer_segment: val.fk_customer_segment,
|
||||
isactive: val.isactive,
|
||||
};
|
||||
this.addLanguage(vals, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getTemplateLenderDetails(){
|
||||
this.templatesService.getTemplateIDLenderDetails(this.questionId).subscribe(
|
||||
data => {
|
||||
if (data) {
|
||||
if (data.records) {
|
||||
this.noTemplateLendersFound = false;
|
||||
this.templateLenderRecord = data.records;
|
||||
this.setFormDatas(this.templateLenderRecord);
|
||||
// this.templateListData = data.records;
|
||||
// this.dataLength = data.records.length;
|
||||
// this.dataSource.data = this.templateListData;
|
||||
} else {
|
||||
this.noTemplateLendersFound = true;
|
||||
}
|
||||
} else {
|
||||
this.noTemplateLendersFound = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getLenderMasters(){
|
||||
this.templatesService.getLenderMasterListDetails().subscribe(
|
||||
data => {
|
||||
this.m_lender = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Lender Master Records Found.!');
|
||||
this.errorMessage = "No Lender Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getProductsMasters(){
|
||||
this.templatesService.getProductsMasterListDetails().subscribe(
|
||||
data => {
|
||||
this.m_product = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Products Master Records Found.!');
|
||||
this.errorMessage = "No Products Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getCustomerSegmentMasters() {
|
||||
this.templatesService.getCustomerSegmentsMasterListDetails().subscribe(
|
||||
data => {
|
||||
this.m_customerSegment = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Customer Segment Master Records Found.!');
|
||||
this.errorMessage = "No Customer Segment Master Record Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// convenience getter for easy access to form fields
|
||||
get f() { return this._editTempLenderFrom.controls; }
|
||||
@ -42,16 +142,32 @@ export class EditLenderComponent implements OnInit {
|
||||
}];
|
||||
|
||||
// Dynamic Form field creation Functionality : START ===>
|
||||
initAnswers() {
|
||||
initAnswers(data) {
|
||||
return this._formBuilder.group({
|
||||
fk_lender_id: ['', Validators.compose([Validators.required])],
|
||||
fk_product_id: ['', Validators.compose([Validators.required])],
|
||||
fk_category_segment_id: ['', Validators.compose([Validators.required])],
|
||||
template_lender_map_id: [data.template_lender_map_id],
|
||||
fk_template_id: [data.fk_template_id],
|
||||
fk_lender_id: [data.fk_lender_id, Validators.compose([Validators.required])],
|
||||
fk_product_id: [data.fk_product_id , Validators.compose([Validators.required])],
|
||||
fk_customer_segment: [data.fk_customer_segment, Validators.compose([Validators.required])],
|
||||
isactive: [data.isactive],
|
||||
});
|
||||
}
|
||||
addLanguage(e) {
|
||||
const control = <FormArray>this._editTempLenderFrom.controls['temp_lender'];
|
||||
control.push(this.initAnswers());
|
||||
addLanguage(data, e) {
|
||||
if(data == null){
|
||||
let newDate = {
|
||||
template_lender_map_id: null,
|
||||
fk_template_id: this.questionId,
|
||||
fk_lender_id: null,
|
||||
fk_product_id: null,
|
||||
fk_customer_segment: null,
|
||||
isactive: 1,
|
||||
}
|
||||
const control = <FormArray>this._editTempLenderFrom.controls['temp_lender'];
|
||||
control.push(this.initAnswers(newDate));
|
||||
} else {
|
||||
const control = <FormArray>this._editTempLenderFrom.controls['temp_lender'];
|
||||
control.push(this.initAnswers(data));
|
||||
}
|
||||
}
|
||||
removeLanguage(i: number) {
|
||||
const control = <FormArray>this._editTempLenderFrom.controls['temp_lender'];
|
||||
@ -65,6 +181,57 @@ export class EditLenderComponent implements OnInit {
|
||||
onSubmit() {
|
||||
this.submitted = true;
|
||||
// stop here if form is invalid
|
||||
if (this._editTempLenderFrom.invalid) {
|
||||
this.errorMessage = "Please Fill All Mandate Fields.";
|
||||
return;
|
||||
} else {
|
||||
var formValues = this._editTempLenderFrom.value;
|
||||
//To Remove The "Null" With Key also
|
||||
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
|
||||
// alert(JSON.stringify(formValues.temp_lender));
|
||||
|
||||
if(!this.checkDuplicateInObject(formValues.temp_lender)) {
|
||||
this.templatesService.updateTempateIDLenderDetails(formValues.temp_lender).subscribe(
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
console.log(dataresult);
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
const arr = <FormArray>this._editTempLenderFrom.controls.temp_lender;
|
||||
arr.controls.splice(0);
|
||||
this.getTemplateLenderDetails();
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Something Wents Wrong Try Again.!";
|
||||
}
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Some Thing Wents Wrong Try Again.!";
|
||||
});
|
||||
} else {
|
||||
alert("duplication records occured.!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkDuplicateInObject(inputArray) {
|
||||
let seenDuplicate = false;
|
||||
|
||||
inputArray.map(function(item, index) {
|
||||
let currentVal = inputArray[index];
|
||||
for(let i = index+1 ; i < inputArray.length ; i++ ){
|
||||
if(currentVal.fk_lender_id === inputArray[i].fk_lender_id
|
||||
&& currentVal.fk_product_id === inputArray[i].fk_product_id
|
||||
&& currentVal.fk_customer_segment === inputArray[i].fk_customer_segment){
|
||||
console.log('duplication: ' + i);
|
||||
seenDuplicate = true;
|
||||
}
|
||||
}
|
||||
console.log(index);
|
||||
});
|
||||
return seenDuplicate;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
@ -0,0 +1,102 @@
|
||||
<!--<mat-card>
|
||||
|
||||
<form [formGroup]="_editquestionAnswerForm" (submit)="onSubmit()">
|
||||
<div formArrayName="temp_category" class="example-full-width">
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel *ngFor="let data of CaterogyQuesAns">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
{{ data.category_name }}
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
{{ data.weightage }}
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<app-category-question-answer [CaterogyQuesAns]="data">
|
||||
</app-category-question-answer>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card>-->
|
||||
|
||||
|
||||
<!--<pre>{{ templateCategoryRecord | json }}</pre>-->
|
||||
<!--<pre> {{ CaterogyQuesAns | json}}</pre>-->
|
||||
<div fxLayout="row" fxLayoutAlign="end">
|
||||
<button mat-fab class="mr-1 mb-1" color="primary" matTooltip="Add More Contact Person" matTooltipPosition="above" (click)="openDialog(); false"><mat-icon>add</mat-icon></button>
|
||||
</div>
|
||||
<form [formGroup]="_editquestionAnswerForm" (submit)="onSubmit()">
|
||||
<div formArrayName="temp_questions" class="example-full-width">
|
||||
<table>
|
||||
<tr *ngFor="let ques of _editquestionAnswerForm.controls.temp_questions['controls']; let i=index ; let last = last;">
|
||||
<td>
|
||||
<div [formGroupName]="i">
|
||||
<mat-card>
|
||||
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="1 1 auto" class="ml-xs" fxFlex="60%">
|
||||
<label>{{ques.get('question').value}}</label>
|
||||
</div>
|
||||
<div fxFlex="1 1 auto" class="ml-xs" fxFlex="20%">
|
||||
<mat-form-field style="width: 25%; text-align: center" appearance="outline">
|
||||
<input matInput formControlName="question_weightage">
|
||||
</mat-form-field> <span>%</span>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="20%">
|
||||
<button (click)="removeLanguage(i)" 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>
|
||||
</mat-card>
|
||||
<div formArrayName="answers" class="example-full-width">
|
||||
|
||||
<!--<div class="container" fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5%" fxLayoutAlign="center">-->
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="0.5%" fxLayoutAlign="center"
|
||||
*ngFor="let answ of ques['controls'].answers['controls']; let i_ans = index ; let Ans_last = last;">
|
||||
<div [formGroupName]="i_ans">
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field>
|
||||
<!--<label>{{answ.get('answer').value}}</label>-->
|
||||
<input matInput formControlName="answer">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field style="width: 25%; text-align: center" appearance="outline">
|
||||
<input matInput formControlName="template_answer_weightage">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--</div>-->
|
||||
|
||||
<!--<div class="container" fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5%" fxLayoutAlign="center"
|
||||
*ngFor="let answ of ques['controls'].answers['controls']; let i_ans = index ; let Ans_last = last;">
|
||||
<div [formGroupName]="i_ans">
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field>
|
||||
<input matInput formControlName="answer">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field style="width: 25%; text-align: center" appearance="outline">
|
||||
<input matInput formControlName="template_answer_weightage">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<mat-error *ngIf="submitted && i == dublicateRerdIndex "> This Category Already Exist.!</mat-error>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row" style="text-align:right;">
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
</div>
|
||||
</form>
|
||||
@ -0,0 +1,8 @@
|
||||
.container {
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.card-picture {
|
||||
width: 23%;
|
||||
margin-bottom: 2%;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CategoryQuestionAnswerComponent } from './category-question-answer.component';
|
||||
|
||||
describe('CategoryQuestionAnswerComponent', () => {
|
||||
let component: CategoryQuestionAnswerComponent;
|
||||
let fixture: ComponentFixture<CategoryQuestionAnswerComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CategoryQuestionAnswerComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CategoryQuestionAnswerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,316 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy, Input, Inject } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material';
|
||||
import { FormGroup, FormControl, FormBuilder, Validators , FormArray} from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { TemplatesService } from './../../../../../service/templates/templates.service';
|
||||
import { MastersService } from './../../../../../service/masters/masters.service';
|
||||
|
||||
export interface DialogData {
|
||||
animal: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-category-question-answer',
|
||||
templateUrl: './category-question-answer.component.html',
|
||||
styleUrls: ['./category-question-answer.component.scss']
|
||||
})
|
||||
export class CategoryQuestionAnswerComponent implements OnInit {
|
||||
|
||||
@Input() CaterogyQuesAns: any;
|
||||
|
||||
_editquestionAnswerForm: FormGroup;
|
||||
|
||||
public panelOpenState : boolean;
|
||||
// secondFormGroup: FormGroup;
|
||||
|
||||
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
|
||||
constructor(
|
||||
notifier: NotifierService,
|
||||
private templatesService: TemplatesService,
|
||||
private mastersService: MastersService,
|
||||
private _formBuilder: FormBuilder,
|
||||
public dialog: MatDialog) {
|
||||
this.notifier = notifier;
|
||||
this._editquestionAnswerForm = this._formBuilder.group({
|
||||
temp_questions: this._formBuilder.array([
|
||||
// this.initAnswers(),
|
||||
])
|
||||
});
|
||||
// this.secondFormGroup = this._formBuilder.group({
|
||||
// secondCtrl: ''
|
||||
// });
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.setFirstFormDate(this.CaterogyQuesAns.questions);
|
||||
}
|
||||
|
||||
// setFirstFormDate(records){
|
||||
// alert(JSON.stringify(records));
|
||||
// }
|
||||
|
||||
animal: string;
|
||||
name: string;
|
||||
|
||||
|
||||
openDialog(): void {
|
||||
const dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
|
||||
data: {category_id: this.CaterogyQuesAns.fk_question_category_id, template_id: this.CaterogyQuesAns.fk_template_id}
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
console.log('The dialog was closed');
|
||||
this.animal = result;
|
||||
this.setModelFirstFormDate(result);
|
||||
// alert(result);
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
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
|
||||
};
|
||||
this.addLanguage(vals, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
isactive: val.isactive
|
||||
};
|
||||
this.addAnswerData(vals, null, i);
|
||||
}
|
||||
}
|
||||
|
||||
// ================== Dynamic Form set for Answers
|
||||
|
||||
addAnswerData(data, e, ix) {
|
||||
// const control = <FormArray>this._editquestionAnswerForm.controls['temp_questions'].get('answers');
|
||||
// let id = 0;
|
||||
|
||||
const control = (<FormArray>this._editquestionAnswerForm.controls['temp_questions']).at(ix).get('answers') as FormArray;
|
||||
// alert(control);
|
||||
control.push(this.initAnswerData(data));
|
||||
}
|
||||
|
||||
initAnswerData(data){
|
||||
return this._formBuilder.group({
|
||||
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],
|
||||
isactive: [data.isactive]
|
||||
});
|
||||
}
|
||||
|
||||
// =============================================
|
||||
|
||||
|
||||
// Dynamic Form field creation Functionality : START ===>
|
||||
initAnswers(data) {
|
||||
return this._formBuilder.group({
|
||||
question_id: [data.question_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],
|
||||
isactive: [data.isactive],
|
||||
question_answerable_by: [data.question_answerable_by],
|
||||
answers: this._formBuilder.array([
|
||||
// this.setAnswers(data.answers)
|
||||
])
|
||||
});
|
||||
}
|
||||
addLanguage(data, e) {
|
||||
if (data == null) {
|
||||
let newDate = {
|
||||
question:null,
|
||||
template_question_id: null,
|
||||
fk_template_id: null,
|
||||
fk_question_category_id: null,
|
||||
question_weightage: null,
|
||||
isactive: 1,
|
||||
}
|
||||
const control = <FormArray>this._editquestionAnswerForm.controls['temp_questions'];
|
||||
control.push(this.initAnswers(newDate));
|
||||
} else {
|
||||
// alert(JSON.stringify(data));
|
||||
const control = <FormArray>this._editquestionAnswerForm.controls['temp_questions'];
|
||||
control.push(this.initAnswers(data));
|
||||
// alert(control.length);
|
||||
// alert(JSON.stringify(this._editquestionAnswerForm.controls.temp_questions['controls']));
|
||||
this.setAnswers(data.answers, control.length - 1);
|
||||
}
|
||||
}
|
||||
// =========== : END
|
||||
|
||||
|
||||
removeLanguage(inx) {
|
||||
// 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){
|
||||
const control = <FormArray>this._editquestionAnswerForm.controls['temp_questions'];
|
||||
control.removeAt(inx);
|
||||
} else {
|
||||
alert();
|
||||
}
|
||||
// alert(JSON.stringify(value));
|
||||
}
|
||||
|
||||
submitted: boolean;
|
||||
onSubmit() {
|
||||
this.submitted = true;
|
||||
// stop here if form is invalid
|
||||
if (this._editquestionAnswerForm.invalid) {
|
||||
alert('no');
|
||||
return;
|
||||
} else {
|
||||
var formValues = this._editquestionAnswerForm.value;
|
||||
//To Remove The "Null" With Key also
|
||||
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);
|
||||
|
||||
if (totalScore == 100) {
|
||||
if (!this.checkDuplicateInObject(formValues.temp_questions)) {
|
||||
this.templatesService.updateTempateIDQuesAnsDetails(formValues.temp_questions).subscribe(
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
console.log(dataresult);
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
// const arr = <FormArray>this._editquestionAnswerForm.controls.temp_questions;
|
||||
// arr.controls.splice(0);
|
||||
// this.getTemplateCategoryDetails();
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
// this.errorMessage = "Something Wents Wrong Try Again.!";
|
||||
}
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
// this.errorMessage = "Some Thing Wents Wrong Try Again.!";
|
||||
});
|
||||
} else {
|
||||
alert("duplication records occured.!");
|
||||
}
|
||||
} else {
|
||||
alert("value should equal to 100")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public dublicateRerdIndex = -1;
|
||||
|
||||
checkDuplicateInObject(inputArray) {
|
||||
this.dublicateRerdIndex = -1;
|
||||
let seenDuplicate = false;
|
||||
|
||||
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){
|
||||
console.log('duplication: ' + i);
|
||||
this.dublicateRerdIndex = i;
|
||||
seenDuplicate = true;
|
||||
}
|
||||
}
|
||||
console.log(index);
|
||||
});
|
||||
return seenDuplicate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'dialog-overview-example-dialog',
|
||||
templateUrl: './dialog-category-question-list.html'
|
||||
})
|
||||
export class DialogOverviewExampleDialog {
|
||||
|
||||
// typesOfShoes: string[] = [
|
||||
// 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, ',
|
||||
// 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, ',
|
||||
// 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, ',
|
||||
// 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, ',
|
||||
// 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, '
|
||||
// ];
|
||||
|
||||
public m_questions:any;
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<DialogOverviewExampleDialog>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: DialogData,
|
||||
private templatesService: TemplatesService,
|
||||
private mastersService: MastersService,) {
|
||||
this.getCategoryRemainingQuesMasters();
|
||||
}
|
||||
|
||||
onNoClick(ques): void {
|
||||
this.dialogRef.close(ques);
|
||||
}
|
||||
|
||||
getCategoryRemainingQuesMasters() {
|
||||
this.templatesService.getRemaningQuestionCategory(this.data).subscribe(
|
||||
data => {
|
||||
this.m_questions = data.records;
|
||||
},
|
||||
error => {
|
||||
// this.notifier.notify('warning', 'No Category Master Records Found.!');
|
||||
// this.m_category = "No Category Master Records Found.";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
<div style="max-height: 480px;">
|
||||
<mat-card style="width: 580px; padding: 6px;" *ngFor="let question of m_questions">
|
||||
<span (click)="onNoClick(question)">{{question.question}}</span>
|
||||
</mat-card>
|
||||
</div>
|
||||
@ -1,91 +1,20 @@
|
||||
<!--<form [formGroup]="_editTempCategoryFrom" (submit)="onSubmit()">
|
||||
<div formArrayName="temp_category" class="example-full-width">
|
||||
<mat-list role="list">
|
||||
<mat-list-item style="margin: 2px 0;" *ngFor="let answ of _editTempCategoryFrom.controls.temp_category['controls']; let i=index ; let last = last;"
|
||||
role="listitem">
|
||||
<div [formGroupName]="i">
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Category" formControlName="fk_category_id">
|
||||
<mat-option *ngFor="let category of m_categoryList" [value]="category.fk_category_id">{{ category.name }}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<mat-form-field style="width: 25%; text-align: center" appearance="outline">
|
||||
<input matInput formControlName="weightage">
|
||||
</mat-form-field> <span>%</span>
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<button *ngIf="_editTempCategoryFrom.controls.temp_category.controls.length > 1" (click)="removeLanguage(i)" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
|
||||
|
||||
</div>
|
||||
<div fxFlex="0 1 auto" class="ml-xs">
|
||||
<button *ngIf="last" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Add More" matTooltipPosition="above" (click)="addLanguage($event); false"><mat-icon>add</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</div>
|
||||
<div class="row" style="text-align:right;">
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
</div>
|
||||
</form>-->
|
||||
<mat-card>
|
||||
<!--<pre>{{ templateQuesAnsRecord | json}}</pre>-->
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Category 1
|
||||
<mat-expansion-panel *ngFor="let data of templateQuesAnsRecord">
|
||||
<mat-expansion-panel-header fxLayout="row" fxLayoutWrap fxLayoutGap="5%" fxLayoutAlign="start center">
|
||||
<mat-panel-title fxFlex="0 1" class="ml-xs">
|
||||
{{ data.category_name }}
|
||||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
50%
|
||||
<mat-panel-description fxFlex="0 1" class="ml-xs">
|
||||
{{ data.weightage }}
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
<!--<mat-horizontal-stepper [linear]="isLinear" #stepper>
|
||||
<mat-step [stepControl]="firstFormGroup">
|
||||
<form [formGroup]="firstFormGroup">
|
||||
<ng-template matStepLabel>Questions</ng-template>
|
||||
<mat-list role="list">
|
||||
<mat-list-item role="listitem">Item 1</mat-list-item>
|
||||
<hr>
|
||||
<mat-list-item role="listitem">Item 2</mat-list-item>
|
||||
<hr>
|
||||
<mat-list-item role="listitem">Item 3</mat-list-item>
|
||||
<hr>
|
||||
</mat-list>
|
||||
<div>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-step>
|
||||
<mat-step [stepControl]="secondFormGroup">
|
||||
<form [formGroup]="secondFormGroup">
|
||||
<ng-template matStepLabel>Answers</ng-template>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Address" formControlName="secondCtrl" required>
|
||||
</mat-form-field>
|
||||
<div>
|
||||
<button mat-button matStepperPrevious>Back</button>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-step>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>Done</ng-template>
|
||||
You are now done.
|
||||
<div>
|
||||
<button mat-button matStepperPrevious>Back</button>
|
||||
<button mat-button (click)="stepper.reset()">Reset</button>
|
||||
</div>
|
||||
</mat-step>
|
||||
</mat-horizontal-stepper>-->
|
||||
<!--<p> {{ data.questions | json }}</p>-->
|
||||
<app-category-question-answer [CaterogyQuesAns]="data">
|
||||
</app-category-question-answer>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel (opened)="panelOpenState = true" (closed)="panelOpenState = false">
|
||||
<!--<mat-expansion-panel (opened)="panelOpenState = true" (closed)="panelOpenState = false">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Category 2
|
||||
@ -95,6 +24,6 @@
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<p>I'm visible because I am open</p>
|
||||
</mat-expansion-panel>
|
||||
</mat-expansion-panel>-->
|
||||
</mat-accordion>
|
||||
</mat-card>
|
||||
</mat-card>
|
||||
@ -5,6 +5,11 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { TemplatesService } from './../../../../service/templates/templates.service';
|
||||
import { MastersService } from './../../../../service/masters/masters.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-template-edit-question-answer',
|
||||
templateUrl: './edit-question-answer.component.html',
|
||||
@ -18,13 +23,29 @@ export class EditQuestionAnswerComponent implements OnInit {
|
||||
public _editTempCategoryFrom: FormGroup;
|
||||
public submitted = false;
|
||||
public panelOpenState : boolean;
|
||||
public templateQuesAnsRecord: any;
|
||||
|
||||
firstFormGroup: FormGroup;
|
||||
secondFormGroup: FormGroup;
|
||||
|
||||
constructor(
|
||||
notifier: NotifierService,
|
||||
private templatesService: TemplatesService,
|
||||
private mastersService: MastersService,
|
||||
private _formBuilder: FormBuilder,
|
||||
public dialog: MatDialog) {
|
||||
this.firstFormGroup = this._formBuilder.group({
|
||||
temp_questions: this._formBuilder.array([
|
||||
// this.initAnswers(),
|
||||
])
|
||||
});
|
||||
this.secondFormGroup = this._formBuilder.group({
|
||||
secondCtrl: ''
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.getTemplateQuesAnsDetails();
|
||||
this.initalLoadFormData();
|
||||
if(this.categoryList.length > 0){
|
||||
for (let val of this.categoryList) {
|
||||
@ -35,6 +56,10 @@ export class EditQuestionAnswerComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
setFormQuestionData(record) {
|
||||
// alert(JSON.stringify(record));
|
||||
}
|
||||
|
||||
initalLoadFormData(){
|
||||
this._editTempCategoryFrom = this._formBuilder.group({
|
||||
temp_category: this._formBuilder.array([
|
||||
@ -89,6 +114,26 @@ export class EditQuestionAnswerComponent implements OnInit {
|
||||
|
||||
// END ===>
|
||||
|
||||
getTemplateQuesAnsDetails() {
|
||||
this.templatesService.getTemplateIDQuesAnsDetails(this.questionId).subscribe(
|
||||
data => {
|
||||
if (data) {
|
||||
if (data.records) {
|
||||
this.templateQuesAnsRecord = data.records;
|
||||
this.setFormQuestionData(this.templateQuesAnsRecord);
|
||||
// this.templateListData = data.records;
|
||||
// this.dataLength = data.records.length;
|
||||
// this.dataSource.data = this.templateListData;
|
||||
} else {
|
||||
// this.noTemplateLendersFound = true;
|
||||
}
|
||||
} else {
|
||||
// this.noTemplateLendersFound = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/** To Save/Edited Popup Data */
|
||||
onSubmit() {
|
||||
|
||||
@ -7,31 +7,43 @@
|
||||
<mat-card style="padding: 6px;">
|
||||
<h6>Template Name</h6>
|
||||
<hr>
|
||||
<form (submit)="onSubmit()">
|
||||
<!---->
|
||||
<div *ngIf="templateNameRecord">
|
||||
<form [formGroup]="_editTempNameFrom" (submit)="onSubmit()">
|
||||
<div fxLayout="row" fxLayoutWrap fxLayoutGap="0.5%" fxLayoutAlign="start center">
|
||||
<mat-form-field class="ml-xs">
|
||||
<input matInput placeholder="Template Name">
|
||||
<!--<mat-error *ngIf="submitted && f.pan.hasError('required')" class="mat-text-warn">You must Include Pan Number.</mat-error>-->
|
||||
<input matInput placeholder="Template Name" formControlName="template_name">
|
||||
<mat-error *ngIf="submitted && f.template_name.hasError('required')" class="mat-text-warn">You must Include Template Name.</mat-error>
|
||||
</mat-form-field>
|
||||
<div>
|
||||
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="button" (click)="onReset()"><mat-icon>settings_backup_restore</mat-icon></button>
|
||||
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div *ngIf="noTemplateNameFound"> No Template Name Found.</div>
|
||||
</mat-card>
|
||||
<mat-card>
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Lender Details">
|
||||
<ng-template matTabContent>
|
||||
<app-template-edit-lender [questionId]="question_id">
|
||||
</app-template-edit-lender>
|
||||
</ng-template>
|
||||
|
||||
</mat-tab>
|
||||
<mat-tab label="Category">
|
||||
<ng-template matTabContent>
|
||||
<app-template-edit-category [questionId]="question_id">
|
||||
</app-template-edit-category> </mat-tab>
|
||||
</app-template-edit-category>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
<mat-tab label="Questions / Answers">
|
||||
<ng-template matTabContent>
|
||||
<app-template-edit-question-answer [questionId]="question_id">
|
||||
</app-template-edit-question-answer>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</mat-card>
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
|
||||
import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
|
||||
import { FormGroup, FormControl, FormBuilder, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { TemplateListComponent } from './../templates.list.component';
|
||||
import { TemplatesService } from './../../../service/templates/templates.service';
|
||||
|
||||
/*
|
||||
* Template Edit component
|
||||
* Edit Template Name component
|
||||
* : kdk
|
||||
*/
|
||||
@Component({
|
||||
@ -16,18 +18,70 @@ import { TemplateListComponent } from './../templates.list.component';
|
||||
templateUrl: './templates.edit.component.html'
|
||||
})
|
||||
export class TemplateEditComponent implements OnInit, OnDestroy {
|
||||
public pageTitle: string = "Edit Template";
|
||||
public pageTitle: string = "Edit Template";
|
||||
public question_id : number;
|
||||
public submitted: boolean = false;
|
||||
public _editTempNameFrom: FormGroup;
|
||||
public templateNameRecord: any;
|
||||
public noTemplateNameFound: boolean;
|
||||
|
||||
constructor( private route: ActivatedRoute,
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier : NotifierService;
|
||||
|
||||
constructor(
|
||||
notifier: NotifierService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private templateListComponent : TemplateListComponent) {
|
||||
private templateListComponent : TemplateListComponent,
|
||||
private templatesService: TemplatesService,
|
||||
private _formBuilder: FormBuilder,) {
|
||||
this.notifier = notifier;
|
||||
this.question_id = this.route.snapshot.params['question-id'];
|
||||
this.getTemplateNameDetails(this.question_id);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.templateListComponent.showListView(false);
|
||||
// this._editTempNameFrom = this._formBuilder.group({
|
||||
// template_name: [this.templateNameDetails.template_name, Validators.compose([Validators.required]) ]
|
||||
// })
|
||||
}
|
||||
|
||||
setFormDatas(){
|
||||
// alert(this.templateNameDetails.template_name);
|
||||
this._editTempNameFrom = this._formBuilder.group({
|
||||
template_id: [this.templateNameRecord.template_id],
|
||||
template_name: [this.templateNameRecord.template_name, Validators.compose([Validators.required]) ],
|
||||
isactive: [this.templateNameRecord.isactive]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// convenience getter for easy access to form fields
|
||||
get f() { return this._editTempNameFrom.controls; }
|
||||
|
||||
// get Template name details
|
||||
getTemplateNameDetails(q_id){
|
||||
this.templatesService.getTemplateIDNameDetails(q_id).subscribe(
|
||||
data => {
|
||||
if (data) {
|
||||
if (data.records) {
|
||||
this.noTemplateNameFound = false;
|
||||
this.templateNameRecord = data.records[0];
|
||||
this.setFormDatas();
|
||||
// this.templateListData = data.records;
|
||||
// this.dataLength = data.records.length;
|
||||
// this.dataSource.data = this.templateListData;
|
||||
} else {
|
||||
this.noTemplateNameFound = true;
|
||||
}
|
||||
} else {
|
||||
this.noTemplateNameFound = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
backToList(){
|
||||
@ -35,10 +89,41 @@ export class TemplateEditComponent implements OnInit, OnDestroy {
|
||||
this.router.navigate([ '../../' ], { relativeTo: this.route });
|
||||
}
|
||||
|
||||
public errorMessage;
|
||||
|
||||
/** To Save/Edited Popup Data */
|
||||
onSubmit() {
|
||||
this.submitted = true;
|
||||
this.submitted = true;
|
||||
// stop here if form is invalid
|
||||
if (this._editTempNameFrom.invalid) {
|
||||
this.errorMessage = "Please Fill All Mandate Fields.";
|
||||
return;
|
||||
} else {
|
||||
var formValues = this._editTempNameFrom.value;
|
||||
//To Remove The "Null" With Key also
|
||||
Object.keys(formValues).forEach((key) => (formValues[key] == null) && delete formValues[key]);
|
||||
|
||||
this.templatesService.updateTempateIDNameDetails(formValues).subscribe(
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
console.log(dataresult);
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
this.getTemplateNameDetails(this.question_id);
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Something Wents Wrong Try Again.!";
|
||||
}
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Some Thing Wents Wrong Try Again.!";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** To Reset Popup Data */
|
||||
onReset() {
|
||||
this.setFormDatas();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
@ -5,6 +5,8 @@ import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { TemplatesService } from './../../service/templates/templates.service';
|
||||
|
||||
/*
|
||||
* Template List component
|
||||
* : kdk
|
||||
@ -20,6 +22,7 @@ export class TemplateListComponent implements OnInit, OnDestroy {
|
||||
public listView: boolean;
|
||||
public names: string;
|
||||
public noTemplMasterRecrdFound: boolean = false;
|
||||
public search_cid : any;
|
||||
|
||||
// pagination variable details
|
||||
length = 50;
|
||||
@ -38,7 +41,8 @@ export class TemplateListComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
private router: Router,
|
||||
private templatesService: TemplatesService) {
|
||||
this.listView = true;
|
||||
// this.names = 'dinesh';
|
||||
}
|
||||
@ -51,34 +55,34 @@ export class TemplateListComponent implements OnInit, OnDestroy {
|
||||
|
||||
// get question master list details
|
||||
getTemplateMastersListDetails() {
|
||||
this.templateList = this.m_templateList.records;
|
||||
this.templateListData = this.m_templateList.records;
|
||||
this.dataLength = this.m_templateList.records.length;
|
||||
this.dataSource.data = this.templateListData;
|
||||
|
||||
// this.noTemplMasterRecrdFound = false;
|
||||
// this.search_cid = this.filterFormGroupCtrl.controls.category.value;
|
||||
// console.log(this.search_cid + ", " + this.filterFormGroupCtrl);
|
||||
// this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe(
|
||||
// data => {
|
||||
// if (data) {
|
||||
// if (data.records) {
|
||||
// this.templateList = data.records;
|
||||
// this.templateListData = data.records;
|
||||
// this.dataLength = data.records.length;
|
||||
// this.templateList = this.m_templateList.records;
|
||||
// this.templateListData = this.m_templateList.records;
|
||||
// this.dataLength = this.m_templateList.records.length;
|
||||
// this.dataSource.data = this.templateListData;
|
||||
// } else {
|
||||
// this.templateList = [];
|
||||
// this.dataLength = null;
|
||||
// this.noTemplMasterRecrdFound = true;
|
||||
// }
|
||||
// } else {
|
||||
// this.templateList = [];
|
||||
// this.dataLength = null;
|
||||
// this.noTemplMasterRecrdFound = true;
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
|
||||
this.noTemplMasterRecrdFound = false;
|
||||
this.search_cid = '';
|
||||
// console.log(this.search_cid + ", " + this.filterFormGroupCtrl);
|
||||
this.templatesService.getTemplatesMasterListDetails(this.search_cid).subscribe(
|
||||
data => {
|
||||
if (data) {
|
||||
if (data.records) {
|
||||
this.templateList = data.records;
|
||||
this.templateListData = data.records;
|
||||
this.dataLength = data.records.length;
|
||||
this.dataSource.data = this.templateListData;
|
||||
} else {
|
||||
this.templateList = [];
|
||||
this.dataLength = null;
|
||||
this.noTemplMasterRecrdFound = true;
|
||||
}
|
||||
} else {
|
||||
this.templateList = [];
|
||||
this.dataLength = null;
|
||||
this.noTemplMasterRecrdFound = true;
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,11 @@ import { EditCategoryComponent } from './templates-list/edit/edit-category/edit-
|
||||
import { EditLenderComponent } from './templates-list/edit/edit-lender/edit-lender.component';
|
||||
import { EditQuestionAnswerComponent } from './templates-list/edit/edit-question-answer/edit-question-answer.component';
|
||||
|
||||
// import { QuestionsService } from './../service/questions/questions.service';
|
||||
|
||||
import { TemplatesService } from './../service/templates/templates.service';
|
||||
import { CategoryQuestionAnswerComponent } from './templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component';
|
||||
import { DialogOverviewExampleDialog } from './templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component';
|
||||
|
||||
/*
|
||||
* Question Master Module details
|
||||
* : kdk
|
||||
@ -105,12 +109,15 @@ const customNotifierOptions: NotifierOptions = {
|
||||
TemplateEditComponent,
|
||||
EditCategoryComponent,
|
||||
EditLenderComponent,
|
||||
EditQuestionAnswerComponent
|
||||
EditQuestionAnswerComponent,
|
||||
CategoryQuestionAnswerComponent,
|
||||
DialogOverviewExampleDialog
|
||||
],
|
||||
entryComponents: [
|
||||
DialogOverviewExampleDialog
|
||||
],
|
||||
providers: [
|
||||
// QuestionsService
|
||||
TemplatesService
|
||||
]
|
||||
})
|
||||
export class TemplatesModule { }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user