question master changes : kdk

This commit is contained in:
dineshkumarkannan 2018-10-03 10:47:02 +05:30
parent 7400b4f216
commit 3bdd446b07
8 changed files with 267 additions and 235 deletions

View File

@ -1,77 +1,77 @@
<div style="max-height: 580px;"> <div style="max-height: 580px;">
<mat-card style="width: 580px; padding: 6px;"> <mat-card style="width: 580px; padding: 6px;">
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center"> <div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2> <h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
<div style="width: 20%;"></div> <div style="width: 20%;"></div>
<div style="width: 30%;text-align:right;"> <div style="width: 30%;text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
</div>
</div> </div>
</div> <form [formGroup]="_addQuesFrom" (submit)="onSubmit()">
<form [formGroup]="_addQuesFrom" (submit)="onSubmit()"> <!--<div class="form-group">-->
<!--<div class="form-group">--> <div fxLayout="row" fxLayoutAlign="start none">
<div fxLayout="row" fxLayoutAlign="start none"> <mat-form-field class="ml-xs example-full-width">
<mat-form-field class="ml-xs example-full-width"> <mat-select placeholder="Select Category" formControlName="fk_question_catagory">
<mat-select placeholder="Select Category" formControlName="fk_question_catagory"> <mat-option *ngFor="let ct of categories" [value]="ct.question_categroy_id">{{ ct.categroy_name }}</mat-option>
<mat-option *ngFor="let ct of categories" [value]="ct.question_categroy_id">{{ ct.categroy_name }}</mat-option> </mat-select>
</mat-select> <mat-error *ngIf="submitted && f.fk_question_catagory.hasError('required')" class="mat-text-warn">You must Select Category.</mat-error>
<mat-error *ngIf="submitted && f.fk_question_catagory.hasError('required')" class="mat-text-warn">You must Select Category.</mat-error> </mat-form-field>
</mat-form-field> </div>
</div> <div fxLayout="row" fxLayoutAlign="start none">
<div fxLayout="row" fxLayoutAlign="start none"> <mat-form-field class="ml-xs example-full-width">
<mat-form-field class="ml-xs example-full-width"> <textarea matInput placeholder="Question" formControlName="question"></textarea>
<textarea matInput placeholder="Question" formControlName="question"></textarea> <mat-error *ngIf="submitted && f.question.hasError('required')" class="mat-text-warn">You must Include Question.</mat-error>
<mat-error *ngIf="submitted && f.question.hasError('required')" class="mat-text-warn">You must Include Question.</mat-error> </mat-form-field>
</mat-form-field> </div>
</div> <div fxLayout="row" fxLayoutAlign="start none">
<div fxLayout="row" fxLayoutAlign="start none"> <mat-form-field class="ml-xs example-full-width">
<mat-form-field class="ml-xs example-full-width"> <textarea matInput placeholder="Description" formControlName="description"></textarea>
<textarea matInput placeholder="Description" formControlName="description"></textarea> <mat-error *ngIf="submitted && f.description.hasError('required')" class="mat-text-warn">You must Include Description.</mat-error>
<mat-error *ngIf="submitted && f.description.hasError('required')" class="mat-text-warn">You must Include Description.</mat-error> </mat-form-field>
</mat-form-field> </div>
</div> <div fxLayout="row" fxLayoutAlign="start none">
<div fxLayout="row" fxLayoutAlign="start none"> <mat-form-field class="ml-xs example-full-width">
<mat-form-field class="ml-xs example-full-width"> <mat-select placeholder="Select Answer Type" formControlName="fk_question_answertype">
<mat-select placeholder="Select Answer Type" formControlName="fk_question_answertype"> <mat-option *ngFor="let ans of questionsOptions" [value]="ans.question_answer_type_id">{{ ans.answer_type_name }}</mat-option>
<mat-option *ngFor="let ans of questionsOptions" [value]="ans.question_answer_type_id">{{ ans.answer_type_name }}</mat-option> </mat-select>
</mat-select> <mat-error *ngIf="submitted && f.fk_question_answertype.hasError('required')" class="mat-text-warn">You must Select Answer Type.</mat-error>
<mat-error *ngIf="submitted && f.fk_question_answertype.hasError('required')" class="mat-text-warn">You must Select Answer Type.</mat-error> </mat-form-field>
</mat-form-field> </div>
</div> <div fxLayout="row" fxLayoutAlign="start none">
<div fxLayout="row" fxLayoutAlign="start none"> <div formArrayName="answers" class="example-full-width">
<div formArrayName="answers" class="example-full-width"> <div *ngFor="let answ of _addQuesFrom.controls.answers['controls']; let i=index">
<div *ngFor="let answ of _addQuesFrom.controls.answers['controls']; let i=index"> <div [formGroupName]="i">
<div [formGroupName]="i"> <div fxLayout="row" style="width: 100%">
<div fxLayout="row" style="width: 100%"> <div style="width: 80%">
<div style="width: 80%"> <mat-form-field class="ml-xs example-full-width">
<mat-form-field class="ml-xs example-full-width"> <!--<span>Answer {{i + 1}}</span>-->
<!--<span>Answer {{i + 1}}</span>--> <textarea matInput placeholder="Answer" formControlName="answer"></textarea>
<textarea matInput placeholder="Answer" formControlName="answer"></textarea> <!--<mat-error *ngIf="submitted && answer.hasError('required')" class="mat-text-warn">You must Include Question.</mat-error>-->
<!--<mat-error *ngIf="submitted && answer.hasError('required')" class="mat-text-warn">You must Include Question.</mat-error>--> </mat-form-field>
</mat-form-field> </div>
</div> <div style="width:20%">
<div style="width:20%"> <span *ngIf="_addQuesFrom.controls.answers.controls.length > 1" (click)="removeLanguage(i)">
<span *ngIf="_addQuesFrom.controls.answers.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 mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
</span> </span>
</div>
</div> </div>
</div> </div>
</div> </div>
<button mat-button color="primary" matTooltip="Add More Answer" matTooltipPosition="above" (click)="addLanguage($event); false">Add More</button>
<!--<a (click)="addLanguage()" style="cursor: default">Add another Answer </a>-->
</div> </div>
<button mat-button color="primary" matTooltip="Add More Answer" matTooltipPosition="above" (click)="addLanguage($event); false">Add More</button>
<!--<a (click)="addLanguage()" style="cursor: default">Add another Answer </a>-->
</div> </div>
</div>
<!--Error List Shown Here--> <!--Error List Shown Here-->
<!--<ul> <!--<ul>
<li *ngFor="let err of errorMessage"> <li *ngFor="let err of errorMessage">
<mat-error>{{err.err}}</mat-error> <mat-error>{{err.err}}</mat-error>
</li> </li>
</ul>--> </ul>-->
<div class="row" style="text-align:right;"> <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> <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>
<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> <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> </div>
<!--</div>--> <!--</div>-->
</form> </form>
</mat-card> </mat-card>
</div> </div>

