template questions details master added : kdk

This commit is contained in:
dineshkumarkannan 2018-10-01 18:09:13 +05:30
parent beb703e938
commit 7400b4f216
25 changed files with 1421 additions and 0 deletions

View File

@ -31,6 +31,7 @@
"@swimlane/ngx-datatable": "11.1.5",
"amazon-cognito-identity-js": "^2.0.27",
"angular-calendar": "0.23.3",
"angular-notifier": "^4.1.1",
"angular-sortablejs": "^2.0.6",
"angular-tree-component": "6.1.0",
"chart.js": "2.6.0",
@ -47,6 +48,7 @@
"ng2-charts": "1.6.0",
"ng2-dragula": "1.3.1",
"ng2-file-upload": "1.2.1",
"ng2-toastr": "^4.1.2",
"ng2-validation": "4.2.0",
"ngx-color-picker": "^4.0.3",
"ngx-mat-select-search": "^1.3.1",

View File

@ -22,6 +22,9 @@ export const AppRoutes: Routes = [{
,{
path:'pdtrigger',
loadChildren:'./pd-triger/pd-triger.module#PdTrigerModule'
},{
path:'template',
loadChildren:'./template/template.module#TemplateModule'
}
]
}, {

View File

@ -44,6 +44,14 @@ const MENUITEMS : Menu[] = [
// children:[
// {state:'pdtriggerlist',name:'Pd Trigger Listing'}
// ]
},{
state: 'template',
name: 'Template',
type: 'sub',
icon: 'art_track',
children: [
{state: 'questions', name: 'Questions'}
]
},
{
state: 'authentication',

View File

@ -0,0 +1,77 @@
<div style="max-height: 580px;">
<mat-card style="width: 580px; padding: 6px;">
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
<div style="width: 20%;"></div>
<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>
</div>
</div>
<form [formGroup]="_addQuesFrom" (submit)="onSubmit()">
<!--<div class="form-group">-->
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-select>
<mat-error *ngIf="submitted && f.fk_question_catagory.hasError('required')" class="mat-text-warn">You must Select Category.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-select>
<mat-error *ngIf="submitted && f.fk_question_answertype.hasError('required')" class="mat-text-warn">You must Select Answer Type.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<div formArrayName="answers" class="example-full-width">
<div *ngFor="let answ of _addQuesFrom.controls.answers['controls']; let i=index">
<div [formGroupName]="i">
<div fxLayout="row" style="width: 100%">
<div style="width: 80%">
<mat-form-field class="ml-xs example-full-width">
<!--<span>Answer {{i + 1}}</span>-->
<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-form-field>
</div>
<div style="width:20%">
<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>
</span>
</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>
<!--Error List Shown Here-->
<!--<ul>
<li *ngFor="let err of errorMessage">
<mat-error>{{err.err}}</mat-error>
</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="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>
</div>
<!--</div>-->
</form>
</mat-card>
</div>

View File

@ -0,0 +1,3 @@
.example-full-width{
width: 100%;
}

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddComponent } from './add.component';
describe('AddComponent', () => {
let component: AddComponent;
let fixture: ComponentFixture<AddComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,155 @@
/** Common Imports */
import {
Component,
OnInit,
Inject
} from '@angular/core';
import {
FormBuilder,
FormGroup,
Validators,
FormArray,
} from '@angular/forms';
import {
MatDialog,
MatDialogRef,
MAT_DIALOG_DATA
} from '@angular/material';
/** Service */
import { MastersService } from './../../service/masters/masters.service';
import { QuestionsService } from './../../service/questions/questions.service';
@Component({
selector: 'app-add',
templateUrl: './add.component.html',
styleUrls: ['./add.component.scss']
})
export class AddComponent implements OnInit {
public pageTitle : string = "Add Question Details";
public _addQuesFrom: FormGroup;
public submitted = false;
public categories: any = [];
public questionsOptions: any = [];
errorMessage: string;
constructor(private _formBuilder: FormBuilder,
private dialogRef: MatDialogRef<AddComponent>,
private masterService: MastersService,
private questionsService: QuestionsService) { }
ngOnInit() {
/** Questions Form Datas*/
this._addQuesFrom = this._formBuilder.group({
question: [null, Validators.compose([Validators.required])],
description: [null, Validators.compose([Validators.required])],
fk_question_catagory: [null, Validators.compose([Validators.required])],
fk_question_answertype: [null, Validators.compose([Validators.required])],
answers: this._formBuilder.array([
this.initAnswers(),
])
});
// 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
get f() { return this._addQuesFrom.controls; }
// Dynamic Form field creation Functionality : START ===>
initAnswers() {
return this._formBuilder.group({
answer: ['', Validators.compose([Validators.required])]
});
}
addLanguage(e) {
const control = <FormArray>this._addQuesFrom.controls['answers'];
control.push(this.initAnswers());
}
removeLanguage(i: number) {
const control = <FormArray>this._addQuesFrom.controls['answers'];
control.removeAt(i);
}
// END ===>
getCategoryListMaster() {
this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe(
data => {
this.categories = data.records.filter(category => category.isactive == 1);
},
error => {
this.errorMessage = "No Category Record Found.";
}
)
}
getQuestionOptionsMaster() {
this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe(
data => {
this.questionsOptions = data.records;
},
error => {
this.errorMessage = "No Answer Type Record Found.";
}
)
}
/** For Popup Close Button */
onNoClick(): void {
this.dialogRef.close();
}
/** To Save/Edited Popup Data */
onSubmit() {
this.submitted = true;
// stop here if form is invalid
if (this._addQuesFrom.invalid) {
this.errorMessage = "Please Fill All Mandate Fields.";
return;
} else {
var answerFormValues = this._addQuesFrom.value;
//To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
//Add BRANCH data with help Service File
this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe(
dataresult => {
if (dataresult.status == 200) {
console.log(dataresult);
alert("sample alert for Saving");
}
else {
this.errorMessage = "Some Thing Wents Wrong Try Again !";
}
} , error => {
this.errorMessage = "Some Thing Wents Wrong Try Again !";
this.dialogRef.close();
});
//After Saving the BRANCH data then popup close
// this.dialogRef.close();
}
}
/** To Reset Popup Data */
onReset() {
this._addQuesFrom.reset();
}
}

View File

@ -0,0 +1,86 @@
<div style="max-height: 480px;">
<mat-card style="width: 580px; padding: 6px;">
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
<div style="width: 20%;"></div>
<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>
</div>
</div>
<form [formGroup]="_addQuesFrom" (submit)="onSubmit()">
<!--<div class="form-group">-->
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-select>
<mat-error *ngIf="submitted && f.fk_question_catagory.hasError('required')" class="mat-text-warn">You must Select Category.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<mat-form-field class="ml-xs example-full-width">
<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-select>
<mat-error *ngIf="submitted && f.fk_question_answertype.hasError('required')" class="mat-text-warn">You must Select Answer Type.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<div formArrayName="answers" class="example-full-width">
<div *ngFor="let answ of f_ans.controls; let i=index">
<div [formGroupName]="i">
<div fxLayout="row" style="width: 100%">
<div style="width: 80%">
<mat-form-field class="ml-xs example-full-width">
<!--<span>Answer {{i + 1}} </span>-->
<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-form-field>
</div>
<div style="width:20%">
<mat-checkbox *ngIf="answ.get('question_answer_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="_addQuesFrom.controls.answers.controls.length > 1" (click)="removeLanguage(i)">
<button *ngIf="answ.get('question_answer_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-button color="primary" matTooltip="Add More Answer" matTooltipPosition="above" (click)="addLanguage(null, null, null, $event); false">Add More</button>
<!--<a (click)="addLanguage()" style="cursor: default">Add another Answer </a>-->
</div>
</div>
<div fxLayout="row" fxLayoutAlign="start none">
<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>
</div>
<!--Error List Shown Here-->
<!--<ul>
<li *ngFor="let err of errorMessage">
<mat-error>{{err.err}}</mat-error>
</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="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
</div>
<!--</div>-->
</form>
</mat-card>
</div>
<notifier-container></notifier-container>

View File

@ -0,0 +1,3 @@
.example-full-width{
width: 100%;
}

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditComponent } from './edit.component';
describe('EditComponent', () => {
let component: EditComponent;
let fixture: ComponentFixture<EditComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,191 @@
/** Common Imports */
import {
Component,
OnInit,
Inject
} from '@angular/core';
import {
FormBuilder,
FormGroup,
Validators,
FormArray,
} from '@angular/forms';
import { NotifierService } from 'angular-notifier';
import {
MatDialog,
MatDialogRef,
MAT_DIALOG_DATA
} from '@angular/material';
/** Service */
import { MastersService } from './../../service/masters/masters.service';
import { QuestionsService } from './../../service/questions/questions.service';
@Component({
selector: 'app-edit',
templateUrl: './edit.component.html',
styleUrls: ['./edit.component.scss']
})
export class EditComponent implements OnInit {
public pageTitle : string = "Edit Question Details";
public _addQuesFrom: FormGroup;
public submitted = false;
public categories: any = [];
public questionsOptions: any = [];
errorMessage: string;
/**
* Notifier service
*/
private notifier: NotifierService;
constructor(
notifier: NotifierService,
private _formBuilder: FormBuilder,
private dialogRef: MatDialogRef<EditComponent>,
private masterService: MastersService,
private questionsService: QuestionsService,
@Inject(MAT_DIALOG_DATA) public data: any) {
this.notifier = notifier;
}
ngOnInit() {
this.loadFormData();
if (this.data["0"].length > 0) {
for (let val of this.data["0"]) {
// alert(JSON.stringify(val));
let vals = val;
this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null);
}
}
// OnInit Load Category and Question Type Masters
this.getCategoryListMaster();
this.getQuestionOptionsMaster();
}
loadAnsData(){
if (this.data["0"].length > 0) {
for (let val of this.data["0"]) {
// alert(JSON.stringify(val));
let vals = val;
this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null);
}
}
}
loadFormData() {
/** Questions Form Datas*/
this._addQuesFrom = this._formBuilder.group({
question_id: [this.data.question_id],
question: [this.data.question, 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_answertype: [this.data.fk_question_answertype, Validators.compose([Validators.required])],
isactive:[this.data.isactive],
answers: this._formBuilder.array([
// this.initAnswers(null, null),
])
});
}
get f_ans() { return <FormArray>this._addQuesFrom.get('answers'); }
// convenience getter for easy access to form fields
get f() { return this._addQuesFrom.controls; }
// Dynamic Form field creation Functionality : START ===>
initAnswers(ans, fk_id, isAct) {
isAct = isAct == null ? 1 : isAct;
return this._formBuilder.group({
answer: [ans, Validators.compose([Validators.required])],
question_answer_id: [fk_id],
isactive: [isAct]
});
}
addLanguage(ans, fk_id, isAct, e) {
const control = <FormArray>this._addQuesFrom.controls['answers'];
control.push(this.initAnswers(ans, fk_id, isAct));
}
removeLanguage(i: number) {
const control = <FormArray>this._addQuesFrom.controls['answers'];
control.removeAt(i);
}
// END ===>
getCategoryListMaster() {
this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe(
data => {
this.categories = data.records.filter(category => category.isactive == 1);
},
error => {
this.errorMessage = "No Category Record Found.";
}
)
}
getQuestionOptionsMaster() {
this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe(
data => {
this.questionsOptions = data.records;
},
error => {
this.errorMessage = "No Answer Type Record Found.";
}
)
}
/** For Popup Close Button */
onNoClick(): void {
this.dialogRef.close();
}
/** To Save/Edited Popup Data */
onSubmit() {
this.submitted = true;
// stop here if form is invalid
if (this._addQuesFrom.invalid) {
this.errorMessage = "Please Fill All Mandate Fields.";
return;
} else {
var answerFormValues = this._addQuesFrom.value;
//To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
//Add BRANCH data with help Service File
this.questionsService.updateQuestionMasterDetails(answerFormValues).subscribe(
dataresult => {
if (dataresult.status == 200) {
console.log(dataresult);
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 !";
}
}, error => {
this.errorMessage = "Some Thing Wents Wrong Try Again !";
this.dialogRef.close();
});
//After Saving the BRANCH data then popup close
// this.dialogRef.close();
}
}
/** To Reset Popup Data */
onReset() {
// this._addQuesFrom.reset();
this.loadFormData();
this.loadAnsData();
}
}

View File

@ -0,0 +1,134 @@
<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%">
<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">
<!--<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>
</div>
<div fxFlex="20%">
<button mat-stroked-button color="primary" (click)="addNewQuestion()">Add Questions</button>
</div>
</div>
<!--</mat-card-content>-->
</mat-card>
<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 fxFlex="90%" style="padding: 12px 8px;">
<!--<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="start none">
<div class="category-label"> {{ product.categroy_name }}</div>
</div>-->
<div fxLayout="row" fxLayoutWrap fxLayoutAlign="none none">
<div class="ml-xs" fxFlex="20%">
{{ product.categroy_name }}
</div>
<div class="ml-xs" fxFlex="80%">
<div class="text-line-limit">{{ product.question }}
</div>
</div>
</div>
</div>
<div fxFlex="10%">
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="editQuestion(product)">
<mat-icon>create</mat-icon>
<span>Edit</span>
</button>
</mat-menu>
</div>
</div>
<!--<mat-card-header>
<mat-card-title>
<h4>{{ product.question }}</h4>
</mat-card-title>
</mat-card-header>
<img mat-card-image [src]="product.img_url" [alt]="product.title" [title]="product.title">
<mat-card-content>
<p>{{ product.description }}</p>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button color="accent" (click)="addItemToCard(product)">Add to card</button>
</mat-card-actions>-->
</mat-card>
</div>
</ng-container>
<!--<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>
<!--<mat-card>
<div class="example-container mat-elevation-z8">
<mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="categroy_name">
<mat-header-cell *matHeaderCellDef mat-sort-header> Category </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.categroy_name}} </mat-cell>
</ng-container>
<ng-container matColumnDef="question">
<mat-header-cell *matHeaderCellDef mat-sort-header> Question </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.question}} </mat-cell>
</ng-container>
<ng-container matColumnDef="actions">
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
<mat-cell *matCellDef="let row">
<button mat-icon-button class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editQuestion(row)"><mat-icon>edit</mat-icon></button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;">
</mat-row>
</mat-table>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
</div>
</mat-card>-->
</mat-card>
</div>
<!--<div *ngIf="addView">
<app-add></app-add>
</div>-->
<notifier-container></notifier-container>

