question master changes : kdk
This commit is contained in:
parent
7400b4f216
commit
3bdd446b07
@ -12,6 +12,8 @@ import {
|
||||
FormArray,
|
||||
} from '@angular/forms';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
|
||||
import {
|
||||
MatDialog,
|
||||
MatDialogRef,
|
||||
@ -21,6 +23,10 @@ import {
|
||||
import { MastersService } from './../../service/masters/masters.service';
|
||||
import { QuestionsService } from './../../service/questions/questions.service';
|
||||
|
||||
/*
|
||||
* Question master add details
|
||||
* : kdk
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-add',
|
||||
templateUrl: './add.component.html',
|
||||
@ -35,10 +41,19 @@ export class AddComponent implements OnInit {
|
||||
public questionsOptions: any = [];
|
||||
errorMessage: string;
|
||||
|
||||
constructor(private _formBuilder: FormBuilder,
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
|
||||
constructor(
|
||||
notifier: NotifierService,
|
||||
private _formBuilder: FormBuilder,
|
||||
private dialogRef: MatDialogRef<AddComponent>,
|
||||
private masterService: MastersService,
|
||||
private questionsService: QuestionsService) { }
|
||||
private questionsService: QuestionsService) {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
@ -55,19 +70,6 @@ export class AddComponent implements OnInit {
|
||||
// OnInit Load Category and Question Type Masters
|
||||
this.getCategoryListMaster();
|
||||
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
|
||||
@ -96,7 +98,8 @@ export class AddComponent implements OnInit {
|
||||
this.categories = data.records.filter(category => category.isactive == 1);
|
||||
},
|
||||
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;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Answer Type Records Found.!');
|
||||
this.errorMessage = "No Answer Type Record Found.";
|
||||
}
|
||||
)
|
||||
@ -134,13 +138,17 @@ export class AddComponent implements OnInit {
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
console.log(dataresult);
|
||||
alert("sample alert for Saving");
|
||||
this.notifier.notify('success', 'Record Saved Successfully.!');
|
||||
this.dialogRef.close();
|
||||
// alert("sample alert for Saving");
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
||||
}
|
||||
}, error => {
|
||||
this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Something Wents Wrong Try Again !";
|
||||
this.dialogRef.close();
|
||||
});
|
||||
//After Saving the BRANCH data then popup close
|
||||
|
||||
@ -75,7 +75,8 @@
|
||||
</li>
|
||||
</ul>-->
|
||||
<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>
|
||||
</div>
|
||||
<!--</div>-->
|
||||
|
||||
@ -23,6 +23,10 @@ import {
|
||||
import { MastersService } from './../../service/masters/masters.service';
|
||||
import { QuestionsService } from './../../service/questions/questions.service';
|
||||
|
||||
/*
|
||||
* Question master details edit component
|
||||
* : kdk
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-edit',
|
||||
templateUrl: './edit.component.html',
|
||||
@ -63,12 +67,12 @@ export class EditComponent implements OnInit {
|
||||
this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null);
|
||||
}
|
||||
}
|
||||
|
||||
// OnInit Load Category and Question Type Masters
|
||||
this.getCategoryListMaster();
|
||||
this.getQuestionOptionsMaster();
|
||||
}
|
||||
|
||||
// load answer details list
|
||||
loadAnsData() {
|
||||
if (this.data["0"].length > 0) {
|
||||
for (let val of this.data["0"]) {
|
||||
@ -79,6 +83,7 @@ export class EditComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
// load form data form the master
|
||||
loadFormData() {
|
||||
/** Questions Form Datas*/
|
||||
this._addQuesFrom = this._formBuilder.group({
|
||||
@ -94,11 +99,13 @@ export class EditComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
get f_ans() { return <FormArray>this._addQuesFrom.get('answers'); }
|
||||
|
||||
// convenience getter for easy access to form fields
|
||||
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 ===>
|
||||
initAnswers(ans, fk_id, isAct) {
|
||||
isAct = isAct == null ? 1 : isAct;
|
||||
@ -125,6 +132,7 @@ export class EditComponent implements OnInit {
|
||||
this.categories = data.records.filter(category => category.isactive == 1);
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Category Records Found.!');
|
||||
this.errorMessage = "No Category Record Found.";
|
||||
}
|
||||
)
|
||||
@ -135,6 +143,7 @@ export class EditComponent implements OnInit {
|
||||
this.questionsOptions = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Answer Type Records Found.!');
|
||||
this.errorMessage = "No Answer Type Record Found.";
|
||||
}
|
||||
)
|
||||
@ -163,17 +172,18 @@ export class EditComponent implements OnInit {
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
console.log(dataresult);
|
||||
this.notifier.notify( 'success', 'Your Changes Updated!' );
|
||||
this.notifier.notify('success', 'Your Changes Updated.!');
|
||||
this.dialogRef.close();
|
||||
// this.notifierService('success', 'You are awesome! I mean it!');
|
||||
// alert("sample alert for Saving");
|
||||
}
|
||||
else {
|
||||
this.notifier.notify( 'warning', 'Something Wents Wrong Try Again !' );
|
||||
this.errorMessage = "Something Wents Wrong Try Again !";
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
this.errorMessage = "Something Wents Wrong Try Again.!";
|
||||
}
|
||||
}, 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();
|
||||
});
|
||||
//After Saving the BRANCH data then popup close
|
||||
|
||||
@ -1,29 +1,23 @@
|
||||
<div>
|
||||
<mat-card>
|
||||
<mat-card class="mat-elevation-z1">
|
||||
<!--<mat-card-title><span> Questions Master </span></mat-card-title>
|
||||
<mat-card-subtitle> List of Questions</mat-card-subtitle>
|
||||
<mat-card-content>-->
|
||||
<div style="margin: 6px; padding: 4px;">
|
||||
<div class="p_title" style="font-size: 16px; font-style: bold;">Questions Master</div>
|
||||
<div class="sub_title" style="font-size: 11px;">List of Questions</div>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="center none">
|
||||
<div fxFlex="80%">
|
||||
<form [formGroup]="filterFormGroupCtrl">
|
||||
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5px" fxLayoutAlign="start none" style="padding: 6px;">
|
||||
<!--<mat-form-field class="example-full-width">
|
||||
<input matInput placeholder="Category" value="">
|
||||
</mat-form-field>-->
|
||||
<!--<mat-form-field>-->
|
||||
<mat-select placeholder="Category" formControlName="filterFormCtrl">
|
||||
|
||||
<mat-select placeholder="Category" formControlName="category">
|
||||
<!--<ngx-mat-select-search [formControl]="masterFilterCtrl" ></ngx-mat-select-search>-->
|
||||
<mat-option *ngFor="let cat of categories" [value]="cat.question_categroy_id" (click)="getQuestionsMasters()">
|
||||
{{cat.categroy_name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
<!--</mat-form-field>-->
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div fxFlex="20%">
|
||||
<button mat-stroked-button color="primary" (click)="addNewQuestion()">Add Questions</button>
|
||||
@ -35,7 +29,7 @@
|
||||
<ng-container *ngIf="productList.length > 0">
|
||||
<div style="padding: 0 12px;">
|
||||
<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 fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="start none">
|
||||
@ -52,7 +46,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div fxFlex="10%">
|
||||
<button mat-icon-button [matMenuTriggerFor]="menu">
|
||||
<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">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
<mat-menu #menu="matMenu">
|
||||
@ -60,7 +55,7 @@
|
||||
<mat-icon>create</mat-icon>
|
||||
<span>Edit</span>
|
||||
</button>
|
||||
</mat-menu>
|
||||
</mat-menu>-->
|
||||
</div>
|
||||
</div>
|
||||
<!--<mat-card-header>
|
||||
@ -78,23 +73,13 @@
|
||||
</mat-card>
|
||||
</div>
|
||||
</ng-container>
|
||||
<mat-card *ngIf="noQuesMasterRecrdFound">
|
||||
<div class="no-record-found">No Record Found ... </div>
|
||||
</mat-card>
|
||||
|
||||
<!--<mat-paginator
|
||||
#paginator
|
||||
[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 #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-card>
|
||||
<div class="example-container mat-elevation-z8">
|
||||
<mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
@ -44,3 +44,9 @@
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 3px #c8bbbb;
|
||||
}
|
||||
|
||||
.no-record-found {
|
||||
font-size: 18px;
|
||||
color: #03a9f4;
|
||||
padding : 12px 8px;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
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 { Observable } from 'rxjs/Observable';
|
||||
import { QuestionsService } from './../../service/questions/questions.service';
|
||||
@ -9,6 +9,10 @@ import { MastersService } from './../../service/masters/masters.service';
|
||||
import { AddComponent } from './../add/add.component';
|
||||
import { EditComponent } from './../edit/edit.component';
|
||||
|
||||
/*
|
||||
* Questions master List component
|
||||
* : kdk
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-list',
|
||||
templateUrl: './list.component.html',
|
||||
@ -20,17 +24,17 @@ export class ListComponent implements OnInit {
|
||||
public paginationList: any[] = [];
|
||||
public categories: any = [];
|
||||
public search_cid: any = null;
|
||||
public noQuesMasterRecrdFound: boolean = false;
|
||||
|
||||
public filterFormCtrl : FormControl = new FormControl();
|
||||
/** control for the MatSelect filter keyword */
|
||||
// public masterFilterCtrl: FormControl = new FormControl();
|
||||
public filterFormGroupCtrl: FormGroup;
|
||||
|
||||
// pagination variable details
|
||||
length = 50;
|
||||
pageIndex = 0;
|
||||
pageSize = 10;
|
||||
|
||||
pageEvent: PageEvent;
|
||||
|
||||
// data source variable details
|
||||
questionListData = null;
|
||||
public dataLength: number;
|
||||
public dataSource = new MatTableDataSource();
|
||||
@ -41,28 +45,46 @@ export class ListComponent implements OnInit {
|
||||
|
||||
constructor(private dialog: MatDialog,
|
||||
private questionsService: QuestionsService,
|
||||
private masterService: MastersService) {
|
||||
this.getQuestionsMasters();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
)
|
||||
private masterService: MastersService,
|
||||
private _formBuilder: FormBuilder) {
|
||||
this.filterFormGroupCtrl = this._formBuilder.group({
|
||||
category: [null, '']
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getCategorMaster();
|
||||
this.getQuestionsMasters();
|
||||
}
|
||||
|
||||
// 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(
|
||||
data => {
|
||||
@ -88,9 +110,9 @@ export class ListComponent implements OnInit {
|
||||
// add questions popup model call
|
||||
addNewQuestion() {
|
||||
const dialogRef = this.dialog.open(AddComponent, {
|
||||
data: {}
|
||||
data: {},
|
||||
disableClose: true
|
||||
});
|
||||
|
||||
dialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
this.getQuestionsMasters();
|
||||
@ -99,11 +121,12 @@ export class ListComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
// edit questions master details popup model
|
||||
editQuestion(rowDetails: any) {
|
||||
const dialogRef = this.dialog.open(EditComponent, {
|
||||
data: rowDetails
|
||||
data: rowDetails,
|
||||
disableClose: true
|
||||
});
|
||||
|
||||
dialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
this.getQuestionsMasters();
|
||||
@ -111,7 +134,7 @@ export class ListComponent implements OnInit {
|
||||
// this.isPopupOpened = false;
|
||||
});
|
||||
}
|
||||
|
||||
// padination page event call
|
||||
pageChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
@ -28,9 +28,8 @@ import { AddComponent } from './add/add.component';
|
||||
import { EditComponent } from './edit/edit.component';
|
||||
/*
|
||||
* Question Master Module details
|
||||
* : kdk
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Custom angular notifier options
|
||||
*/
|
||||
@ -42,7 +41,7 @@ const customNotifierOptions: NotifierOptions = {
|
||||
},
|
||||
vertical: {
|
||||
position: 'top',
|
||||
distance: 12,
|
||||
distance: 32,
|
||||
gap: 10
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user