View File

@ -12,6 +12,8 @@ import {
FormArray, FormArray,
} from '@angular/forms'; } from '@angular/forms';
import { NotifierService } from 'angular-notifier';
import { import {
MatDialog, MatDialog,
MatDialogRef, MatDialogRef,
@ -21,24 +23,37 @@ import {
import { MastersService } from './../../service/masters/masters.service'; import { MastersService } from './../../service/masters/masters.service';
import { QuestionsService } from './../../service/questions/questions.service'; import { QuestionsService } from './../../service/questions/questions.service';
/*
* Question master add details
* : kdk
*/
@Component({ @Component({
selector: 'app-add', selector: 'app-add',
templateUrl: './add.component.html', templateUrl: './add.component.html',
styleUrls: ['./add.component.scss'] styleUrls: ['./add.component.scss']
}) })
export class AddComponent implements OnInit { export class AddComponent implements OnInit {
public pageTitle : string = "Add Question Details"; public pageTitle: string = "Add Question Details";
public _addQuesFrom: FormGroup; public _addQuesFrom: FormGroup;
public submitted = false; public submitted = false;
public categories: any = []; public categories: any = [];
public questionsOptions: any = []; public questionsOptions: any = [];
errorMessage: string; errorMessage: string;
constructor(private _formBuilder: FormBuilder, /**
* Notifier service
*/
private notifier: NotifierService;
constructor(
notifier: NotifierService,
private _formBuilder: FormBuilder,
private dialogRef: MatDialogRef<AddComponent>, private dialogRef: MatDialogRef<AddComponent>,
private masterService: MastersService, private masterService: MastersService,
private questionsService: QuestionsService) { } private questionsService: QuestionsService) {
this.notifier = notifier;
}
ngOnInit() { ngOnInit() {
@ -55,19 +70,6 @@ export class AddComponent implements OnInit {
// OnInit Load Category and Question Type Masters // OnInit Load Category and Question Type Masters
this.getCategoryListMaster(); this.getCategoryListMaster();
this.getQuestionOptionsMaster(); this.getQuestionOptionsMaster();
// /** For SelectDrop Datas*/
// this._mastersService.getAllMasterData('CITY')
// .subscribe(
// data => {
// if (data.status == 200) {
// this.citydatas = data.records;
// this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
// }
// }, error => this.errorMessage = <any> error);
} }
// convenience getter for easy access to form fields // convenience getter for easy access to form fields
@ -96,7 +98,8 @@ export class AddComponent implements OnInit {
this.categories = data.records.filter(category => category.isactive == 1); this.categories = data.records.filter(category => category.isactive == 1);
}, },
error => { error => {
this.errorMessage = "No Category Record Found."; this.notifier.notify('warning', 'No Category Records Found.!');
this.errorMessage = "No Category Records Found.";
} }
) )
} }
@ -106,6 +109,7 @@ export class AddComponent implements OnInit {
this.questionsOptions = data.records; this.questionsOptions = data.records;
}, },
error => { error => {
this.notifier.notify('warning', 'No Answer Type Records Found.!');
this.errorMessage = "No Answer Type Record Found."; this.errorMessage = "No Answer Type Record Found.";
} }
) )
@ -126,25 +130,29 @@ export class AddComponent implements OnInit {
} else { } else {
var answerFormValues = this._addQuesFrom.value; var answerFormValues = this._addQuesFrom.value;
//To Remove The "Null" With Key also //To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
//Add BRANCH data with help Service File //Add BRANCH data with help Service File
this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe( this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if (dataresult.status == 200) {
console.log(dataresult); console.log(dataresult);
alert("sample alert for Saving"); this.notifier.notify('success', 'Record Saved Successfully.!');
} this.dialogRef.close();
else { // alert("sample alert for Saving");
this.errorMessage = "Some Thing Wents Wrong Try Again !"; }
} else {
} , error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
this.errorMessage = "Some Thing Wents Wrong Try Again !"; this.errorMessage = "Some Thing Wents Wrong Try Again !";
this.dialogRef.close(); }
}); }, error => {
//After Saving the BRANCH data then popup close this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
// this.dialogRef.close(); this.errorMessage = "Something Wents Wrong Try Again !";
this.dialogRef.close();
});
//After Saving the BRANCH data then popup close
// this.dialogRef.close();
} }
} }