View File

@ -0,0 +1,46 @@
// mat table css
.example-container {
display: flex;
flex-direction: column;
min-width: 300px;
}
.example-header {
min-height: 64px;
padding: 8px 24px 0;
}
.mat-form-field {
font-size: 14px;
// width: 100%;
}
.mat-table {
overflow: auto;
max-height: 500px;
}
.text-line-limit {
text-overflow: ellipsis;
overflow: hidden;
// white-space: nowrap;
display: -webkit-box;
line-height: 16px; /* fallback */
max-height: 32px; /* fallback */
-webkit-line-clamp: 2; /* number of lines to show */
-webkit-box-orient: vertical;
// text-overflow: ellipsis;
// overflow: hidden;
// width: 160px;
// height: 1.2em;
// white-space: nowrap;
}
.category-label {
padding: 2px 6px;
background: #629cff;
color: #fff;
box-shadow: 0 2px 3px #c8bbbb;
}

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListComponent } from './list.component';
describe('ListComponent', () => {
let component: ListComponent;
let fixture: ComponentFixture<ListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,119 @@
import { Component, ViewChild, OnInit } from '@angular/core';
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent} from '@angular/material';
import { FormGroup, FormControl } from '@angular/forms';
import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable';
import { QuestionsService } from './../../service/questions/questions.service';
import { MastersService } from './../../service/masters/masters.service';
/** Dialog Component */
import { AddComponent } from './../add/add.component';
import { EditComponent } from './../edit/edit.component';
@Component({
selector: 'app-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.scss']
})
export class ListComponent implements OnInit {
public productList: any[] = [];
public paginationList: any[] = [];
public categories: any = [];
public search_cid :any = null;
public filterFormCtrl : FormControl = new FormControl();
/** control for the MatSelect filter keyword */
// public masterFilterCtrl: FormControl = new FormControl();
length = 50;
pageIndex = 0;
pageSize = 10;
pageEvent: PageEvent;
questionListData = null;
public dataLength: number;
public dataSource = new MatTableDataSource();
displayedColumns = ['categroy_name', 'question', 'actions'];
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
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;
}
)
}
ngOnInit() {
this.getCategorMaster();
}
getCategorMaster() {
this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe(
data => {
this.categories = data.records.filter(category => category.isactive == 1);
},
error => {
// this.errorMessage = "No Category Record Found.";
}
)
}
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
applyFilter(filterValue: string) {
filterValue = filterValue.trim(); // Remove whitespace
filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches
this.dataSource.filter = filterValue;
}
// add questions popup model call
addNewQuestion() {
const dialogRef = this.dialog.open(AddComponent, {
data: {}
});
dialogRef.afterClosed()
.subscribe(dataresult => {
this.getQuestionsMasters();
// this.getBranch();
// this.isPopupOpened = false;
});
}
editQuestion(rowDetails: any){
const dialogRef = this.dialog.open(EditComponent, {
data: rowDetails
});
dialogRef.afterClosed()
.subscribe(dataresult => {
this.getQuestionsMasters();
// this.getBranch();
// this.isPopupOpened = false;
});
}
pageChange(e) {
console.log(e);
}
}

