Merge branch 'master' of https://bitbucket.org/sriramv18/sparqsineedge
This commit is contained in:
commit
5e5e07d471
10
ng6-seed/package-lock.json
generated
10
ng6-seed/package-lock.json
generated
@ -950,6 +950,11 @@
|
||||
"resolved": "https://registry.npmjs.org/angular-draggable-droppable/-/angular-draggable-droppable-2.0.0.tgz",
|
||||
"integrity": "sha512-/b8LIGamjOKnDI2uG1jRUErTIHeQ3w2WqHn4cbeiUTy+6eNHjkQI32DNhvxl0nVxr2gF5QluECNB4uWjMMyzQg=="
|
||||
},
|
||||
"angular-notifier": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/angular-notifier/-/angular-notifier-4.1.1.tgz",
|
||||
"integrity": "sha512-QrL5cW3GDjONy6Ack+HIgd3tUf93ztkPT6C551/pqOaE69Ad2YDem+JyBLnlLKBnCFUxhKkSVnv/Ak2HsOrBxQ=="
|
||||
},
|
||||
"angular-resizable-element": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/angular-resizable-element/-/angular-resizable-element-2.0.0.tgz",
|
||||
@ -7203,6 +7208,11 @@
|
||||
"resolved": "https://registry.npmjs.org/ng2-file-upload/-/ng2-file-upload-1.2.1.tgz",
|
||||
"integrity": "sha1-VWPF39b0P7++gVwgbjQ0ZKCmoZc="
|
||||
},
|
||||
"ng2-toastr": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ng2-toastr/-/ng2-toastr-4.1.2.tgz",
|
||||
"integrity": "sha1-G0UvBxOZYcOPhmxuJKBiR++iGxE="
|
||||
},
|
||||
"ng2-validation": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ng2-validation/-/ng2-validation-4.2.0.tgz",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -22,6 +22,9 @@ export const AppRoutes: Routes = [{
|
||||
,{
|
||||
path:'pdtrigger',
|
||||
loadChildren:'./pd-triger/pd-triger.module#PdTrigerModule'
|
||||
},{
|
||||
path:'template',
|
||||
loadChildren:'./template/template.module#TemplateModule'
|
||||
}
|
||||
]
|
||||
}, {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<mat-card class="p-1">
|
||||
<form [formGroup]="PDtriggerForm" (submit)="submitPdDetails()">
|
||||
<form [formGroup]="PDtriggerForm" (submit)="submitPdDetails(PDtriggerForm.value)">
|
||||
<mat-card-content>
|
||||
<div class="mb-2"></div>
|
||||
<div fxLayout="row" fxLayoutWrap="wrap">
|
||||
@ -66,16 +66,16 @@
|
||||
<input matInput placeholder="Loan Amount" [formControl]="PDtriggerForm.controls['loan_amount']">
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<input matInput placeholder="Address 1" [formControl]="PDtriggerForm.controls['addressline1']">
|
||||
<textarea matInput placeholder="Address 1" [formControl]="PDtriggerForm.controls['addressline1']"></textarea>
|
||||
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width: 100%">
|
||||
<input matInput placeholder="Address 2" [formControl]="PDtriggerForm.controls['addressline2']">
|
||||
<textarea matInput placeholder="Address 2" [formControl]="PDtriggerForm.controls['addressline2']"></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width: 100%">
|
||||
<input matInput placeholder="Address 3" [formControl]="PDtriggerForm.controls['addressline3']">
|
||||
<textarea matInput placeholder="Address 3" [formControl]="PDtriggerForm.controls['addressline3']"></textarea>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%;">
|
||||
<mat-select placeholder="Select City" [formControl]="PDtriggerForm.controls['fk_city']" >
|
||||
@ -146,19 +146,53 @@
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutWrap="wrap">
|
||||
|
||||
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="30" fxFlex.lg="50" fxFlex.xl="30">
|
||||
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
|
||||
<mat-card class="p-2" style="opacity: 0.5;">
|
||||
<!-- <button _ngcontent-c29="" class="mr-1 mb-2 mat-fab1 mat-accent" mat-fab="" (click)="addCoApplicant(createWithLongContent)"><span class="mat-button-wrapper"><mat-icon _ngcontent-c29="" class="mat-icon material-icons" role="img" aria-hidden="true">add</mat-icon></span><div class="mat-button-ripple mat-ripple mat-button-ripple-round" matripple=""></div><div class="mat-button-focus-overlay"></div></button> -->
|
||||
<button _ngcontent-c39="" class="mr-1 mb-1 mat-button" mat-button=""><span style="opacity: 0.5;" (click)="addCoApplicant()" class="mat-button-wrapper">Add More Co-Applicant</span><div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat-button-focus-overlay"></div></button>
|
||||
<button _ngcontent-c39="" class="mr-1 mb-1 mat-button" type="button"><span style="opacity: 0.5;" (click)="addCoApplicant()" class="mat-button-wrapper">Add More Co-Applicant</span><div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat-button-focus-overlay"></div></button>
|
||||
<!-- <button mat-raised-button mat-button-sm color="primary" (click)="addCoApplicant()" type="button">Add More Co-Applicant</button> -->
|
||||
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutWrap="wrap">
|
||||
|
||||
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
|
||||
|
||||
<mat-card class="p-2" formArrayName="documents">
|
||||
<mat-list>
|
||||
<mat-list-item>
|
||||
<!-- <button mat-raised-button mat-button-sm color="primary" type="button">Add Document</button> -->
|
||||
<button _ngcontent-c39="" class="mr-1 mb-1 mat-button" type="button"><span style="opacity: 0.5;" (click)="addMoreDocs()" class="mat-button-wrapper">Add Document</span><div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat-button-focus-overlay"></div></button>
|
||||
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
<mat-list *ngFor="let docList of documents.controls; let d = index;" [formGroupName]="d">
|
||||
<!-- <h3 mat-subheader>Upload Documents</h3> -->
|
||||
<mat-list-item>
|
||||
<mat-form-field style="width: 100%">
|
||||
<input matInput placeholder="Document Name" formControlName="doc_name" type="text">
|
||||
</mat-form-field>
|
||||
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<input type="file" title="Browse Document" (change)="fileSelectionEvent($event,d)" formControlName="documentFile">
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button color="accent" (click)="removeItem(d)" type="button">Remove</button>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" type="submit" [disabled]="!PDtriggerForm.valid">Submit</button>
|
||||
<hr>
|
||||
<mat-card-actions style="text-align: right">
|
||||
<button mat-button color="accent" type="button" (click)="loadPdListCompoent()">Cancel</button>
|
||||
|
||||
<button mat-button color="primary" type="submit" [disabled]="!PDtriggerForm.valid">Submit</button>
|
||||
</mat-card-actions>
|
||||
</form>
|
||||
</mat-card>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, OnInit, ViewEncapsulation, Output, EventEmitter } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms';
|
||||
import { CustomValidators } from 'ng2-validation';
|
||||
import { PdTrigerService } from '../pd-service/pd-triger.service';
|
||||
import { AwsService } from '../../AwsService/aws.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-add-pd',
|
||||
@ -10,6 +11,8 @@ import { PdTrigerService } from '../pd-service/pd-triger.service';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AddPdComponent implements OnInit {
|
||||
@Output() loadParent = new EventEmitter<string>();
|
||||
|
||||
public PDtriggerForm: FormGroup;
|
||||
items: FormArray;
|
||||
CityList: any;
|
||||
@ -25,10 +28,14 @@ export class AddPdComponent implements OnInit {
|
||||
// Dynamic co applicant
|
||||
createWithLongContent = false;
|
||||
dynamicCoApplicant = [];
|
||||
constructor(private _fb: FormBuilder,
|
||||
private _pd: PdTrigerService) { }
|
||||
|
||||
constructor(private _fb: FormBuilder,
|
||||
private _pd: PdTrigerService, private _aws:AwsService) { }
|
||||
public totalfiles: Array<File> =[];
|
||||
public totalFileName = [];
|
||||
public lengthCheckToaddMore =0;
|
||||
ngOnInit() {
|
||||
|
||||
this.PDtriggerForm = this._fb.group({
|
||||
fk_lender_id: [null, Validators.compose([Validators.required])],
|
||||
lender_applicant_id: [null, Validators.compose([Validators.required])],
|
||||
@ -36,7 +43,7 @@ export class AddPdComponent implements OnInit {
|
||||
fk_subproduct_id: [null, Validators.compose([Validators.required])],
|
||||
fk_pd_type: [null, Validators.compose([Validators.required])],
|
||||
fk_customer_segment: [null, Validators.compose([Validators.required])],
|
||||
loan_amount: [null],
|
||||
loan_amount: [null, Validators.compose([Validators.required])],
|
||||
applicant_name: [null, Validators.compose([Validators.required])],
|
||||
mobile_no: [null, Validators.compose([Validators.required])],
|
||||
email: [null, Validators.compose([Validators.required, CustomValidators.email])],
|
||||
@ -45,8 +52,9 @@ export class AddPdComponent implements OnInit {
|
||||
addressline3: [null],
|
||||
fk_city: [null, Validators.compose([Validators.required])],
|
||||
fk_state: [null, Validators.compose([Validators.required])],
|
||||
pincode : [null],
|
||||
items: this._fb.array([])
|
||||
pincode : [null, Validators.compose([Validators.required])],
|
||||
items: this._fb.array([]),
|
||||
documents: this._fb.array([])
|
||||
});
|
||||
|
||||
this._pd.getAllMasterDatas('CITY')
|
||||
@ -142,11 +150,135 @@ this._pd.getAllMasterDatas('PDTYPE')
|
||||
this.items.push(this.createItem());
|
||||
}
|
||||
}
|
||||
submitPdDetails() {
|
||||
if(this.PDtriggerForm.valid){
|
||||
var my_array = this.PDtriggerForm.value;
|
||||
Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]);
|
||||
|
||||
addMoreDocs() {
|
||||
if(this.totalfiles.length!=0){
|
||||
|
||||
|
||||
if( this.documents.value[0].doc_name != "" && ((this.lengthCheckToaddMore) === (this.totalfiles.length)) )
|
||||
{
|
||||
this.documents.insert(0, this.generateDocuments())
|
||||
this.lengthCheckToaddMore=this.lengthCheckToaddMore+1;
|
||||
}
|
||||
}
|
||||
else if(this.totalfiles.length===0 && this.lengthCheckToaddMore===0){
|
||||
this.documents.insert(0, this.generateDocuments())
|
||||
this.lengthCheckToaddMore=this.lengthCheckToaddMore+1;
|
||||
}
|
||||
}
|
||||
generateDocuments(): FormGroup {
|
||||
return this._fb.group({
|
||||
doc_name: [null, Validators.compose([Validators.required])],
|
||||
documentFile : [null, Validators.compose([Validators.required])],
|
||||
});
|
||||
}
|
||||
|
||||
get documents(): FormArray {
|
||||
return this.PDtriggerForm.get('documents') as FormArray;
|
||||
};
|
||||
|
||||
removeItem(index: number) {
|
||||
this.totalfiles.splice(index,1);
|
||||
this.totalFileName.splice(index,1);
|
||||
this.documents.removeAt(index);
|
||||
this.lengthCheckToaddMore=this.lengthCheckToaddMore-1;
|
||||
}
|
||||
|
||||
public fileSelectionEvent(fileInput: any,oldIndex:number) {
|
||||
|
||||
|
||||
if (fileInput.target.files && fileInput.target.files[0]) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = (event: any) => {
|
||||
}
|
||||
|
||||
if(oldIndex==0)
|
||||
{
|
||||
this.totalfiles.unshift((fileInput.target.files[0]))
|
||||
this.totalFileName.unshift(fileInput.target.files[0].name)
|
||||
}
|
||||
else
|
||||
{
|
||||
this.totalfiles[oldIndex]=(fileInput.target.files[0]);
|
||||
this.totalFileName[oldIndex]=fileInput.target.files[0].name
|
||||
}
|
||||
|
||||
reader.readAsDataURL(fileInput.target.files[0]);
|
||||
}
|
||||
|
||||
if(this.totalfiles.length == 1)
|
||||
{
|
||||
this.lengthCheckToaddMore=1;
|
||||
}
|
||||
}
|
||||
submitPdDetails(formValue: any) {
|
||||
if(this.PDtriggerForm.valid){
|
||||
// let my_array = this.PDtriggerForm.value;
|
||||
// Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]);
|
||||
let pd_details:any={
|
||||
"fk_lender_id":formValue.fk_lender_id,
|
||||
"lender_applicant_id":formValue.lender_applicant_id,
|
||||
"fk_product_id":formValue.fk_product_id.product_id,
|
||||
"fk_subproduct_id":formValue.fk_subproduct_id.subproduct_id,
|
||||
"fk_pd_type":formValue.fk_pd_type,
|
||||
"fk_customer_segment":formValue.fk_customer_segment,
|
||||
"loan_amount":formValue.loan_amount,
|
||||
"addressline1":formValue.addressline1,
|
||||
"addressline2":formValue.addressline2,
|
||||
"addressline3":formValue.addressline3,
|
||||
"fk_city":formValue.fk_city.city_id,
|
||||
"fk_state":formValue.fk_state.state_id,
|
||||
"pincode ":formValue.pincode ,
|
||||
"fk_createdby" : this._aws.getlocale(),
|
||||
"createdon": new Date().toJSON().slice(0,19).replace('T',' ')
|
||||
};
|
||||
let pd_applicant_details : any=[{
|
||||
"applicant_name":formValue.applicant_name,
|
||||
"email":formValue.email,
|
||||
"mobile_no":formValue.mobile_no,
|
||||
"applicant_type":1,
|
||||
"relationship":"",
|
||||
}];
|
||||
formValue.items.forEach((itemElement, itemIndex) => {
|
||||
let obj1 = {
|
||||
"applicant_name":itemElement.coapplicantName,
|
||||
"relationship":itemElement.relationship,
|
||||
"email":"",
|
||||
"mobile_no":"",
|
||||
"applicant_type":0,
|
||||
}
|
||||
pd_applicant_details.push(obj1)
|
||||
});
|
||||
|
||||
// docs details
|
||||
let pd_form: FormData = new FormData();
|
||||
|
||||
for(let j=0;j<this.totalfiles.length; j++)
|
||||
{
|
||||
|
||||
pd_form.append(this.totalFileName[j],<File>this.totalfiles[j])
|
||||
}
|
||||
|
||||
//reverseFileNames=this.totalFileName.reverse();
|
||||
|
||||
let AllFilesObj= []
|
||||
|
||||
formValue.documents.forEach((element, index) => {
|
||||
// let eachObj=
|
||||
// {
|
||||
// 'doc_name' : element.doc_name,
|
||||
// 'file_name' : this.totalFileName[index]
|
||||
// }
|
||||
AllFilesObj.push(element.doc_name);
|
||||
});
|
||||
pd_form.append("pd_details",JSON.stringify(pd_details))
|
||||
pd_form.append("pd_applicant_details",JSON.stringify(pd_applicant_details))
|
||||
pd_form.append("pd_document_titles",JSON.stringify(AllFilesObj))
|
||||
|
||||
this._pd.addPdDetails(pd_form).subscribe();
|
||||
}
|
||||
}
|
||||
loadPdListCompoent() {
|
||||
this.loadParent.emit('1')
|
||||
}
|
||||
}
|
||||
|
||||
11
ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html
Normal file
11
ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html
Normal file
@ -0,0 +1,11 @@
|
||||
<mat-card class="p-1">
|
||||
|
||||
<mat-card-content>
|
||||
{{ childData }}
|
||||
</mat-card-content>
|
||||
<hr>
|
||||
<mat-card-actions>
|
||||
<button mat-button color="accent" type="button" (click)="loadPdListCompoent()">Cancel</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
||||
25
ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts
Normal file
25
ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EditPdComponent } from './edit-pd.component';
|
||||
|
||||
describe('EditPdComponent', () => {
|
||||
let component: EditPdComponent;
|
||||
let fixture: ComponentFixture<EditPdComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EditPdComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EditPdComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
23
ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts
Normal file
23
ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Component, OnInit,ViewEncapsulation, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ListPdComponent } from '../list-pd/list-pd.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-pd',
|
||||
templateUrl: './edit-pd.component.html',
|
||||
styleUrls: ['./edit-pd.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class EditPdComponent implements OnInit {
|
||||
@Input() childData: string;
|
||||
@Output() loadParent = new EventEmitter<string>();
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
loadPdListCompoent() {
|
||||
this.loadParent.emit('2')
|
||||
}
|
||||
|
||||
}
|
||||
171
ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html
Normal file
171
ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html
Normal file
@ -0,0 +1,171 @@
|
||||
<div align="right" *ngIf="showParentComponent">
|
||||
<button mat-button (click)="addPdDetails()" color="primary">ADD PD</button>
|
||||
</div>
|
||||
<mat-card *ngIf="showParentComponent">
|
||||
<mat-tab-group>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>All PD Details</ng-template>
|
||||
<mat-card-content>
|
||||
<div class="card-comment-widget">
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let details of pdList">
|
||||
<img mat-list-avatar src="assets/images/face3.jpg" alt="">
|
||||
<p mat-line>{{details.applicat_details[0].applicant_name}} </p>
|
||||
|
||||
<p mat-line>{{details.lender_applicant_id}} {{details.pd_date_of_initiation}}</p>
|
||||
<p mat-line>{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}} <i class="fa-1x fa fa-dollar"> </i>{{details.loan_amount}} <i class="fa-1x fa fa-map-marker"> </i> {{details.state_name}}/{{details.city_name}}</p>
|
||||
<!-- <span class="text-mat mat-text-muted">Chennai</span> -->
|
||||
|
||||
<div class="comment-time">
|
||||
<!-- <a> <i class="fa ic-change fa-edit fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="primary" (click)="editPdDetails(details.pd_id)"><mat-icon>edit</mat-icon></button>
|
||||
|
||||
</div>
|
||||
<div class="comment-time">
|
||||
|
||||
<!-- <a> <i class="fa ic-change fa-eye fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="accent"><mat-icon>visibility</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</mat-list-item>
|
||||
<hr>
|
||||
<mat-list-item *ngFor="let details of pdList">
|
||||
<img mat-list-avatar src="assets/images/face3.jpg" alt="">
|
||||
<p mat-line>{{details.applicat_details[0].applicant_name}} </p>
|
||||
|
||||
<p mat-line>{{details.lender_applicant_id}} {{details.pd_date_of_initiation}}</p>
|
||||
<p mat-line>{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}} <i class="fa-1x fa fa-dollar"> </i>{{details.loan_amount}} <i class="fa-1x fa fa-map-marker"> </i> {{details.state_name}}/{{details.city_name}}</p>
|
||||
<!-- <span class="text-mat mat-text-muted">Chennai</span> -->
|
||||
|
||||
<div class="comment-time">
|
||||
<!-- <a> <i class="fa ic-change fa-edit fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="primary"><mat-icon>edit</mat-icon></button>
|
||||
|
||||
</div>
|
||||
<div class="comment-time">
|
||||
|
||||
<!-- <a> <i class="fa ic-change fa-eye fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="accent"><mat-icon>visibility</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</mat-list-item>
|
||||
<hr>
|
||||
<mat-list-item *ngFor="let details of pdList">
|
||||
<img mat-list-avatar src="assets/images/face3.jpg" alt="">
|
||||
<p mat-line>{{details.applicat_details[0].applicant_name}} </p>
|
||||
|
||||
<p mat-line>{{details.lender_applicant_id}} {{details.pd_date_of_initiation}}</p>
|
||||
<p mat-line>{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}} <i class="fa-1x fa fa-dollar"> </i>{{details.loan_amount}} <i class="fa-1x fa fa-map-marker"> </i> {{details.state_name}}/{{details.city_name}}</p>
|
||||
<!-- <span class="text-mat mat-text-muted">Chennai</span> -->
|
||||
|
||||
<div class="comment-time">
|
||||
<!-- <a> <i class="fa ic-change fa-edit fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="primary"><mat-icon>edit</mat-icon></button>
|
||||
|
||||
</div>
|
||||
<div class="comment-time">
|
||||
|
||||
<!-- <a> <i class="fa ic-change fa-eye fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="accent"><mat-icon>visibility</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</mat-list-item>
|
||||
<hr>
|
||||
<mat-list-item *ngFor="let details of pdList">
|
||||
<img mat-list-avatar src="assets/images/face3.jpg" alt="">
|
||||
<p mat-line>{{details.applicat_details[0].applicant_name}} </p>
|
||||
|
||||
<p mat-line>{{details.lender_applicant_id}} {{details.pd_date_of_initiation}}</p>
|
||||
<p mat-line>{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}} <i class="fa-1x fa fa-dollar"> </i>{{details.loan_amount}} <i class="fa-1x fa fa-map-marker"> </i> {{details.state_name}}/{{details.city_name}}</p>
|
||||
<!-- <span class="text-mat mat-text-muted">Chennai</span> -->
|
||||
|
||||
<div class="comment-time">
|
||||
<!-- <a> <i class="fa ic-change fa-edit fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="primary"><mat-icon>edit</mat-icon></button>
|
||||
|
||||
</div>
|
||||
<div class="comment-time">
|
||||
|
||||
<!-- <a> <i class="fa ic-change fa-eye fa-lg"></i></a> -->
|
||||
<button mat-raised-button mat-icon-button mat-button-sm class="mr-1 mb-1" color="accent"><mat-icon>visibility</mat-icon></button>
|
||||
|
||||
</div>
|
||||
</mat-list-item>
|
||||
<hr>
|
||||
|
||||
|
||||
</mat-list>
|
||||
|
||||
</div>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-button (click)="addTileCols()" color="primary">ADD COLSPAN (THREE)</button>
|
||||
</mat-card-actions>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>Confirmed PD Details</ng-template>
|
||||
<mat-card-content>
|
||||
<mat-grid-list cols="2" [rowHeight]="ratio" gutterSize="4px">
|
||||
<mat-grid-tile *ngFor="let tile of tiles" [style.background]="'lightblue'">
|
||||
{{tile.text}}
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="mt-2">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Change ratio" [(ngModel)]="ratio">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>In Progress PD Details</ng-template>
|
||||
<mat-card-content>
|
||||
<mat-grid-list cols="2" rowHeight="fit" [gutterSize]="ratioGutter"
|
||||
[style.height]="fitListHeight">
|
||||
<mat-grid-tile *ngFor="let tile of tiles" [style.background]="'#F1EBBA'">
|
||||
{{tile.text}}
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="mt-2">
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Change list height" [(ngModel)]="fitListHeight">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Change gutter" type="number" [(ngModel)]="ratioGutter">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-tab>
|
||||
<!-- <mat-tab>
|
||||
<ng-template mat-tab-label>Headers</ng-template>
|
||||
<mat-card-content class="pa-0">
|
||||
<mat-grid-list cols="3" rowHeight="200px">
|
||||
<mat-grid-tile *ngFor="let dog of dogs" style="background:gray">
|
||||
<mat-grid-tile-header>
|
||||
<mat-icon mat-grid-avatar>info_outline</mat-icon>
|
||||
{{dog.name}}
|
||||
</mat-grid-tile-header>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
</mat-card-content>
|
||||
</mat-tab>
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>Footers</ng-template>
|
||||
<mat-card-content class="pa-0">
|
||||
<mat-grid-list cols="3" rowHeight="200px">
|
||||
<mat-grid-tile *ngFor="let dog of dogs">
|
||||
<img [alt]="dog.name" src="https://material.angularjs.org/material2_assets/ngconf/{{dog.name}}.png">
|
||||
<mat-grid-tile-footer>
|
||||
<h3 mat-line>{{dog.name}}</h3>
|
||||
<span mat-line>Human: {{dog.human}}</span>
|
||||
<mat-icon>star_border</mat-icon>
|
||||
</mat-grid-tile-footer>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
</mat-card-content>
|
||||
</mat-tab> -->
|
||||
</mat-tab-group>
|
||||
</mat-card>
|
||||
|
||||
<app-edit-pd *ngIf="showEditComponent" [childData]="parentEditData" (loadParent)="updateParentComponent($event)"></app-edit-pd>
|
||||
<app-add-pd *ngIf="showAddComponent" (loadParent)="updateParentComponent($event)"></app-add-pd>
|
||||
@ -0,0 +1,5 @@
|
||||
.ic-change:hover {
|
||||
transform: scale(1.1);
|
||||
color: green;
|
||||
}
|
||||
|
||||
25
ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts
Normal file
25
ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ListPdComponent } from './list-pd.component';
|
||||
|
||||
describe('ListPdComponent', () => {
|
||||
let component: ListPdComponent;
|
||||
let fixture: ComponentFixture<ListPdComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ListPdComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ListPdComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
115
ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts
Normal file
115
ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts
Normal file
@ -0,0 +1,115 @@
|
||||
import { Component, OnInit, ViewEncapsulation, EventEmitter, Output } from '@angular/core';
|
||||
import { PdTrigerService } from '../pd-service/pd-triger.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list-pd',
|
||||
templateUrl: './list-pd.component.html',
|
||||
styleUrls: ['./list-pd.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ListPdComponent implements OnInit {
|
||||
parentEditData :string;
|
||||
showParentComponent:boolean;
|
||||
showAddComponent:boolean;
|
||||
showEditComponent:boolean;
|
||||
errorMessage: any;
|
||||
pdList:any[];
|
||||
tiles: any[] = [{
|
||||
text: 'One',
|
||||
cols: 3,
|
||||
rows: 1,
|
||||
color: 'lightblue'
|
||||
}, {
|
||||
text: 'Two',
|
||||
cols: 1,
|
||||
rows: 1,
|
||||
color: 'lightgreen'
|
||||
}, {
|
||||
text: 'Three',
|
||||
cols: 1,
|
||||
rows: 1,
|
||||
color: 'lightpink'
|
||||
}, {
|
||||
text: 'Four',
|
||||
cols: 2,
|
||||
rows: 1,
|
||||
color: '#DDBDF1'
|
||||
}];
|
||||
|
||||
dogs: Object[] = [{
|
||||
name: 'Porter',
|
||||
human: 'Kara'
|
||||
}, {
|
||||
name: 'Mal',
|
||||
human: 'Jeremy'
|
||||
}, {
|
||||
name: 'Koby',
|
||||
human: 'Igor'
|
||||
}, {
|
||||
name: 'Razzle',
|
||||
human: 'Ward'
|
||||
}, {
|
||||
name: 'Molly',
|
||||
human: 'Rob'
|
||||
}, {
|
||||
name: 'Husi',
|
||||
human: 'Matias'
|
||||
}];
|
||||
|
||||
basicRowHeight = 80;
|
||||
fixedCols = 4;
|
||||
fixedRowHeight = 50;
|
||||
ratioGutter = 1;
|
||||
fitListHeight = '400px';
|
||||
ratio = '8:1';
|
||||
|
||||
addTileCols() {
|
||||
this.tiles[2].cols++;
|
||||
}
|
||||
constructor(private _pd: PdTrigerService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.showParentComponent=true
|
||||
this.showAddComponent=false
|
||||
this.showEditComponent=false
|
||||
this._pd.getPdDetails()
|
||||
.subscribe(
|
||||
data => {
|
||||
if (data.status == 200) {
|
||||
this.pdList = data.records;
|
||||
}
|
||||
}, error => this.errorMessage = <any> error);
|
||||
}
|
||||
addPdDetails(){
|
||||
this.showParentComponent=false
|
||||
this.showEditComponent=false
|
||||
this.showAddComponent=!this.showAddComponent
|
||||
|
||||
|
||||
}
|
||||
|
||||
editPdDetails(editID:string){
|
||||
this.showParentComponent=false
|
||||
this.showAddComponent=false
|
||||
this.showEditComponent=!this.showEditComponent
|
||||
this.parentEditData=editID
|
||||
}
|
||||
updateParentComponent(event:string) {
|
||||
this.showParentComponent=!this.showParentComponent
|
||||
if(event=='1'){
|
||||
this.showAddComponent=!this.showAddComponent
|
||||
}
|
||||
else if(event=='2'){
|
||||
this.showEditComponent=!this.showEditComponent
|
||||
}
|
||||
this._pd.getPdDetails()
|
||||
.subscribe(
|
||||
data => {
|
||||
if (data.status == 200) {
|
||||
this.pdList = data.records;
|
||||
}
|
||||
}, error => this.errorMessage = <any> error);
|
||||
}
|
||||
|
||||
}
|
||||
@ -32,6 +32,18 @@ export class PdTrigerService {
|
||||
catchError(this.handleError('role', []))
|
||||
)
|
||||
}
|
||||
addPdDetails(pdForm: any): Observable<any> {
|
||||
return this._http.post<any>(this.apiUrl+"triggerNewPD", pdForm)
|
||||
.pipe(
|
||||
catchError(this.handleError('operation', []))
|
||||
)
|
||||
}
|
||||
getPdDetails(): Observable<any> {
|
||||
return this._http.get<any>(this.apiUrl+"listLessPDDetails/get")
|
||||
.pipe(
|
||||
catchError(this.handleError('operation', []))
|
||||
)
|
||||
}
|
||||
|
||||
private handleError<T>(operation = 'operation', result?: T) {
|
||||
return (error: any): Observable<T> => {
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { ListPdComponent } from './list-pd/list-pd.component';
|
||||
import { AddPdComponent } from './add-pd/add-pd.component';
|
||||
|
||||
export const PdTrigerRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: AddPdComponent
|
||||
component: ListPdComponent
|
||||
// children:
|
||||
// [{
|
||||
// path: 'pdtriggerlist',
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
MatRadioModule,
|
||||
MatButtonModule,MatTableModule,MatPaginatorModule,
|
||||
MatProgressBarModule,MatDialogModule, MatSortModule,
|
||||
MatToolbarModule,MatSelectModule } from '@angular/material';
|
||||
MatToolbarModule,MatSelectModule, MatListModule, MatGridListModule, MatTabsModule } 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';
|
||||
@ -22,6 +22,8 @@ import 'hammerjs';
|
||||
import { PdTrigerRoutes } from './pd-triger-routing.module';
|
||||
import { AddPdComponent } from './add-pd/add-pd.component';
|
||||
import { PdTrigerService } from './pd-service/pd-triger.service';
|
||||
import { ListPdComponent } from './list-pd/list-pd.component';
|
||||
import { EditPdComponent } from './edit-pd/edit-pd.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@ -39,14 +41,14 @@ import { PdTrigerService } from './pd-service/pd-triger.service';
|
||||
FlexLayoutModule,
|
||||
NgxDatatableModule,
|
||||
FormsModule,MatSlideToggleModule,
|
||||
MatSelectModule,
|
||||
MatSelectModule, MatListModule,MatGridListModule, MatTabsModule,
|
||||
ReactiveFormsModule,
|
||||
FileUploadModule,
|
||||
TreeModule,
|
||||
MatDialogModule,
|
||||
NgxMatSelectSearchModule
|
||||
],
|
||||
declarations: [AddPdComponent],
|
||||
declarations: [AddPdComponent, ListPdComponent, EditPdComponent],
|
||||
providers: [PdTrigerService]
|
||||
})
|
||||
export class PdTrigerModule { }
|
||||
|
||||
@ -45,6 +45,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',
|
||||
|
||||
77
ng6-seed/src/app/template/questions/add/add.component.html
Normal file
77
ng6-seed/src/app/template/questions/add/add.component.html
Normal 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>
|
||||
@ -0,0 +1,3 @@
|
||||
.example-full-width{
|
||||
width: 100%;
|
||||
}
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
163
ng6-seed/src/app/template/questions/add/add.component.ts
Normal file
163
ng6-seed/src/app/template/questions/add/add.component.ts
Normal file
@ -0,0 +1,163 @@
|
||||
/** 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';
|
||||
|
||||
/*
|
||||
* Question master add details
|
||||
* : kdk
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* Notifier service
|
||||
*/
|
||||
private notifier: NotifierService;
|
||||
|
||||
constructor(
|
||||
notifier: NotifierService,
|
||||
private _formBuilder: FormBuilder,
|
||||
private dialogRef: MatDialogRef<AddComponent>,
|
||||
private masterService: MastersService,
|
||||
private questionsService: QuestionsService) {
|
||||
this.notifier = notifier;
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// 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.notifier.notify('warning', 'No Category Records Found.!');
|
||||
this.errorMessage = "No Category Records Found.";
|
||||
}
|
||||
)
|
||||
}
|
||||
getQuestionOptionsMaster() {
|
||||
this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe(
|
||||
data => {
|
||||
this.questionsOptions = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Answer Type Records Found.!');
|
||||
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);
|
||||
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.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
|
||||
// this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** To Reset Popup Data */
|
||||
onReset() {
|
||||
this._addQuesFrom.reset();
|
||||
}
|
||||
}
|
||||
87
ng6-seed/src/app/template/questions/edit/edit.component.html
Normal file
87
ng6-seed/src/app/template/questions/edit/edit.component.html
Normal file
@ -0,0 +1,87 @@
|
||||
<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>
|
||||
@ -0,0 +1,3 @@
|
||||
.example-full-width{
|
||||
width: 100%;
|
||||
}
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
201
ng6-seed/src/app/template/questions/edit/edit.component.ts
Normal file
201
ng6-seed/src/app/template/questions/edit/edit.component.ts
Normal file
@ -0,0 +1,201 @@
|
||||
/** 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';
|
||||
|
||||
/*
|
||||
* Question master details edit component
|
||||
* : kdk
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
// load answer details list
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load form data form the master
|
||||
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),
|
||||
])
|
||||
});
|
||||
}
|
||||
|
||||
// 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;
|
||||
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.notifier.notify('warning', 'No Category Records Found.!');
|
||||
this.errorMessage = "No Category Record Found.";
|
||||
}
|
||||
)
|
||||
}
|
||||
getQuestionOptionsMaster() {
|
||||
this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe(
|
||||
data => {
|
||||
this.questionsOptions = data.records;
|
||||
},
|
||||
error => {
|
||||
this.notifier.notify('warning', 'No Answer Type Records Found.!');
|
||||
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.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
|
||||
// this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** To Reset Popup Data */
|
||||
onReset() {
|
||||
// this._addQuesFrom.reset();
|
||||
this.loadFormData();
|
||||
this.loadAnsData();
|
||||
}
|
||||
|
||||
}
|
||||
119
ng6-seed/src/app/template/questions/list/list.component.html
Normal file
119
ng6-seed/src/app/template/questions/list/list.component.html
Normal file
@ -0,0 +1,119 @@
|
||||
<div>
|
||||
<mat-card>
|
||||
<mat-card class="mat-elevation-z1">
|
||||
<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-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>
|
||||
</div>
|
||||
</form>
|
||||
</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" style="padding: 6px 2px;">
|
||||
|
||||
<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-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">
|
||||
<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-card *ngIf="noQuesMasterRecrdFound">
|
||||
<div class="no-record-found">No Record Found ... </div>
|
||||
</mat-card>
|
||||
|
||||
<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>
|
||||
52
ng6-seed/src/app/template/questions/list/list.component.scss
Normal file
52
ng6-seed/src/app/template/questions/list/list.component.scss
Normal file
@ -0,0 +1,52 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
.no-record-found {
|
||||
font-size: 18px;
|
||||
color: #03a9f4;
|
||||
padding : 12px 8px;
|
||||
}
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
142
ng6-seed/src/app/template/questions/list/list.component.ts
Normal file
142
ng6-seed/src/app/template/questions/list/list.component.ts
Normal file
@ -0,0 +1,142 @@
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
|
||||
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';
|
||||
import { MastersService } from './../../service/masters/masters.service';
|
||||
/** Dialog Component */
|
||||
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',
|
||||
styleUrls: ['./list.component.scss']
|
||||
})
|
||||
export class ListComponent implements OnInit {
|
||||
|
||||
public productList: any[] = [];
|
||||
public paginationList: any[] = [];
|
||||
public categories: any = [];
|
||||
public search_cid: any = null;
|
||||
public noQuesMasterRecrdFound: boolean = false;
|
||||
|
||||
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();
|
||||
displayedColumns = ['categroy_name', 'question', 'actions'];
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private dialog: MatDialog,
|
||||
private questionsService: QuestionsService,
|
||||
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 => {
|
||||
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: {},
|
||||
disableClose: true
|
||||
});
|
||||
dialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
this.getQuestionsMasters();
|
||||
// this.getBranch();
|
||||
// this.isPopupOpened = false;
|
||||
});
|
||||
}
|
||||
|
||||
// edit questions master details popup model
|
||||
editQuestion(rowDetails: any) {
|
||||
const dialogRef = this.dialog.open(EditComponent, {
|
||||
data: rowDetails,
|
||||
disableClose: true
|
||||
});
|
||||
dialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
this.getQuestionsMasters();
|
||||
// this.getBranch();
|
||||
// this.isPopupOpened = false;
|
||||
});
|
||||
}
|
||||
// padination page event call
|
||||
pageChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
}
|
||||
108
ng6-seed/src/app/template/questions/questions.module.ts
Normal file
108
ng6-seed/src/app/template/questions/questions.module.ts
Normal file
@ -0,0 +1,108 @@
|
||||
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
|
||||
* : kdk
|
||||
*/
|
||||
/**
|
||||
* Custom angular notifier options
|
||||
*/
|
||||
const customNotifierOptions: NotifierOptions = {
|
||||
position: {
|
||||
horizontal: {
|
||||
position: 'right',
|
||||
distance: 12
|
||||
},
|
||||
vertical: {
|
||||
position: 'top',
|
||||
distance: 32,
|
||||
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 { }
|
||||
19
ng6-seed/src/app/template/questions/questions.routing.ts
Normal file
19
ng6-seed/src/app/template/questions/questions.routing.ts
Normal 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 {}
|
||||
@ -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();
|
||||
}));
|
||||
});
|
||||
223
ng6-seed/src/app/template/service/masters/masters.service.ts
Normal file
223
ng6-seed/src/app/template/service/masters/masters.service.ts
Normal 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
|
||||
}
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
55
ng6-seed/src/app/template/template.module.ts
Normal file
55
ng6-seed/src/app/template/template.module.ts
Normal file
@ -0,0 +1,55 @@
|
||||
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 { TemplatesModule } from './templates/templates.module';
|
||||
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),
|
||||
TemplatesModule,
|
||||
QuestionsModule,
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatRadioModule,
|
||||
MatButtonModule,MatTableModule,MatPaginatorModule,
|
||||
MatProgressBarModule,MatDialogModule, MatSortModule,
|
||||
MatToolbarModule,MatSelectModule,
|
||||
FormsModule,ReactiveFormsModule,
|
||||
// HttpClientModule,
|
||||
],
|
||||
|
||||
providers:[
|
||||
MastersService
|
||||
]
|
||||
})
|
||||
export class TemplateModule { }
|
||||
15
ng6-seed/src/app/template/template.routing.ts
Normal file
15
ng6-seed/src/app/template/template.routing.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { QuestionsModule } from './questions/questions.module';
|
||||
|
||||
export const TemplateRoutes: Routes = [{
|
||||
path: '',
|
||||
children:[{
|
||||
path:'questions',
|
||||
loadChildren:'./questions/questions.module#QuestionsModule'
|
||||
},
|
||||
// {
|
||||
// path:'templates',
|
||||
// loadChildren:'./templates/templates.module#TemplatesModule'
|
||||
// }
|
||||
]
|
||||
}]
|
||||
@ -0,0 +1,2 @@
|
||||
<button>Back To List</button>
|
||||
<h3>Template Edit Component</h3>
|
||||
@ -0,0 +1,24 @@
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
|
||||
import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
/*
|
||||
* Template Edit component
|
||||
* : kdk
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-list',
|
||||
templateUrl: './templates.edit.component.html'
|
||||
})
|
||||
export class TemplateEditComponent implements OnInit {
|
||||
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<div *ngIf="listView">
|
||||
<h3>Template List Component</h3>
|
||||
<button (click)="goToEdit()">Edit</button>
|
||||
</div>
|
||||
<div *ngIf="!listView">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
@ -0,0 +1,32 @@
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material';
|
||||
import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
/*
|
||||
* Template List component
|
||||
* : kdk
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-list',
|
||||
templateUrl: './templates.list.component.html'
|
||||
})
|
||||
export class TemplateListComponent implements OnInit {
|
||||
public listView: boolean = true;
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
// alert(1);
|
||||
}
|
||||
|
||||
goToEdit(){
|
||||
this.listView = false;
|
||||
}
|
||||
|
||||
ngAfterViewInit(){
|
||||
// alert(2);
|
||||
}
|
||||
|
||||
}
|
||||
10
ng6-seed/src/app/template/templates/templates.component.ts
Normal file
10
ng6-seed/src/app/template/templates/templates.component.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
@Component({
|
||||
template: `<h2>Templates Master Details List</h2>
|
||||
<div>
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class TemplatesComponent {
|
||||
}
|
||||
106
ng6-seed/src/app/template/templates/templates.module.ts
Normal file
106
ng6-seed/src/app/template/templates/templates.module.ts
Normal file
@ -0,0 +1,106 @@
|
||||
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 { TemplatesRouting } from './templates.routing';
|
||||
|
||||
import { TemplatesComponent } from './templates.component';
|
||||
import { TemplateListComponent } from './templates-list/templates.list.component';
|
||||
import { TemplateEditComponent } from './templates-list/edit/templates.edit.component';
|
||||
|
||||
// import { QuestionsService } from './../service/questions/questions.service';
|
||||
/*
|
||||
* Question Master Module details
|
||||
* : kdk
|
||||
*/
|
||||
/**
|
||||
* Custom angular notifier options
|
||||
*/
|
||||
const customNotifierOptions: NotifierOptions = {
|
||||
position: {
|
||||
horizontal: {
|
||||
position: 'right',
|
||||
distance: 12
|
||||
},
|
||||
vertical: {
|
||||
position: 'top',
|
||||
distance: 32,
|
||||
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,
|
||||
TemplatesRouting
|
||||
],
|
||||
declarations: [
|
||||
TemplatesComponent,
|
||||
TemplateListComponent,
|
||||
TemplateEditComponent
|
||||
],
|
||||
entryComponents: [
|
||||
],
|
||||
providers: [
|
||||
// QuestionsService
|
||||
]
|
||||
})
|
||||
export class TemplatesModule { }
|
||||
32
ng6-seed/src/app/template/templates/templates.routing.ts
Normal file
32
ng6-seed/src/app/template/templates/templates.routing.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
// Templates Component
|
||||
import { TemplatesComponent } from './templates.component';
|
||||
import { TemplateListComponent } from './templates-list/templates.list.component';
|
||||
import { TemplateEditComponent } from './templates-list/edit/templates.edit.component';
|
||||
|
||||
/*
|
||||
* Templates Master Router Module details
|
||||
*/
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'templates',
|
||||
component: TemplatesComponent,
|
||||
children: [
|
||||
{
|
||||
path: 'list',
|
||||
component: TemplateListComponent,
|
||||
children: [{
|
||||
path: 'edit',
|
||||
component: TemplateEditComponent,
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class TemplatesRouting {}
|
||||
@ -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
3
package-lock.json
generated
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user