View File

@ -65,8 +65,8 @@
</div> </div>
</div> </div>
<div fxLayout="row" fxLayoutAlign="start none"> <div fxLayout="row" fxLayoutAlign="start none">
<mat-checkbox formControlName="isactive" [ngModel]="f.isactive.value == 1 ? true : f.isactive.value == 0 ? false : null" <mat-checkbox formControlName="isactive" [ngModel]="f.isactive.value == 1 ? true : f.isactive.value == 0 ? false : null"
(ngModelChange)="_addQuesFrom.controls['isactive'].setValue($event ? 1 : 0)">Active/InActive</mat-checkbox> (ngModelChange)="_addQuesFrom.controls['isactive'].setValue($event ? 1 : 0)">Active/InActive</mat-checkbox>
</div> </div>
<!--Error List Shown Here--> <!--Error List Shown Here-->
<!--<ul> <!--<ul>
@ -75,7 +75,8 @@
</li> </li>
</ul>--> </ul>-->
<div class="row" style="text-align:right;"> <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="button" (click)="onReset()"><mat-icon>settings_backup_restore</mat-icon></button> <button mat-raised-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-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button> <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> </div>
<!--</div>--> <!--</div>-->

View File

@ -23,6 +23,10 @@ import {
import { MastersService } from './../../service/masters/masters.service'; import { MastersService } from './../../service/masters/masters.service';
import { QuestionsService } from './../../service/questions/questions.service'; import { QuestionsService } from './../../service/questions/questions.service';
/*
* Question master details edit component
* : kdk
*/
@Component({ @Component({
selector: 'app-edit', selector: 'app-edit',
templateUrl: './edit.component.html', templateUrl: './edit.component.html',
@ -31,18 +35,18 @@ import { QuestionsService } from './../../service/questions/questions.service';
export class EditComponent implements OnInit { export class EditComponent implements OnInit {
public pageTitle : string = "Edit Question Details"; public pageTitle: string = "Edit Question Details";
public _addQuesFrom: FormGroup; public _addQuesFrom: FormGroup;
public submitted = false; public submitted = false;
public categories: any = []; public categories: any = [];
public questionsOptions: any = []; public questionsOptions: any = [];
errorMessage: string; errorMessage: string;
/** /**
* Notifier service * Notifier service
*/ */
private notifier: NotifierService; private notifier: NotifierService;
constructor( constructor(
notifier: NotifierService, notifier: NotifierService,
@ -51,8 +55,8 @@ export class EditComponent implements OnInit {
private masterService: MastersService, private masterService: MastersService,
private questionsService: QuestionsService, private questionsService: QuestionsService,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
this.notifier = notifier; this.notifier = notifier;
} }
ngOnInit() { ngOnInit() {
this.loadFormData(); this.loadFormData();
@ -63,14 +67,14 @@ export class EditComponent implements OnInit {
this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null);
} }
} }
// OnInit Load Category and Question Type Masters // OnInit Load Category and Question Type Masters
this.getCategoryListMaster(); this.getCategoryListMaster();
this.getQuestionOptionsMaster(); this.getQuestionOptionsMaster();
} }
loadAnsData(){ // load answer details list
if (this.data["0"].length > 0) { loadAnsData() {
if (this.data["0"].length > 0) {
for (let val of this.data["0"]) { for (let val of this.data["0"]) {
// alert(JSON.stringify(val)); // alert(JSON.stringify(val));
let vals = val; let vals = val;
@ -79,26 +83,29 @@ export class EditComponent implements OnInit {
} }
} }
// load form data form the master
loadFormData() { loadFormData() {
/** Questions Form Datas*/ /** Questions Form Datas*/
this._addQuesFrom = this._formBuilder.group({ this._addQuesFrom = this._formBuilder.group({
question_id: [this.data.question_id], question_id: [this.data.question_id],
question: [this.data.question, Validators.compose([Validators.required])], question: [this.data.question, Validators.compose([Validators.required])],
description: [this.data.description, Validators.compose([Validators.required])], description: [this.data.description, Validators.compose([Validators.required])],
fk_question_catagory: [this.data.fk_question_catagory, Validators.compose([Validators.required])], fk_question_catagory: [this.data.fk_question_catagory, Validators.compose([Validators.required])],
fk_question_answertype: [this.data.fk_question_answertype, Validators.compose([Validators.required])], fk_question_answertype: [this.data.fk_question_answertype, Validators.compose([Validators.required])],
isactive:[this.data.isactive], isactive: [this.data.isactive],
answers: this._formBuilder.array([ answers: this._formBuilder.array([
// this.initAnswers(null, null), // this.initAnswers(null, null),
]) ])
}); });
} }
get f_ans() { return <FormArray>this._addQuesFrom.get('answers'); }
// convenience getter for easy access to form fields // convenience getter for easy access to form fields
get f() { return this._addQuesFrom.controls; } get f() { return this._addQuesFrom.controls; }
// form answer details access
get f_ans() { return <FormArray>this._addQuesFrom.get('answers'); }
// Dynamic Form field creation Functionality : START ===> // Dynamic Form field creation Functionality : START ===>
initAnswers(ans, fk_id, isAct) { initAnswers(ans, fk_id, isAct) {
isAct = isAct == null ? 1 : isAct; isAct = isAct == null ? 1 : isAct;
@ -125,6 +132,7 @@ export class EditComponent implements OnInit {
this.categories = data.records.filter(category => category.isactive == 1); this.categories = data.records.filter(category => category.isactive == 1);
}, },
error => { error => {
this.notifier.notify('warning', 'No Category Records Found.!');
this.errorMessage = "No Category Record Found."; this.errorMessage = "No Category Record Found.";
} }
) )
@ -135,6 +143,7 @@ export class EditComponent implements OnInit {
this.questionsOptions = data.records; this.questionsOptions = data.records;
}, },
error => { error => {
this.notifier.notify('warning', 'No Answer Type Records Found.!');
this.errorMessage = "No Answer Type Record Found."; this.errorMessage = "No Answer Type Record Found.";
} }
) )
@ -163,17 +172,18 @@ export class EditComponent implements OnInit {
dataresult => { dataresult => {
if (dataresult.status == 200) { if (dataresult.status == 200) {
console.log(dataresult); console.log(dataresult);
this.notifier.notify( 'success', 'Your Changes Updated!' ); this.notifier.notify('success', 'Your Changes Updated.!');
this.dialogRef.close(); this.dialogRef.close();
// this.notifierService('success', 'You are awesome! I mean it!'); // this.notifierService('success', 'You are awesome! I mean it!');
// alert("sample alert for Saving"); // alert("sample alert for Saving");
} }
else { else {
this.notifier.notify( 'warning', 'Something Wents Wrong Try Again !' ); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
this.errorMessage = "Something Wents Wrong Try Again !"; this.errorMessage = "Something Wents Wrong Try Again.!";
} }
}, error => { }, error => {
this.errorMessage = "Some Thing Wents Wrong Try Again !"; this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
this.errorMessage = "Some Thing Wents Wrong Try Again.!";
this.dialogRef.close(); this.dialogRef.close();
}); });
//After Saving the BRANCH data then popup close //After Saving the BRANCH data then popup close

View File

@ -1,58 +1,53 @@
<div> <div>
<mat-card> <mat-card>
<mat-card class="mat-elevation-z1"> <mat-card class="mat-elevation-z1">
<!--<mat-card-title><span> Questions Master </span></mat-card-title> <div style="margin: 6px; padding: 4px;">
<mat-card-subtitle> List of Questions</mat-card-subtitle> <div class="p_title" style="font-size: 16px; font-style: bold;">Questions Master</div>
<mat-card-content>--> <div class="sub_title" style="font-size: 11px;">List of Questions</div>
<div style="margin: 6px; padding: 4px;"> </div>
<div class="p_title" style="font-size: 16px; font-style: bold;">Questions Master</div> <div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="center none">
<div class="sub_title" style="font-size: 11px;">List of Questions</div> <div fxFlex="80%">
</div> <form [formGroup]="filterFormGroupCtrl">
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="center none"> <div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5px" fxLayoutAlign="start none" style="padding: 6px;">
<div fxFlex="80%">
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5px" fxLayoutAlign="start none" style="padding: 6px;"> <mat-select placeholder="Category" formControlName="category">
<!--<mat-form-field class="example-full-width"> <!--<ngx-mat-select-search [formControl]="masterFilterCtrl" ></ngx-mat-select-search>-->
<input matInput placeholder="Category" value=""> <mat-option *ngFor="let cat of categories" [value]="cat.question_categroy_id" (click)="getQuestionsMasters()">
</mat-form-field>--> {{cat.categroy_name}}
<!--<mat-form-field>--> </mat-option>
<mat-select placeholder="Category" formControlName="filterFormCtrl"> </mat-select>
<!--<ngx-mat-select-search [formControl]="masterFilterCtrl" ></ngx-mat-select-search>--> </div>
<mat-option *ngFor="let cat of categories" [value]="cat.question_categroy_id" (click)="getQuestionsMasters()"> </form>
{{cat.categroy_name}} </div>
</mat-option> <div fxFlex="20%">
</mat-select> <button mat-stroked-button color="primary" (click)="addNewQuestion()">Add Questions</button>
<!--</mat-form-field>-->
</div> </div>
</div> </div>
<div fxFlex="20%"> <!--</mat-card-content>-->
<button mat-stroked-button color="primary" (click)="addNewQuestion()">Add Questions</button> </mat-card>
</div>
</div>
<!--</mat-card-content>-->
</mat-card>
<ng-container *ngIf="productList.length > 0"> <ng-container *ngIf="productList.length > 0">
<div style="padding: 0 12px;"> <div style="padding: 0 12px;">
<mat-card class="product-card" *ngFor="let product of dataSource.connect() | async"> <mat-card class="product-card" *ngFor="let product of dataSource.connect() | async">
<div fxLayout="row" fxLayoutAlign="start start"> <div fxLayout="row" fxLayoutAlign="start start" style="padding: 6px 2px;">
<div fxFlex="90%" style="padding: 12px 8px;"> <div fxFlex="90%" style="padding: 12px 8px;">
<!--<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="start none"> <!--<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="start none">
<div class="category-label"> {{ product.categroy_name }}</div> <div class="category-label"> {{ product.categroy_name }}</div>
</div>--> </div>-->
<div fxLayout="row" fxLayoutWrap fxLayoutAlign="none none"> <div fxLayout="row" fxLayoutWrap fxLayoutAlign="none none">
<div class="ml-xs" fxFlex="20%"> <div class="ml-xs" fxFlex="20%">
{{ product.categroy_name }} {{ product.categroy_name }}
</div>
<div class="ml-xs" fxFlex="80%">
<div class="text-line-limit">{{ product.question }}
</div>
</div>
</div> </div>
<div class="ml-xs" fxFlex="80%">
<div class="text-line-limit">{{ product.question }}
</div>
</div>
</div> </div>
</div> <div fxFlex="10%">
<div fxFlex="10%"> <button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="editQuestion(product)"><mat-icon>edit</mat-icon></button>
<button mat-icon-button [matMenuTriggerFor]="menu"> <!--<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon> <mat-icon>more_vert</mat-icon>
</button> </button>
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
@ -60,10 +55,10 @@
<mat-icon>create</mat-icon> <mat-icon>create</mat-icon>
<span>Edit</span> <span>Edit</span>
</button> </button>
</mat-menu> </mat-menu>-->
</div>
</div> </div>
</div> <!--<mat-card-header>
<!--<mat-card-header>
<mat-card-title> <mat-card-title>
<h4>{{ product.question }}</h4> <h4>{{ product.question }}</h4>
</mat-card-title> </mat-card-title>
@ -75,27 +70,17 @@
<mat-card-actions> <mat-card-actions>
<button mat-raised-button color="accent" (click)="addItemToCard(product)">Add to card</button> <button mat-raised-button color="accent" (click)="addItemToCard(product)">Add to card</button>
</mat-card-actions>--> </mat-card-actions>-->
</mat-card> </mat-card>
</div> </div>
</ng-container> </ng-container>
<mat-card *ngIf="noQuesMasterRecrdFound">
<div class="no-record-found">No Record Found ... </div>
</mat-card>
<!--<mat-paginator <mat-paginator #paginator class="mat-elevation-z1" [length]="productList.length" [pageIndex]="pageIndex" [pageSize]="pageSize"
#paginator [pageSizeOptions]="[5, 10, 25, 100]" (page)="pageEvent = $event; pageChange($event)">
[length]="productList.length"
[pageSize]="5"
[pageSizeOptions]="[5, 10, 25, 100]"
[showFirstLastButtons]="true">
</mat-paginator>-->
<mat-paginator #paginator class="mat-elevation-z1"
[length]="productList.length"
[pageIndex]="pageIndex"
[pageSize]="pageSize"
[pageSizeOptions]="[5, 10, 25, 100]"
(page)="pageEvent = $event; pageChange($event)">
</mat-paginator> </mat-paginator>
<!--<mat-card>
<!--<mat-card>
<div class="example-container mat-elevation-z8"> <div class="example-container mat-elevation-z8">
<mat-table [dataSource]="dataSource" matSort> <mat-table [dataSource]="dataSource" matSort>
@ -120,7 +105,7 @@
<mat-row *matRowDef="let row; columns: displayedColumns;"> <mat-row *matRowDef="let row; columns: displayedColumns;">
</mat-row> </mat-row>
</mat-table> </mat-table>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator> <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
</div> </div>
</mat-card>--> </mat-card>-->

View File

@ -44,3 +44,9 @@
color: #fff; color: #fff;
box-shadow: 0 2px 3px #c8bbbb; box-shadow: 0 2px 3px #c8bbbb;
} }
.no-record-found {
font-size: 18px;
color: #03a9f4;
padding : 12px 8px;
}