View File

@ -0,0 +1,109 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NotifierModule, NotifierOptions } from 'angular-notifier';
import { FlexLayoutModule } from '@angular/flex-layout';
import {
MatCardModule,
MatIconModule,
MatInputModule,
MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule,
MatProgressBarModule,MatDialogModule, MatSortModule,
MatToolbarModule,MatSelectModule,
MatListModule, MatMenuModule,
MatCheckboxModule
} from '@angular/material';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
// Questions Routing import
import { QuestionsRouting } from './questions.routing';
// Questions List
import { ListComponent } from './list/list.component';
import { QuestionsService } from './../service/questions/questions.service';
import { AddComponent } from './add/add.component';
import { EditComponent } from './edit/edit.component';
/*
* Question Master Module details
*/
/**
* Custom angular notifier options
*/
const customNotifierOptions: NotifierOptions = {
position: {
horizontal: {
position: 'right',
distance: 12
},
vertical: {
position: 'top',
distance: 12,
gap: 10
}
},
theme: 'material',
behaviour: {
autoHide: 5000,
onClick: 'hide',
onMouseover: 'pauseAutoHide',
showDismissButton: true,
stacking: 4
},
animations: {
enabled: true,
show: {
preset: 'slide',
speed: 300,
easing: 'ease'
},
hide: {
preset: 'fade',
speed: 300,
easing: 'ease',
offset: 50
},
shift: {
speed: 300,
easing: 'ease'
},
overlap: 150
}
};
@NgModule({
imports: [
CommonModule,
NotifierModule.withConfig(customNotifierOptions),
FlexLayoutModule,
MatCardModule,
MatIconModule,
MatInputModule,
MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule,
MatProgressBarModule,MatDialogModule, MatSortModule,
MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule,
MatSlideToggleModule,
MatCheckboxModule,
FormsModule,
ReactiveFormsModule,
QuestionsRouting
],
declarations: [
ListComponent,
AddComponent,
EditComponent
],
entryComponents: [
AddComponent,
EditComponent
],
providers: [
QuestionsService
]
})
export class QuestionsModule { }

View File

@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
// Questions List
import { ListComponent } from './list/list.component';
/*
* Question Master Router Module details
*/
const routes: Routes = [
{
path: '',
component: ListComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class QuestionsRouting {}

View File

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { MastersService } from './masters.service';
describe('MastersService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [MastersService]
});
});
it('should be created', inject([MastersService], (service: MastersService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -0,0 +1,223 @@
/** Common Import Section */
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';//for Datatables
import { HttpClient } from '@angular/common/http';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs';
/** Imported Service Files Are., */
import { AwsService } from '../../../AwsService/aws.service';
//import { environment } from 'environments/environment';
/** Consant Value For Created Date And Updated Date */
const currentdate = new Date().toJSON().slice(0,19).replace('T',' ');
/** Master Interface */
export interface Master {
master_id:number;
master_name:string;
constant_name:string;
}
@Injectable()
export class MastersService {
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
constructor(private _http: HttpClient,
private _aws:AwsService) { }
//headers:any = this._shared.headercofig('');
/**
* TO Add Master Datas using API Call
* 1st argument is "Records": any - Set of Data To Adding to database
* 2nd argument is "MasterName" :string - Table Name To Store the Records
*/
addMasterDetails(Records: any,MasterName:string): Observable<any> {
Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record
if(MasterName == 'COMPANY'){
Records.company_master_createdon = currentdate;//to get Current date and Time for when the Record is created
}
else{
Records.createdon = currentdate;//to get Current date and Time for when the Record is created
}
var ArrayData = { "master_name":MasterName,
"records": Records }
// var data = this._http.post(this.apiUrl+'saveMaster',ArrayData);
// console.log('from service',data);
return this._http.post<any>(this.apiUrl+"saveMaster", ArrayData)
.pipe(
catchError(this.handleError('role', []))
)
// return data;
}
/**
* TO Edit Master Datas using API Call
* 1st argument is "Records": any - Set of Updated Data
* 2nd argument is "MasterName" :string - Table Name
*/
editMasterDetails(Records: any,MasterName:string): Observable<any> {
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated
var ArrayData = { "master_name":MasterName,
"records": Records }
var data = this._http.post(this.apiUrl+'saveMaster',ArrayData);
return data;
}
/**
* TO Inactive the Master Datas using API Call
* Note : Which means To delete The records
* 1st argument is "PrimaryKeyWithValue" : any - Primarykey and its value
* 2nd argument is "MasterName" :string - Table Name
*/
deleteMasterDetails(PrimaryKeyWithValue:any,MasterName:string): Observable<any> {
//This "otherDatas" Array is common Argument For All Master
let otherDatas:any = {isactive:0,
fk_updatedby:this._aws.getlocale(),
updatedon:currentdate}
//This "dataWithPrimaryKey" Array is Mergeing The 'PrimaryKeyWithValue' argument with otherDatas
let dataWithPrimaryKey = Object.assign(otherDatas,PrimaryKeyWithValue);
var ArrayData = { "master_name":MasterName,
"records":JSON.parse(JSON.stringify(dataWithPrimaryKey))
}
return this._http.post(this.apiUrl+'saveMaster',ArrayData).pipe(
catchError(this.handleError('role', []))
);
// alert(data);
// return data;
}
/**
* TO Get the Master Datas using API Call
* 1st argument is "TableName" :string - Table Name
*/
getAllMasterData(TableName:string): Observable<any> {
return this._http.post<any>(this.apiUrl+"getListOfMaster", { "master_name":TableName })
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO get Branch Data For Listing Screen
*/
getAllBranch(): Observable<any> {
return this._http.get(this.apiUrl+'getListOfBranches')
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO get Subproduct Data For Listing Screen
*/
getAllSubProduct(): Observable<any> {
return this._http.get(this.apiUrl+'getListOfSubProduct')
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO get State Data For Listing Screen
*/
getAllState(): Observable<any> {
return this._http.get(this.apiUrl+'getListOfState')
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO get Company Data For Listing Screen
*/
getAllCompany(): Observable<any> {
return this._http.get(this.apiUrl+'getListOfCompany')
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO get City Data For Listing Screen
*/
getAllCity(): Observable<any> {
return this._http.get(this.apiUrl+'getListOfCity')
.pipe(
catchError(this.handleError('role', []))
)
}
/** Get All EntityType Data using API call With master Keyword */
// getAllEntityType(): Observable<any> {
// var EntityTypeArr = {
// "master_name":"ENTITYTYPE",
// }
// return this._http.post(this.apiUrl+'getListOfMaster',EntityTypeArr,{headers:this.headers})
// .pipe(
// catchError(this.handleError('role', []))
// )
// }
/**
* Seperated Records from the res
* argument 'res' : Response
*/
private extractData(res : Response) {
let Response = res['_body'];
Response = JSON.parse(Response);
return Response['dataStatus'] === true
? Response['records']
: [];
}
/**
* TO Handle The Error
*/
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
};
}
addCompanyDetails
}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { QuestionsService } from './questions.service';
describe('QuestionsService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: QuestionsService = TestBed.get(QuestionsService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,70 @@
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'
})
/*
* Add , Edit, List, Delete Question Master API service End-point Call Functionality
* Kdk
*/
export class QuestionsService {
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
private serviceUrl = 'https://jsonplaceholder.typicode.com/users';
constructor(private _http: HttpClient,
private _aws: AwsService) { }
getUser(): Observable<any> {
return this._http.get<any[]>(this.serviceUrl);
}
// get questions master details list
getQuestionMasterDetails(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 + "listAllQuestions/get", options);
}
// add question master
addQuestionMasterDetails(Records: any): Observable<any> {
Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record
Records.createdon = currentdate;//to get Current date and Time for when the Record is created
return this._http.post<any>(this.apiUrl + "saveNewQuestion", { 'records': Records})
.pipe(
catchError(this.handleError('role', []))
)
}
updateQuestionMasterDetails(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 + "saveExistQuestion", { 'records': Records})
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO Handle The Error
*/
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
};
}
}

View File

@ -0,0 +1,54 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {
MatCardModule,
MatIconModule,
MatInputModule,
MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule,
MatProgressBarModule,MatDialogModule, MatSortModule,
MatToolbarModule,MatSelectModule } from '@angular/material';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
import { TreeModule } from 'angular-tree-component';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
import { FlexLayoutModule } from '@angular/flex-layout';
import { DemoMaterialModule } from '../shared/demo.module';
// import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
import 'hammerjs';
import { RouterModule } from '@angular/router';
import { QuestionsModule } from './questions/questions.module';
/** Template Routes */
import { TemplateRoutes } from './template.routing';
/** Master Service */
import { MastersService } from './service/masters/masters.service';
// import { HttpClientModule } from '@angular/common/http';
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(TemplateRoutes),
QuestionsModule,
MatCardModule,
MatIconModule,
MatInputModule,
MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule,
MatProgressBarModule,MatDialogModule, MatSortModule,
MatToolbarModule,MatSelectModule,
FormsModule,ReactiveFormsModule,
// HttpClientModule,
],
providers:[
MastersService
]
})
export class TemplateModule { }

View File

@ -0,0 +1,11 @@
import { Routes } from '@angular/router';
import { QuestionsModule } from './questions/questions.module';
export const TemplateRoutes: Routes = [{
path: '',
children:[{
path:'questions',
loadChildren:'./questions/questions.module#QuestionsModule'
}
]
}]

View File

@ -45,3 +45,6 @@ Author: TrendSetter Themes
@import "scss/material";
@import "scss/utilities/utilities";
/* Add application styles & imports to this file! */
@import "~angular-notifier/styles";

3
package-lock.json generated Normal file
View File

@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}