View File

@ -1,6 +1,6 @@
import { Component, ViewChild, OnInit } from '@angular/core'; import { Component, ViewChild, OnInit } from '@angular/core';
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent} from '@angular/material'; import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
import { FormGroup, FormControl } from '@angular/forms'; import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { QuestionsService } from './../../service/questions/questions.service'; import { QuestionsService } from './../../service/questions/questions.service';
@ -9,61 +9,83 @@ import { MastersService } from './../../service/masters/masters.service';
import { AddComponent } from './../add/add.component'; import { AddComponent } from './../add/add.component';
import { EditComponent } from './../edit/edit.component'; import { EditComponent } from './../edit/edit.component';
/*
* Questions master List component
* : kdk
*/
@Component({ @Component({
selector: 'app-list', selector: 'app-list',
templateUrl: './list.component.html', templateUrl: './list.component.html',
styleUrls: ['./list.component.scss'] styleUrls: ['./list.component.scss']
}) })
export class ListComponent implements OnInit { export class ListComponent implements OnInit {
public productList: any[] = []; public productList: any[] = [];
public paginationList: any[] = []; public paginationList: any[] = [];
public categories: any = []; public categories: any = [];
public search_cid :any = null; public search_cid: any = null;
public noQuesMasterRecrdFound: boolean = false;
public filterFormCtrl : FormControl = new FormControl(); public filterFormGroupCtrl: FormGroup;
/** control for the MatSelect filter keyword */
// public masterFilterCtrl: FormControl = new FormControl();
// pagination variable details
length = 50; length = 50;
pageIndex = 0; pageIndex = 0;
pageSize = 10; pageSize = 10;
pageEvent: PageEvent; pageEvent: PageEvent;
// data source variable details
questionListData = null; questionListData = null;
public dataLength: number; public dataLength: number;
public dataSource = new MatTableDataSource(); public dataSource = new MatTableDataSource();
displayedColumns = ['categroy_name', 'question', 'actions']; displayedColumns = ['categroy_name', 'question', 'actions'];
@ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
constructor(private dialog: MatDialog, constructor(private dialog: MatDialog,
private questionsService: QuestionsService, private questionsService: QuestionsService,
private masterService: MastersService) { private masterService: MastersService,
this.getQuestionsMasters(); private _formBuilder: FormBuilder) {
} this.filterFormGroupCtrl = this._formBuilder.group({
category: [null, '']
getQuestionsMasters(){ });
this.search_cid = this.filterFormCtrl.value; }
console.log(this.filterFormCtrl);
this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe(
data => {
this.productList = data.records;
this.questionListData = data.records;
// alert(this.userData);
this.dataLength = data.records.length;
this.dataSource.data = this.questionListData;
}
)
}
ngOnInit() { ngOnInit() {
this.getCategorMaster(); this.getCategorMaster();
this.getQuestionsMasters();
} }
getCategorMaster() { // get question master list details
getQuestionsMasters() {
this.noQuesMasterRecrdFound = 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.productList = data.records;
this.questionListData = data.records;
this.dataLength = data.records.length;
this.dataSource.data = this.questionListData;
} else {
this.productList = [];
this.dataLength = null;
this.noQuesMasterRecrdFound = true;
}
} else {
this.productList = [];
this.dataLength = null;
this.noQuesMasterRecrdFound = true;
}
}
)
}
// get category master details
getCategorMaster() {
this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe(
data => { data => {
this.categories = data.records.filter(category => category.isactive == 1); this.categories = data.records.filter(category => category.isactive == 1);
@ -74,7 +96,7 @@ export class ListComponent implements OnInit {
) )
} }
ngAfterViewInit() { ngAfterViewInit() {
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
} }
@ -88,30 +110,31 @@ export class ListComponent implements OnInit {
// add questions popup model call // add questions popup model call
addNewQuestion() { addNewQuestion() {
const dialogRef = this.dialog.open(AddComponent, { const dialogRef = this.dialog.open(AddComponent, {
data: {} data: {},
disableClose: true
}); });
dialogRef.afterClosed() dialogRef.afterClosed()
.subscribe(dataresult => { .subscribe(dataresult => {
this.getQuestionsMasters(); this.getQuestionsMasters();
// this.getBranch(); // this.getBranch();
// this.isPopupOpened = false; // this.isPopupOpened = false;
}); });
} }
editQuestion(rowDetails: any){ // edit questions master details popup model
const dialogRef = this.dialog.open(EditComponent, { editQuestion(rowDetails: any) {
data: rowDetails const dialogRef = this.dialog.open(EditComponent, {
data: rowDetails,
disableClose: true
}); });
dialogRef.afterClosed() dialogRef.afterClosed()
.subscribe(dataresult => { .subscribe(dataresult => {
this.getQuestionsMasters(); this.getQuestionsMasters();
// this.getBranch(); // this.getBranch();
// this.isPopupOpened = false; // this.isPopupOpened = false;
}); });
} }
// padination page event call
pageChange(e) { pageChange(e) {
console.log(e); console.log(e);
} }

View File

@ -28,9 +28,8 @@ import { AddComponent } from './add/add.component';
import { EditComponent } from './edit/edit.component'; import { EditComponent } from './edit/edit.component';
/* /*
* Question Master Module details * Question Master Module details
* : kdk
*/ */
/** /**
* Custom angular notifier options * Custom angular notifier options
*/ */
@ -42,7 +41,7 @@ const customNotifierOptions: NotifierOptions = {
}, },
vertical: { vertical: {
position: 'top', position: 'top',
distance: 12, distance: 32,
gap: 10 gap: 10
} }
}, },