From beb703e938afc5522c471952f7df9ebbad2e6a2e Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Thu, 27 Sep 2018 18:01:40 +0530 Subject: [PATCH 1/7] pd changes --- .../pd-triger/add-pd/add-pd.component.html | 348 ++++++++++-------- .../app/pd-triger/add-pd/add-pd.component.ts | 145 +++++++- .../pd-triger/pd-service/pd-triger.service.ts | 6 + .../src/app/pd-triger/pd-triger.module.ts | 4 +- 4 files changed, 334 insertions(+), 169 deletions(-) diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html index ce7513af8..340bb94c7 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html @@ -1,164 +1,196 @@ -
- -
-
-
- -
PD Details
- -
- - - - - - {{LL.lender_hierarchy}} - - You must include a Pick up Lender Name. - - - - - - - - You must include Lender Applicant Id. - - - - - - {{PL.name}} - - - - - - - - - {{SPL.name}} - - - - - - - {{CSL.name}} - - - - - - - {{PDL.type_name}} - - - - - - - - - - + + +
+
+
+ +
PD Details
+ +
+ - - - + + + + {{LL.lender_hierarchy}} + + You must include a Pick up Lender Name. + + + + + + + + You must include Lender Applicant Id. + + + + + + {{PL.name}} + + + - - - - - - ` - {{CL.name}} - - - - - - - - {{SL.name}} - - - - - - - -
- -
-
-
-
-
- -
Main Applicant Details
- - - - - - - - - - - - - - - - - - -
-
-
-
-
- - -
{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}
-
- - - - - - + + + + + {{SPL.name}} + + + + + + + {{CSL.name}} + + + + + + + {{PDL.type_name}} + + + + + + + + + + + + + + + + + + + + + ` + {{CL.name}} + + + + + + + + {{SL.name}} + + + + + + +
-
-
+ + +
+
+
+
+ +
Main Applicant Details
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + +
{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}
+
+ + + + + + +
+
+
+
+
+ +
+ + + + + + +
- -
- - - - -
-
- - - - - -
- - - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + \ No newline at end of file diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts index ffc9a5490..859a3f9b7 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, ViewEncapsulation } 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', @@ -25,10 +26,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 =[]; + 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 +41,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 +50,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 +148,132 @@ 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;jthis.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(); + } + } } diff --git a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts index e0139e295..f5048b551 100644 --- a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts @@ -32,6 +32,12 @@ export class PdTrigerService { catchError(this.handleError('role', [])) ) } + addPdDetails(pdForm: any): Observable { + return this._http.post(this.apiUrl+"triggerNewPD", pdForm) + .pipe( + catchError(this.handleError('operation', [])) + ) + } private handleError(operation = 'operation', result?: T) { return (error: any): Observable => { diff --git a/ng6-seed/src/app/pd-triger/pd-triger.module.ts b/ng6-seed/src/app/pd-triger/pd-triger.module.ts index 2e161ca0a..4bbf56394 100644 --- a/ng6-seed/src/app/pd-triger/pd-triger.module.ts +++ b/ng6-seed/src/app/pd-triger/pd-triger.module.ts @@ -8,7 +8,7 @@ import { MatRadioModule, MatButtonModule,MatTableModule,MatPaginatorModule, MatProgressBarModule,MatDialogModule, MatSortModule, - MatToolbarModule,MatSelectModule } from '@angular/material'; + MatToolbarModule,MatSelectModule, MatListModule } 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'; @@ -39,7 +39,7 @@ import { PdTrigerService } from './pd-service/pd-triger.service'; FlexLayoutModule, NgxDatatableModule, FormsModule,MatSlideToggleModule, - MatSelectModule, + MatSelectModule, MatListModule, ReactiveFormsModule, FileUploadModule, TreeModule, From 7400b4f216051d8b982f157eb2ed941f192bb85e Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Mon, 1 Oct 2018 18:09:13 +0530 Subject: [PATCH 2/7] template questions details master added : kdk --- ng6-seed/package.json | 2 + ng6-seed/src/app/app.routing.ts | 3 + .../src/app/shared/menu-items/menu-items.ts | 8 + .../template/questions/add/add.component.html | 77 ++++++ .../template/questions/add/add.component.scss | 3 + .../questions/add/add.component.spec.ts | 25 ++ .../template/questions/add/add.component.ts | 155 ++++++++++++ .../questions/edit/edit.component.html | 86 +++++++ .../questions/edit/edit.component.scss | 3 + .../questions/edit/edit.component.spec.ts | 25 ++ .../template/questions/edit/edit.component.ts | 191 +++++++++++++++ .../questions/list/list.component.html | 134 +++++++++++ .../questions/list/list.component.scss | 46 ++++ .../questions/list/list.component.spec.ts | 25 ++ .../template/questions/list/list.component.ts | 119 ++++++++++ .../template/questions/questions.module.ts | 109 +++++++++ .../template/questions/questions.routing.ts | 19 ++ .../service/masters/masters.service.spec.ts | 15 ++ .../service/masters/masters.service.ts | 223 ++++++++++++++++++ .../questions/questions.service.spec.ts | 12 + .../service/questions/questions.service.ts | 70 ++++++ ng6-seed/src/app/template/template.module.ts | 54 +++++ ng6-seed/src/app/template/template.routing.ts | 11 + ng6-seed/src/assets/styles/app.scss | 3 + package-lock.json | 3 + 25 files changed, 1421 insertions(+) create mode 100644 ng6-seed/src/app/template/questions/add/add.component.html create mode 100644 ng6-seed/src/app/template/questions/add/add.component.scss create mode 100644 ng6-seed/src/app/template/questions/add/add.component.spec.ts create mode 100644 ng6-seed/src/app/template/questions/add/add.component.ts create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.html create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.scss create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.spec.ts create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.ts create mode 100644 ng6-seed/src/app/template/questions/list/list.component.html create mode 100644 ng6-seed/src/app/template/questions/list/list.component.scss create mode 100644 ng6-seed/src/app/template/questions/list/list.component.spec.ts create mode 100644 ng6-seed/src/app/template/questions/list/list.component.ts create mode 100644 ng6-seed/src/app/template/questions/questions.module.ts create mode 100644 ng6-seed/src/app/template/questions/questions.routing.ts create mode 100644 ng6-seed/src/app/template/service/masters/masters.service.spec.ts create mode 100644 ng6-seed/src/app/template/service/masters/masters.service.ts create mode 100644 ng6-seed/src/app/template/service/questions/questions.service.spec.ts create mode 100644 ng6-seed/src/app/template/service/questions/questions.service.ts create mode 100644 ng6-seed/src/app/template/template.module.ts create mode 100644 ng6-seed/src/app/template/template.routing.ts create mode 100644 package-lock.json diff --git a/ng6-seed/package.json b/ng6-seed/package.json index 7dca4c1b4..299250298 100644 --- a/ng6-seed/package.json +++ b/ng6-seed/package.json @@ -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", diff --git a/ng6-seed/src/app/app.routing.ts b/ng6-seed/src/app/app.routing.ts index a4d27b61d..deeef0a53 100644 --- a/ng6-seed/src/app/app.routing.ts +++ b/ng6-seed/src/app/app.routing.ts @@ -22,6 +22,9 @@ export const AppRoutes: Routes = [{ ,{ path:'pdtrigger', loadChildren:'./pd-triger/pd-triger.module#PdTrigerModule' + },{ + path:'template', + loadChildren:'./template/template.module#TemplateModule' } ] }, { diff --git a/ng6-seed/src/app/shared/menu-items/menu-items.ts b/ng6-seed/src/app/shared/menu-items/menu-items.ts index ebc3fe320..ea4fde87b 100644 --- a/ng6-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/menu-items.ts @@ -44,6 +44,14 @@ const MENUITEMS : Menu[] = [ // children:[ // {state:'pdtriggerlist',name:'Pd Trigger Listing'} // ] + },{ + state: 'template', + name: 'Template', + type: 'sub', + icon: 'art_track', + children: [ + {state: 'questions', name: 'Questions'} + ] }, { state: 'authentication', diff --git a/ng6-seed/src/app/template/questions/add/add.component.html b/ng6-seed/src/app/template/questions/add/add.component.html new file mode 100644 index 000000000..48a04cea6 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.html @@ -0,0 +1,77 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+
+ +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + +
+
+
+
+ + +
+
+ + +
+ + +
+ +
+
+
\ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.scss b/ng6-seed/src/app/template/questions/add/add.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.scss @@ -0,0 +1,3 @@ +.example-full-width{ + width: 100%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.spec.ts b/ng6-seed/src/app/template/questions/add/add.component.spec.ts new file mode 100644 index 000000000..fdcddf4c8 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AddComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/add/add.component.ts b/ng6-seed/src/app/template/questions/add/add.component.ts new file mode 100644 index 000000000..60ccf36f4 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.ts @@ -0,0 +1,155 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, +} from '@angular/forms'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { MastersService } from './../../service/masters/masters.service'; +import { QuestionsService } from './../../service/questions/questions.service'; + +@Component({ + selector: 'app-add', + templateUrl: './add.component.html', + styleUrls: ['./add.component.scss'] +}) +export class AddComponent implements OnInit { + + public pageTitle : string = "Add Question Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public questionsOptions: any = []; + errorMessage: string; + + constructor(private _formBuilder: FormBuilder, + private dialogRef: MatDialogRef, + private masterService: MastersService, + private questionsService: QuestionsService) { } + + + ngOnInit() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + question: [null, Validators.compose([Validators.required])], + description: [null, Validators.compose([Validators.required])], + fk_question_catagory: [null, Validators.compose([Validators.required])], + fk_question_answertype: [null, Validators.compose([Validators.required])], + answers: this._formBuilder.array([ + this.initAnswers(), + ]) + }); + // OnInit Load Category and Question Type Masters + this.getCategoryListMaster(); + this.getQuestionOptionsMaster(); + + // /** For SelectDrop Datas*/ + // this._mastersService.getAllMasterData('CITY') + // .subscribe( + // data => { + + // if (data.status == 200) { + // this.citydatas = data.records; + // this.citydatas = this.citydatas.filter(city=>city.isactive == 1 ); + // } + + // }, error => this.errorMessage = error); + + } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + + // Dynamic Form field creation Functionality : START ===> + initAnswers() { + return this._formBuilder.group({ + answer: ['', Validators.compose([Validators.required])] + }); + } + addLanguage(e) { + const control = this._addQuesFrom.controls['answers']; + control.push(this.initAnswers()); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['answers']; + control.removeAt(i); + } + + // END ===> + + getCategoryListMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + this.errorMessage = "No Category Record Found."; + } + ) + } + getQuestionOptionsMaster() { + this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe( + data => { + this.questionsOptions = data.records; + }, + error => { + this.errorMessage = "No Answer Type Record Found."; + } + ) + } + + /** For Popup Close Button */ + onNoClick(): void { + this.dialogRef.close(); + } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addQuesFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var answerFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + //Add BRANCH data with help Service File + this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + alert("sample alert for Saving"); + } + else { + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + } + } , error => { + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + this.dialogRef.close(); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + /** To Reset Popup Data */ + onReset() { + this._addQuesFrom.reset(); + } +} diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.html b/ng6-seed/src/app/template/questions/edit/edit.component.html new file mode 100644 index 000000000..6ee59cc58 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.html @@ -0,0 +1,86 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+ +
+ +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + + +
+
+
+
+ + +
+
+
+ Active/InActive +
+ + +
+ + +
+ +
+
+
+ + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.scss b/ng6-seed/src/app/template/questions/edit/edit.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.scss @@ -0,0 +1,3 @@ +.example-full-width{ + width: 100%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts b/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts new file mode 100644 index 000000000..34ef921a1 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.ts b/ng6-seed/src/app/template/questions/edit/edit.component.ts new file mode 100644 index 000000000..726bb8e56 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.ts @@ -0,0 +1,191 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { MastersService } from './../../service/masters/masters.service'; +import { QuestionsService } from './../../service/questions/questions.service'; + +@Component({ + selector: 'app-edit', + templateUrl: './edit.component.html', + styleUrls: ['./edit.component.scss'] +}) +export class EditComponent implements OnInit { + + + public pageTitle : string = "Edit Question Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public questionsOptions: any = []; + errorMessage: string; + + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, + private dialogRef: MatDialogRef, + private masterService: MastersService, + private questionsService: QuestionsService, + @Inject(MAT_DIALOG_DATA) public data: any) { + this.notifier = notifier; + } + + ngOnInit() { + this.loadFormData(); + if (this.data["0"].length > 0) { + for (let val of this.data["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); + } + } + + // OnInit Load Category and Question Type Masters + this.getCategoryListMaster(); + this.getQuestionOptionsMaster(); + } + + loadAnsData(){ + if (this.data["0"].length > 0) { + for (let val of this.data["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); + } + } + } + + loadFormData() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + question_id: [this.data.question_id], + question: [this.data.question, Validators.compose([Validators.required])], + description: [this.data.description, Validators.compose([Validators.required])], + fk_question_catagory: [this.data.fk_question_catagory, Validators.compose([Validators.required])], + fk_question_answertype: [this.data.fk_question_answertype, Validators.compose([Validators.required])], + isactive:[this.data.isactive], + answers: this._formBuilder.array([ + // this.initAnswers(null, null), + ]) + }); + } + + get f_ans() { return this._addQuesFrom.get('answers'); } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + + // Dynamic Form field creation Functionality : START ===> + initAnswers(ans, fk_id, isAct) { + isAct = isAct == null ? 1 : isAct; + return this._formBuilder.group({ + answer: [ans, Validators.compose([Validators.required])], + question_answer_id: [fk_id], + isactive: [isAct] + }); + } + addLanguage(ans, fk_id, isAct, e) { + const control = this._addQuesFrom.controls['answers']; + control.push(this.initAnswers(ans, fk_id, isAct)); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['answers']; + control.removeAt(i); + } + + // END ===> + + getCategoryListMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + this.errorMessage = "No Category Record Found."; + } + ) + } + getQuestionOptionsMaster() { + this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe( + data => { + this.questionsOptions = data.records; + }, + error => { + this.errorMessage = "No Answer Type Record Found."; + } + ) + } + + /** For Popup Close Button */ + onNoClick(): void { + this.dialogRef.close(); + } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addQuesFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var answerFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + //Add BRANCH data with help Service File + this.questionsService.updateQuestionMasterDetails(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify( 'success', 'Your Changes Updated!' ); + this.dialogRef.close(); + // this.notifierService('success', 'You are awesome! I mean it!'); + // alert("sample alert for Saving"); + } + else { + this.notifier.notify( 'warning', 'Something Wents Wrong Try Again !' ); + this.errorMessage = "Something Wents Wrong Try Again !"; + } + }, error => { + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + this.dialogRef.close(); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + /** To Reset Popup Data */ + onReset() { + // this._addQuesFrom.reset(); + this.loadFormData(); + this.loadAnsData(); + } + +} diff --git a/ng6-seed/src/app/template/questions/list/list.component.html b/ng6-seed/src/app/template/questions/list/list.component.html new file mode 100644 index 000000000..0ee433bb7 --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.html @@ -0,0 +1,134 @@ +
+ + + +
+
Questions Master
+
List of Questions
+
+
+
+
+ + + + + + {{cat.categroy_name}} + + + + +
+
+
+ +
+
+ +
+ + +
+ +
+ +
+ +
+
+ {{ product.categroy_name }} +
+
+
{{ product.question }} +
+
+
+
+
+ + + + +
+
+ +
+
+
+ + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.scss b/ng6-seed/src/app/template/questions/list/list.component.scss new file mode 100644 index 000000000..67712370e --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.scss @@ -0,0 +1,46 @@ +// mat table css + +.example-container { + display: flex; + flex-direction: column; + min-width: 300px; +} + +.example-header { + min-height: 64px; + padding: 8px 24px 0; +} + +.mat-form-field { + font-size: 14px; +// width: 100%; +} + +.mat-table { + overflow: auto; + max-height: 500px; +} + +.text-line-limit { + text-overflow: ellipsis; + overflow: hidden; + // white-space: nowrap; + display: -webkit-box; + line-height: 16px; /* fallback */ + max-height: 32px; /* fallback */ + -webkit-line-clamp: 2; /* number of lines to show */ + -webkit-box-orient: vertical; + + // text-overflow: ellipsis; + // overflow: hidden; + // width: 160px; + // height: 1.2em; + // white-space: nowrap; +} + +.category-label { + padding: 2px 6px; + background: #629cff; + color: #fff; + box-shadow: 0 2px 3px #c8bbbb; +} diff --git a/ng6-seed/src/app/template/questions/list/list.component.spec.ts b/ng6-seed/src/app/template/questions/list/list.component.spec.ts new file mode 100644 index 000000000..beacd156f --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/list/list.component.ts b/ng6-seed/src/app/template/questions/list/list.component.ts new file mode 100644 index 000000000..c670fd325 --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.ts @@ -0,0 +1,119 @@ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent} from '@angular/material'; +import { FormGroup, FormControl } from '@angular/forms'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { QuestionsService } from './../../service/questions/questions.service'; +import { MastersService } from './../../service/masters/masters.service'; +/** Dialog Component */ +import { AddComponent } from './../add/add.component'; +import { EditComponent } from './../edit/edit.component'; + +@Component({ + selector: 'app-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] +}) +export class ListComponent implements OnInit { + + public productList: any[] = []; + public paginationList: any[] = []; + public categories: any = []; + public search_cid :any = null; + + public filterFormCtrl : FormControl = new FormControl(); + /** control for the MatSelect filter keyword */ + // public masterFilterCtrl: FormControl = new FormControl(); + + length = 50; + pageIndex = 0; + pageSize = 10; + + pageEvent: PageEvent; + + questionListData = null; + public dataLength: number; + public dataSource = new MatTableDataSource(); + displayedColumns = ['categroy_name', 'question', 'actions']; + + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + + constructor(private dialog: MatDialog, + private questionsService: QuestionsService, + private masterService: MastersService) { + this.getQuestionsMasters(); + } + + getQuestionsMasters(){ + this.search_cid = this.filterFormCtrl.value; + console.log(this.filterFormCtrl); + this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe( + data => { + this.productList = data.records; + this.questionListData = data.records; + // alert(this.userData); + this.dataLength = data.records.length; + this.dataSource.data = this.questionListData; + } + ) + } + + ngOnInit() { + this.getCategorMaster(); + } + + getCategorMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + // this.errorMessage = "No Category Record Found."; + } + ) + } + + ngAfterViewInit() { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + applyFilter(filterValue: string) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches + this.dataSource.filter = filterValue; + } + + // add questions popup model call + addNewQuestion() { + const dialogRef = this.dialog.open(AddComponent, { + data: {} + }); + + dialogRef.afterClosed() + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); + } + + editQuestion(rowDetails: any){ + const dialogRef = this.dialog.open(EditComponent, { + data: rowDetails + }); + + dialogRef.afterClosed() + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); + } + + pageChange(e) { + console.log(e); + } + +} diff --git a/ng6-seed/src/app/template/questions/questions.module.ts b/ng6-seed/src/app/template/questions/questions.module.ts new file mode 100644 index 000000000..0c8a20bd5 --- /dev/null +++ b/ng6-seed/src/app/template/questions/questions.module.ts @@ -0,0 +1,109 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { NotifierModule, NotifierOptions } from 'angular-notifier'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule, + MatListModule, MatMenuModule, + MatCheckboxModule +} from '@angular/material'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +// Questions Routing import +import { QuestionsRouting } from './questions.routing'; +// Questions List +import { ListComponent } from './list/list.component'; + +import { QuestionsService } from './../service/questions/questions.service'; +import { AddComponent } from './add/add.component'; +import { EditComponent } from './edit/edit.component'; +/* +* Question Master Module details +*/ + + +/** + * Custom angular notifier options + */ +const customNotifierOptions: NotifierOptions = { + position: { + horizontal: { + position: 'right', + distance: 12 + }, + vertical: { + position: 'top', + distance: 12, + gap: 10 + } + }, + theme: 'material', + behaviour: { + autoHide: 5000, + onClick: 'hide', + onMouseover: 'pauseAutoHide', + showDismissButton: true, + stacking: 4 + }, + animations: { + enabled: true, + show: { + preset: 'slide', + speed: 300, + easing: 'ease' + }, + hide: { + preset: 'fade', + speed: 300, + easing: 'ease', + offset: 50 + }, + shift: { + speed: 300, + easing: 'ease' + }, + overlap: 150 + } +}; + +@NgModule({ + imports: [ + CommonModule, + NotifierModule.withConfig(customNotifierOptions), + FlexLayoutModule, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule, + MatSlideToggleModule, + MatCheckboxModule, + FormsModule, + ReactiveFormsModule, + QuestionsRouting + ], + declarations: [ + ListComponent, + AddComponent, + EditComponent + ], + entryComponents: [ + AddComponent, + EditComponent + ], + providers: [ + QuestionsService + ] +}) +export class QuestionsModule { } diff --git a/ng6-seed/src/app/template/questions/questions.routing.ts b/ng6-seed/src/app/template/questions/questions.routing.ts new file mode 100644 index 000000000..0f07ea048 --- /dev/null +++ b/ng6-seed/src/app/template/questions/questions.routing.ts @@ -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 {} diff --git a/ng6-seed/src/app/template/service/masters/masters.service.spec.ts b/ng6-seed/src/app/template/service/masters/masters.service.spec.ts new file mode 100644 index 000000000..2550bd5a4 --- /dev/null +++ b/ng6-seed/src/app/template/service/masters/masters.service.spec.ts @@ -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(); + })); +}); diff --git a/ng6-seed/src/app/template/service/masters/masters.service.ts b/ng6-seed/src/app/template/service/masters/masters.service.ts new file mode 100644 index 000000000..0448504d2 --- /dev/null +++ b/ng6-seed/src/app/template/service/masters/masters.service.ts @@ -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 { + 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(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 { + + 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 { + + //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 { + return this._http.post(this.apiUrl+"getListOfMaster", { "master_name":TableName }) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + /** + * TO get Branch Data For Listing Screen + */ + getAllBranch(): Observable { + return this._http.get(this.apiUrl+'getListOfBranches') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + + + /** + * TO get Subproduct Data For Listing Screen + */ + getAllSubProduct(): Observable { + + return this._http.get(this.apiUrl+'getListOfSubProduct') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + + /** + * TO get State Data For Listing Screen + */ + getAllState(): Observable { + + return this._http.get(this.apiUrl+'getListOfState') + .pipe( + catchError(this.handleError('role', [])) + ) + + + } + + /** + * TO get Company Data For Listing Screen + */ + getAllCompany(): Observable { + + return this._http.get(this.apiUrl+'getListOfCompany') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + /** + * TO get City Data For Listing Screen + */ + getAllCity(): Observable { + + return this._http.get(this.apiUrl+'getListOfCity') + .pipe( + catchError(this.handleError('role', [])) + ) + +} + + + /** Get All EntityType Data using API call With master Keyword */ + // getAllEntityType(): Observable { + // 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(operation = 'operation', result?: T) { + + return (error: any): Observable => { + return of(result as T); + }; +} +addCompanyDetails +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/service/questions/questions.service.spec.ts b/ng6-seed/src/app/template/service/questions/questions.service.spec.ts new file mode 100644 index 000000000..831ec17b2 --- /dev/null +++ b/ng6-seed/src/app/template/service/questions/questions.service.spec.ts @@ -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(); + }); +}); diff --git a/ng6-seed/src/app/template/service/questions/questions.service.ts b/ng6-seed/src/app/template/service/questions/questions.service.ts new file mode 100644 index 000000000..1b532635c --- /dev/null +++ b/ng6-seed/src/app/template/service/questions/questions.service.ts @@ -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 { + return this._http.get(this.serviceUrl); + } + + // get questions master details list + getQuestionMasterDetails(cid: any): Observable { + // 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(this.apiUrl + "listAllQuestions/get", options); + } + + // add question master + addQuestionMasterDetails(Records: any): Observable { + 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(this.apiUrl + "saveNewQuestion", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + updateQuestionMasterDetails(Records: any): Observable { + 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(this.apiUrl + "saveExistQuestion", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + /** + * TO Handle The Error + */ + private handleError(operation = 'operation', result?: T) { + + return (error: any): Observable => { + return of(result as T); + }; + } + +} diff --git a/ng6-seed/src/app/template/template.module.ts b/ng6-seed/src/app/template/template.module.ts new file mode 100644 index 000000000..452fcd0cc --- /dev/null +++ b/ng6-seed/src/app/template/template.module.ts @@ -0,0 +1,54 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule } from '@angular/material'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; +import { TreeModule } from 'angular-tree-component'; +import { NgxDatatableModule } from '@swimlane/ngx-datatable'; +import { FlexLayoutModule } from '@angular/flex-layout'; + +import { DemoMaterialModule } from '../shared/demo.module'; +// import { NgxMatSelectSearchModule } from 'ngx-mat-select-search'; +import 'hammerjs'; +import { RouterModule } from '@angular/router'; + + +import { QuestionsModule } from './questions/questions.module'; +/** Template Routes */ +import { TemplateRoutes } from './template.routing'; + +/** Master Service */ +import { MastersService } from './service/masters/masters.service'; + + +// import { HttpClientModule } from '@angular/common/http'; +@NgModule({ + imports: [ + CommonModule, + RouterModule.forChild(TemplateRoutes), + QuestionsModule, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule, + FormsModule,ReactiveFormsModule, + // HttpClientModule, + ], + + providers:[ + MastersService + ] +}) +export class TemplateModule { } diff --git a/ng6-seed/src/app/template/template.routing.ts b/ng6-seed/src/app/template/template.routing.ts new file mode 100644 index 000000000..0aee5b6fd --- /dev/null +++ b/ng6-seed/src/app/template/template.routing.ts @@ -0,0 +1,11 @@ +import { Routes } from '@angular/router'; +import { QuestionsModule } from './questions/questions.module'; + +export const TemplateRoutes: Routes = [{ + path: '', + children:[{ + path:'questions', + loadChildren:'./questions/questions.module#QuestionsModule' + } +] +}] diff --git a/ng6-seed/src/assets/styles/app.scss b/ng6-seed/src/assets/styles/app.scss index d966db745..a5b6d83cc 100644 --- a/ng6-seed/src/assets/styles/app.scss +++ b/ng6-seed/src/assets/styles/app.scss @@ -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"; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..48e341a09 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} From b2bc5bee2aba8df693721670c407af2ea1556cd3 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 3 Oct 2018 10:36:21 +0530 Subject: [PATCH 3/7] pd changes --- .../pd-triger/add-pd/add-pd.component.html | 10 +- .../app/pd-triger/add-pd/add-pd.component.ts | 7 +- .../pd-triger/edit-pd/edit-pd.component.html | 11 ++ .../pd-triger/edit-pd/edit-pd.component.scss | 0 .../edit-pd/edit-pd.component.spec.ts | 25 +++ .../pd-triger/edit-pd/edit-pd.component.ts | 23 +++ .../pd-triger/list-pd/list-pd.component.html | 171 ++++++++++++++++++ .../pd-triger/list-pd/list-pd.component.scss | 5 + .../list-pd/list-pd.component.spec.ts | 25 +++ .../pd-triger/list-pd/list-pd.component.ts | 115 ++++++++++++ .../pd-triger/pd-service/pd-triger.service.ts | 6 + .../app/pd-triger/pd-triger-routing.module.ts | 3 +- .../src/app/pd-triger/pd-triger.module.ts | 8 +- 13 files changed, 400 insertions(+), 9 deletions(-) create mode 100644 ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html create mode 100644 ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.scss create mode 100644 ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts create mode 100644 ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts create mode 100644 ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html create mode 100644 ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss create mode 100644 ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts create mode 100644 ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html index 340bb94c7..a30235d64 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html @@ -179,7 +179,7 @@ - + @@ -187,9 +187,11 @@
- - - +
+ + + +
diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts index 859a3f9b7..cabd1804f 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts @@ -1,4 +1,4 @@ -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'; @@ -11,6 +11,8 @@ import { AwsService } from '../../AwsService/aws.service'; encapsulation: ViewEncapsulation.None }) export class AddPdComponent implements OnInit { + @Output() loadParent = new EventEmitter(); + public PDtriggerForm: FormGroup; items: FormArray; CityList: any; @@ -276,4 +278,7 @@ this._pd.getAllMasterDatas('PDTYPE') this._pd.addPdDetails(pd_form).subscribe(); } } + loadPdListCompoent() { + this.loadParent.emit('1') + } } diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html new file mode 100644 index 000000000..cb6987e03 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html @@ -0,0 +1,11 @@ + + + + {{ childData }} + +
+ + + +
+ diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.scss b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts new file mode 100644 index 000000000..ad598b308 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditPdComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditPdComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts new file mode 100644 index 000000000..b9c660080 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts @@ -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(); + constructor() { + + } + + ngOnInit() { + } + loadPdListCompoent() { + this.loadParent.emit('2') + } + +} diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html new file mode 100644 index 000000000..ee96ba06a --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html @@ -0,0 +1,171 @@ +
+ +
+ + + + All PD Details + +
+ + + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +
+ +
+
+ + + +
+ + Confirmed PD Details + + + + {{tile.text}} + + +
+ + + +
+
+
+ + In Progress PD Details + + + + {{tile.text}} + + +
+ + + + + + +
+
+
+ +
+
+ + + diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss new file mode 100644 index 000000000..b1e122b24 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss @@ -0,0 +1,5 @@ +.ic-change:hover { + transform: scale(1.1); + color: green; +} + diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts new file mode 100644 index 000000000..e91599347 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListPdComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListPdComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts new file mode 100644 index 000000000..e64b9d67e --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts @@ -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 = 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 = error); +} + +} diff --git a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts index f5048b551..1babea421 100644 --- a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts @@ -38,6 +38,12 @@ export class PdTrigerService { catchError(this.handleError('operation', [])) ) } + getPdDetails(): Observable { + return this._http.get(this.apiUrl+"listLessPDDetails/get") + .pipe( + catchError(this.handleError('operation', [])) + ) + } private handleError(operation = 'operation', result?: T) { return (error: any): Observable => { diff --git a/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts b/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts index 68107874b..cf23e2a3d 100644 --- a/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts +++ b/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts @@ -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', diff --git a/ng6-seed/src/app/pd-triger/pd-triger.module.ts b/ng6-seed/src/app/pd-triger/pd-triger.module.ts index 4bbf56394..0dab02906 100644 --- a/ng6-seed/src/app/pd-triger/pd-triger.module.ts +++ b/ng6-seed/src/app/pd-triger/pd-triger.module.ts @@ -8,7 +8,7 @@ import { MatRadioModule, MatButtonModule,MatTableModule,MatPaginatorModule, MatProgressBarModule,MatDialogModule, MatSortModule, - MatToolbarModule,MatSelectModule, MatListModule } 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, MatListModule, + MatSelectModule, MatListModule,MatGridListModule, MatTabsModule, ReactiveFormsModule, FileUploadModule, TreeModule, MatDialogModule, NgxMatSelectSearchModule ], - declarations: [AddPdComponent], + declarations: [AddPdComponent, ListPdComponent, EditPdComponent], providers: [PdTrigerService] }) export class PdTrigerModule { } From 3bdd446b0760f030c46f5bea12469a0a15829ebe Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Wed, 3 Oct 2018 10:47:02 +0530 Subject: [PATCH 4/7] question master changes : kdk --- .../template/questions/add/add.component.html | 124 +++++++++--------- .../template/questions/add/add.component.ts | 80 ++++++----- .../questions/edit/edit.component.html | 7 +- .../template/questions/edit/edit.component.ts | 42 +++--- .../questions/list/list.component.html | 123 ++++++++--------- .../questions/list/list.component.scss | 6 + .../template/questions/list/list.component.ts | 115 +++++++++------- .../template/questions/questions.module.ts | 5 +- 8 files changed, 267 insertions(+), 235 deletions(-) diff --git a/ng6-seed/src/app/template/questions/add/add.component.html b/ng6-seed/src/app/template/questions/add/add.component.html index 48a04cea6..0dc81434f 100644 --- a/ng6-seed/src/app/template/questions/add/add.component.html +++ b/ng6-seed/src/app/template/questions/add/add.component.html @@ -1,77 +1,77 @@
- -
-

{{pageTitle}}

-
-
- + +
+

{{pageTitle}}

+
+
+ +
-
-
- -
- - - {{ ct.categroy_name }} - - You must Select Category. - -
-
- - - You must Include Question. - -
-
- - - You must Include Description. - -
-
- - - {{ ans.answer_type_name }} - - You must Select Answer Type. - -
-
-
-
-
-
-
- - - - - -
-
- + + +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ +
+ +
- -
-
- -
- - -
- - - +
+ + +
+ + +
\ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.ts b/ng6-seed/src/app/template/questions/add/add.component.ts index 60ccf36f4..c8824cd9e 100644 --- a/ng6-seed/src/app/template/questions/add/add.component.ts +++ b/ng6-seed/src/app/template/questions/add/add.component.ts @@ -12,6 +12,8 @@ import { FormArray, } from '@angular/forms'; +import { NotifierService } from 'angular-notifier'; + import { MatDialog, MatDialogRef, @@ -21,24 +23,37 @@ import { import { MastersService } from './../../service/masters/masters.service'; import { QuestionsService } from './../../service/questions/questions.service'; +/* +* Question master add details +* : kdk +*/ @Component({ selector: 'app-add', templateUrl: './add.component.html', styleUrls: ['./add.component.scss'] }) export class AddComponent implements OnInit { - - public pageTitle : string = "Add Question Details"; + + public pageTitle: string = "Add Question Details"; public _addQuesFrom: FormGroup; public submitted = false; public categories: any = []; public questionsOptions: any = []; errorMessage: string; - constructor(private _formBuilder: FormBuilder, + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, private dialogRef: MatDialogRef, private masterService: MastersService, - private questionsService: QuestionsService) { } + private questionsService: QuestionsService) { + this.notifier = notifier; + } ngOnInit() { @@ -55,19 +70,6 @@ export class AddComponent implements OnInit { // OnInit Load Category and Question Type Masters this.getCategoryListMaster(); this.getQuestionOptionsMaster(); - - // /** For SelectDrop Datas*/ - // this._mastersService.getAllMasterData('CITY') - // .subscribe( - // data => { - - // if (data.status == 200) { - // this.citydatas = data.records; - // this.citydatas = this.citydatas.filter(city=>city.isactive == 1 ); - // } - - // }, error => this.errorMessage = error); - } // convenience getter for easy access to form fields @@ -96,7 +98,8 @@ export class AddComponent implements OnInit { this.categories = data.records.filter(category => category.isactive == 1); }, error => { - this.errorMessage = "No Category Record Found."; + this.notifier.notify('warning', 'No Category Records Found.!'); + this.errorMessage = "No Category Records Found."; } ) } @@ -106,6 +109,7 @@ export class AddComponent implements OnInit { this.questionsOptions = data.records; }, error => { + this.notifier.notify('warning', 'No Answer Type Records Found.!'); this.errorMessage = "No Answer Type Record Found."; } ) @@ -126,25 +130,29 @@ export class AddComponent implements OnInit { } else { var answerFormValues = this._addQuesFrom.value; - //To Remove The "Null" With Key also - Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); - //Add BRANCH data with help Service File - this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe( - dataresult => { - if (dataresult.status == 200) { - console.log(dataresult); - alert("sample alert for Saving"); - } - else { - this.errorMessage = "Some Thing Wents Wrong Try Again !"; - } - } , error => { - this.errorMessage = "Some Thing Wents Wrong Try Again !"; - this.dialogRef.close(); - }); - //After Saving the BRANCH data then popup close - // this.dialogRef.close(); + //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(); } } diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.html b/ng6-seed/src/app/template/questions/edit/edit.component.html index 6ee59cc58..a3804dcee 100644 --- a/ng6-seed/src/app/template/questions/edit/edit.component.html +++ b/ng6-seed/src/app/template/questions/edit/edit.component.html @@ -65,8 +65,8 @@
- Active/InActive + Active/InActive
- +
diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.ts b/ng6-seed/src/app/template/questions/edit/edit.component.ts index 726bb8e56..20dd63a40 100644 --- a/ng6-seed/src/app/template/questions/edit/edit.component.ts +++ b/ng6-seed/src/app/template/questions/edit/edit.component.ts @@ -23,6 +23,10 @@ import { import { MastersService } from './../../service/masters/masters.service'; import { QuestionsService } from './../../service/questions/questions.service'; +/* +* Question master details edit component +* : kdk +*/ @Component({ selector: 'app-edit', templateUrl: './edit.component.html', @@ -31,18 +35,18 @@ import { QuestionsService } from './../../service/questions/questions.service'; export class EditComponent implements OnInit { - public pageTitle : string = "Edit Question Details"; + 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; + private notifier: NotifierService; constructor( notifier: NotifierService, @@ -51,8 +55,8 @@ export class EditComponent implements OnInit { private masterService: MastersService, private questionsService: QuestionsService, @Inject(MAT_DIALOG_DATA) public data: any) { - this.notifier = notifier; - } + this.notifier = notifier; + } ngOnInit() { this.loadFormData(); @@ -63,14 +67,14 @@ export class EditComponent implements OnInit { this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); } } - // OnInit Load Category and Question Type Masters this.getCategoryListMaster(); this.getQuestionOptionsMaster(); } - loadAnsData(){ - if (this.data["0"].length > 0) { + // 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; @@ -79,26 +83,29 @@ export class EditComponent implements OnInit { } } + // load form data form the master loadFormData() { - /** Questions Form Datas*/ + /** 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], + isactive: [this.data.isactive], answers: this._formBuilder.array([ // this.initAnswers(null, null), ]) }); } - get f_ans() { return this._addQuesFrom.get('answers'); } - // convenience getter for easy access to form fields get f() { return this._addQuesFrom.controls; } + // form answer details access + get f_ans() { return this._addQuesFrom.get('answers'); } + + // Dynamic Form field creation Functionality : START ===> initAnswers(ans, fk_id, isAct) { isAct = isAct == null ? 1 : isAct; @@ -125,6 +132,7 @@ export class EditComponent implements OnInit { this.categories = data.records.filter(category => category.isactive == 1); }, error => { + this.notifier.notify('warning', 'No Category Records Found.!'); this.errorMessage = "No Category Record Found."; } ) @@ -135,6 +143,7 @@ export class EditComponent implements OnInit { this.questionsOptions = data.records; }, error => { + this.notifier.notify('warning', 'No Answer Type Records Found.!'); this.errorMessage = "No Answer Type Record Found."; } ) @@ -163,17 +172,18 @@ export class EditComponent implements OnInit { dataresult => { if (dataresult.status == 200) { console.log(dataresult); - this.notifier.notify( 'success', 'Your Changes Updated!' ); + this.notifier.notify('success', 'Your Changes Updated.!'); this.dialogRef.close(); // this.notifierService('success', 'You are awesome! I mean it!'); // alert("sample alert for Saving"); } else { - this.notifier.notify( 'warning', 'Something Wents Wrong Try Again !' ); - this.errorMessage = "Something Wents Wrong Try Again !"; + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Something Wents Wrong Try Again.!"; } }, error => { - this.errorMessage = "Some Thing Wents Wrong Try Again !"; + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Some Thing Wents Wrong Try Again.!"; this.dialogRef.close(); }); //After Saving the BRANCH data then popup close diff --git a/ng6-seed/src/app/template/questions/list/list.component.html b/ng6-seed/src/app/template/questions/list/list.component.html index 0ee433bb7..5d45ad099 100644 --- a/ng6-seed/src/app/template/questions/list/list.component.html +++ b/ng6-seed/src/app/template/questions/list/list.component.html @@ -1,58 +1,53 @@
- - -
-
Questions Master
-
List of Questions
-
-
-
-
- - - - - - {{cat.categroy_name}} - - - - + +
+
Questions Master
+
List of Questions
+
+
+
+
+
+ + + + + {{cat.categroy_name}} + + +
+
+
+
+
-
- -
-
- - + + - -
- -
- -
- -
-
- {{ product.categroy_name }} +
+
+ {{ product.categroy_name }} +
+
+
{{ product.question }} +
+
-
-
{{ product.question }} -
-
-
-
- + +
-
- -
-
-
+ +
+ + +
No Record Found ...
+
- - - + - - diff --git a/ng6-seed/src/app/template/questions/list/list.component.scss b/ng6-seed/src/app/template/questions/list/list.component.scss index 67712370e..fa863a272 100644 --- a/ng6-seed/src/app/template/questions/list/list.component.scss +++ b/ng6-seed/src/app/template/questions/list/list.component.scss @@ -44,3 +44,9 @@ color: #fff; box-shadow: 0 2px 3px #c8bbbb; } + +.no-record-found { + font-size: 18px; + color: #03a9f4; + padding : 12px 8px; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.ts b/ng6-seed/src/app/template/questions/list/list.component.ts index c670fd325..4ef7238db 100644 --- a/ng6-seed/src/app/template/questions/list/list.component.ts +++ b/ng6-seed/src/app/template/questions/list/list.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild, OnInit } from '@angular/core'; -import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent} from '@angular/material'; -import { FormGroup, FormControl } from '@angular/forms'; +import { 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'; @@ -9,61 +9,83 @@ import { MastersService } from './../../service/masters/masters.service'; import { AddComponent } from './../add/add.component'; import { EditComponent } from './../edit/edit.component'; +/* +* Questions master List component +* : kdk +*/ @Component({ selector: 'app-list', templateUrl: './list.component.html', styleUrls: ['./list.component.scss'] }) export class ListComponent implements OnInit { - + public productList: any[] = []; public paginationList: any[] = []; public categories: any = []; - public search_cid :any = null; + public search_cid: any = null; + public noQuesMasterRecrdFound: boolean = false; - public filterFormCtrl : FormControl = new FormControl(); - /** control for the MatSelect filter keyword */ - // public masterFilterCtrl: FormControl = new FormControl(); + public filterFormGroupCtrl: FormGroup; + // pagination variable details length = 50; pageIndex = 0; pageSize = 10; - pageEvent: PageEvent; + // data source variable details questionListData = null; public dataLength: number; public dataSource = new MatTableDataSource(); displayedColumns = ['categroy_name', 'question', 'actions']; - + @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; constructor(private dialog: MatDialog, - private questionsService: QuestionsService, - private masterService: MastersService) { - this.getQuestionsMasters(); - } - - getQuestionsMasters(){ - this.search_cid = this.filterFormCtrl.value; - console.log(this.filterFormCtrl); - this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe( - data => { - this.productList = data.records; - this.questionListData = data.records; - // alert(this.userData); - this.dataLength = data.records.length; - this.dataSource.data = this.questionListData; - } - ) - } + private questionsService: QuestionsService, + private masterService: MastersService, + private _formBuilder: FormBuilder) { + this.filterFormGroupCtrl = this._formBuilder.group({ + category: [null, ''] + }); + } ngOnInit() { this.getCategorMaster(); + this.getQuestionsMasters(); } - getCategorMaster() { + // get question master list details + getQuestionsMasters() { + this.noQuesMasterRecrdFound = false; + this.search_cid = this.filterFormGroupCtrl.controls.category.value; + console.log(this.search_cid + ", " + this.filterFormGroupCtrl); + this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe( + data => { + if (data) { + if (data.records) { + this.productList = data.records; + this.questionListData = data.records; + this.dataLength = data.records.length; + this.dataSource.data = this.questionListData; + } else { + this.productList = []; + this.dataLength = null; + this.noQuesMasterRecrdFound = true; + } + } else { + this.productList = []; + this.dataLength = null; + this.noQuesMasterRecrdFound = true; + } + } + ) + } + + // get category master details + getCategorMaster() { this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( data => { this.categories = data.records.filter(category => category.isactive == 1); @@ -74,7 +96,7 @@ export class ListComponent implements OnInit { ) } - ngAfterViewInit() { + ngAfterViewInit() { this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; } @@ -88,30 +110,31 @@ export class ListComponent implements OnInit { // add questions popup model call addNewQuestion() { const dialogRef = this.dialog.open(AddComponent, { - data: {} + data: {}, + disableClose: true }); - dialogRef.afterClosed() - .subscribe(dataresult => { - this.getQuestionsMasters(); - // this.getBranch(); - // this.isPopupOpened = false; - }); + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); } - editQuestion(rowDetails: any){ - const dialogRef = this.dialog.open(EditComponent, { - data: rowDetails + // 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; - }); + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); } - + // padination page event call pageChange(e) { console.log(e); } diff --git a/ng6-seed/src/app/template/questions/questions.module.ts b/ng6-seed/src/app/template/questions/questions.module.ts index 0c8a20bd5..e5e6301fb 100644 --- a/ng6-seed/src/app/template/questions/questions.module.ts +++ b/ng6-seed/src/app/template/questions/questions.module.ts @@ -28,9 +28,8 @@ import { AddComponent } from './add/add.component'; import { EditComponent } from './edit/edit.component'; /* * Question Master Module details +* : kdk */ - - /** * Custom angular notifier options */ @@ -42,7 +41,7 @@ const customNotifierOptions: NotifierOptions = { }, vertical: { position: 'top', - distance: 12, + distance: 32, gap: 10 } }, From 63e34bb3b9c6ff6efdeb94f5735fd17c2da944db Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 3 Oct 2018 10:47:16 +0530 Subject: [PATCH 5/7] merge changes --- ng6-seed/package.json | 2 + ng6-seed/src/app/app.routing.ts | 3 + .../src/app/shared/menu-items/menu-items.ts | 8 + .../template/questions/add/add.component.html | 77 ++++++ .../template/questions/add/add.component.scss | 3 + .../questions/add/add.component.spec.ts | 25 ++ .../template/questions/add/add.component.ts | 155 ++++++++++++ .../questions/edit/edit.component.html | 86 +++++++ .../questions/edit/edit.component.scss | 3 + .../questions/edit/edit.component.spec.ts | 25 ++ .../template/questions/edit/edit.component.ts | 191 +++++++++++++++ .../questions/list/list.component.html | 134 +++++++++++ .../questions/list/list.component.scss | 46 ++++ .../questions/list/list.component.spec.ts | 25 ++ .../template/questions/list/list.component.ts | 119 ++++++++++ .../template/questions/questions.module.ts | 109 +++++++++ .../template/questions/questions.routing.ts | 19 ++ .../service/masters/masters.service.spec.ts | 15 ++ .../service/masters/masters.service.ts | 223 ++++++++++++++++++ .../questions/questions.service.spec.ts | 12 + .../service/questions/questions.service.ts | 70 ++++++ ng6-seed/src/app/template/template.module.ts | 54 +++++ ng6-seed/src/app/template/template.routing.ts | 11 + ng6-seed/src/assets/styles/app.scss | 3 + package-lock.json | 3 + 25 files changed, 1421 insertions(+) create mode 100644 ng6-seed/src/app/template/questions/add/add.component.html create mode 100644 ng6-seed/src/app/template/questions/add/add.component.scss create mode 100644 ng6-seed/src/app/template/questions/add/add.component.spec.ts create mode 100644 ng6-seed/src/app/template/questions/add/add.component.ts create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.html create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.scss create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.spec.ts create mode 100644 ng6-seed/src/app/template/questions/edit/edit.component.ts create mode 100644 ng6-seed/src/app/template/questions/list/list.component.html create mode 100644 ng6-seed/src/app/template/questions/list/list.component.scss create mode 100644 ng6-seed/src/app/template/questions/list/list.component.spec.ts create mode 100644 ng6-seed/src/app/template/questions/list/list.component.ts create mode 100644 ng6-seed/src/app/template/questions/questions.module.ts create mode 100644 ng6-seed/src/app/template/questions/questions.routing.ts create mode 100644 ng6-seed/src/app/template/service/masters/masters.service.spec.ts create mode 100644 ng6-seed/src/app/template/service/masters/masters.service.ts create mode 100644 ng6-seed/src/app/template/service/questions/questions.service.spec.ts create mode 100644 ng6-seed/src/app/template/service/questions/questions.service.ts create mode 100644 ng6-seed/src/app/template/template.module.ts create mode 100644 ng6-seed/src/app/template/template.routing.ts create mode 100644 package-lock.json diff --git a/ng6-seed/package.json b/ng6-seed/package.json index 7dca4c1b4..299250298 100644 --- a/ng6-seed/package.json +++ b/ng6-seed/package.json @@ -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", diff --git a/ng6-seed/src/app/app.routing.ts b/ng6-seed/src/app/app.routing.ts index a4d27b61d..deeef0a53 100644 --- a/ng6-seed/src/app/app.routing.ts +++ b/ng6-seed/src/app/app.routing.ts @@ -22,6 +22,9 @@ export const AppRoutes: Routes = [{ ,{ path:'pdtrigger', loadChildren:'./pd-triger/pd-triger.module#PdTrigerModule' + },{ + path:'template', + loadChildren:'./template/template.module#TemplateModule' } ] }, { diff --git a/ng6-seed/src/app/shared/menu-items/menu-items.ts b/ng6-seed/src/app/shared/menu-items/menu-items.ts index ebc3fe320..ea4fde87b 100644 --- a/ng6-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/menu-items.ts @@ -44,6 +44,14 @@ const MENUITEMS : Menu[] = [ // children:[ // {state:'pdtriggerlist',name:'Pd Trigger Listing'} // ] + },{ + state: 'template', + name: 'Template', + type: 'sub', + icon: 'art_track', + children: [ + {state: 'questions', name: 'Questions'} + ] }, { state: 'authentication', diff --git a/ng6-seed/src/app/template/questions/add/add.component.html b/ng6-seed/src/app/template/questions/add/add.component.html new file mode 100644 index 000000000..48a04cea6 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.html @@ -0,0 +1,77 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+
+ +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + +
+
+
+
+ + +
+
+ + +
+ + +
+ +
+
+
\ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.scss b/ng6-seed/src/app/template/questions/add/add.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.scss @@ -0,0 +1,3 @@ +.example-full-width{ + width: 100%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.spec.ts b/ng6-seed/src/app/template/questions/add/add.component.spec.ts new file mode 100644 index 000000000..fdcddf4c8 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AddComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/add/add.component.ts b/ng6-seed/src/app/template/questions/add/add.component.ts new file mode 100644 index 000000000..60ccf36f4 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.ts @@ -0,0 +1,155 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, +} from '@angular/forms'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { MastersService } from './../../service/masters/masters.service'; +import { QuestionsService } from './../../service/questions/questions.service'; + +@Component({ + selector: 'app-add', + templateUrl: './add.component.html', + styleUrls: ['./add.component.scss'] +}) +export class AddComponent implements OnInit { + + public pageTitle : string = "Add Question Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public questionsOptions: any = []; + errorMessage: string; + + constructor(private _formBuilder: FormBuilder, + private dialogRef: MatDialogRef, + private masterService: MastersService, + private questionsService: QuestionsService) { } + + + ngOnInit() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + question: [null, Validators.compose([Validators.required])], + description: [null, Validators.compose([Validators.required])], + fk_question_catagory: [null, Validators.compose([Validators.required])], + fk_question_answertype: [null, Validators.compose([Validators.required])], + answers: this._formBuilder.array([ + this.initAnswers(), + ]) + }); + // OnInit Load Category and Question Type Masters + this.getCategoryListMaster(); + this.getQuestionOptionsMaster(); + + // /** For SelectDrop Datas*/ + // this._mastersService.getAllMasterData('CITY') + // .subscribe( + // data => { + + // if (data.status == 200) { + // this.citydatas = data.records; + // this.citydatas = this.citydatas.filter(city=>city.isactive == 1 ); + // } + + // }, error => this.errorMessage = error); + + } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + + // Dynamic Form field creation Functionality : START ===> + initAnswers() { + return this._formBuilder.group({ + answer: ['', Validators.compose([Validators.required])] + }); + } + addLanguage(e) { + const control = this._addQuesFrom.controls['answers']; + control.push(this.initAnswers()); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['answers']; + control.removeAt(i); + } + + // END ===> + + getCategoryListMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + this.errorMessage = "No Category Record Found."; + } + ) + } + getQuestionOptionsMaster() { + this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe( + data => { + this.questionsOptions = data.records; + }, + error => { + this.errorMessage = "No Answer Type Record Found."; + } + ) + } + + /** For Popup Close Button */ + onNoClick(): void { + this.dialogRef.close(); + } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addQuesFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var answerFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + //Add BRANCH data with help Service File + this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + alert("sample alert for Saving"); + } + else { + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + } + } , error => { + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + this.dialogRef.close(); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + /** To Reset Popup Data */ + onReset() { + this._addQuesFrom.reset(); + } +} diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.html b/ng6-seed/src/app/template/questions/edit/edit.component.html new file mode 100644 index 000000000..6ee59cc58 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.html @@ -0,0 +1,86 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+ +
+ +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + + +
+
+
+
+ + +
+
+
+ Active/InActive +
+ + +
+ + +
+ +
+
+
+ + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.scss b/ng6-seed/src/app/template/questions/edit/edit.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.scss @@ -0,0 +1,3 @@ +.example-full-width{ + width: 100%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts b/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts new file mode 100644 index 000000000..34ef921a1 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.ts b/ng6-seed/src/app/template/questions/edit/edit.component.ts new file mode 100644 index 000000000..726bb8e56 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.ts @@ -0,0 +1,191 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA +} from '@angular/material'; +/** Service */ +import { MastersService } from './../../service/masters/masters.service'; +import { QuestionsService } from './../../service/questions/questions.service'; + +@Component({ + selector: 'app-edit', + templateUrl: './edit.component.html', + styleUrls: ['./edit.component.scss'] +}) +export class EditComponent implements OnInit { + + + public pageTitle : string = "Edit Question Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public questionsOptions: any = []; + errorMessage: string; + + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, + private dialogRef: MatDialogRef, + private masterService: MastersService, + private questionsService: QuestionsService, + @Inject(MAT_DIALOG_DATA) public data: any) { + this.notifier = notifier; + } + + ngOnInit() { + this.loadFormData(); + if (this.data["0"].length > 0) { + for (let val of this.data["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); + } + } + + // OnInit Load Category and Question Type Masters + this.getCategoryListMaster(); + this.getQuestionOptionsMaster(); + } + + loadAnsData(){ + if (this.data["0"].length > 0) { + for (let val of this.data["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); + } + } + } + + loadFormData() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + question_id: [this.data.question_id], + question: [this.data.question, Validators.compose([Validators.required])], + description: [this.data.description, Validators.compose([Validators.required])], + fk_question_catagory: [this.data.fk_question_catagory, Validators.compose([Validators.required])], + fk_question_answertype: [this.data.fk_question_answertype, Validators.compose([Validators.required])], + isactive:[this.data.isactive], + answers: this._formBuilder.array([ + // this.initAnswers(null, null), + ]) + }); + } + + get f_ans() { return this._addQuesFrom.get('answers'); } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + + // Dynamic Form field creation Functionality : START ===> + initAnswers(ans, fk_id, isAct) { + isAct = isAct == null ? 1 : isAct; + return this._formBuilder.group({ + answer: [ans, Validators.compose([Validators.required])], + question_answer_id: [fk_id], + isactive: [isAct] + }); + } + addLanguage(ans, fk_id, isAct, e) { + const control = this._addQuesFrom.controls['answers']; + control.push(this.initAnswers(ans, fk_id, isAct)); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['answers']; + control.removeAt(i); + } + + // END ===> + + getCategoryListMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + this.errorMessage = "No Category Record Found."; + } + ) + } + getQuestionOptionsMaster() { + this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe( + data => { + this.questionsOptions = data.records; + }, + error => { + this.errorMessage = "No Answer Type Record Found."; + } + ) + } + + /** For Popup Close Button */ + onNoClick(): void { + this.dialogRef.close(); + } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addQuesFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var answerFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + //Add BRANCH data with help Service File + this.questionsService.updateQuestionMasterDetails(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify( 'success', 'Your Changes Updated!' ); + this.dialogRef.close(); + // this.notifierService('success', 'You are awesome! I mean it!'); + // alert("sample alert for Saving"); + } + else { + this.notifier.notify( 'warning', 'Something Wents Wrong Try Again !' ); + this.errorMessage = "Something Wents Wrong Try Again !"; + } + }, error => { + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + this.dialogRef.close(); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + /** To Reset Popup Data */ + onReset() { + // this._addQuesFrom.reset(); + this.loadFormData(); + this.loadAnsData(); + } + +} diff --git a/ng6-seed/src/app/template/questions/list/list.component.html b/ng6-seed/src/app/template/questions/list/list.component.html new file mode 100644 index 000000000..0ee433bb7 --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.html @@ -0,0 +1,134 @@ +
+ + + +
+
Questions Master
+
List of Questions
+
+
+
+
+ + + + + + {{cat.categroy_name}} + + + + +
+
+
+ +
+
+ +
+ + +
+ +
+ +
+ +
+
+ {{ product.categroy_name }} +
+
+
{{ product.question }} +
+
+
+
+
+ + + + +
+
+ +
+
+
+ + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.scss b/ng6-seed/src/app/template/questions/list/list.component.scss new file mode 100644 index 000000000..67712370e --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.scss @@ -0,0 +1,46 @@ +// mat table css + +.example-container { + display: flex; + flex-direction: column; + min-width: 300px; +} + +.example-header { + min-height: 64px; + padding: 8px 24px 0; +} + +.mat-form-field { + font-size: 14px; +// width: 100%; +} + +.mat-table { + overflow: auto; + max-height: 500px; +} + +.text-line-limit { + text-overflow: ellipsis; + overflow: hidden; + // white-space: nowrap; + display: -webkit-box; + line-height: 16px; /* fallback */ + max-height: 32px; /* fallback */ + -webkit-line-clamp: 2; /* number of lines to show */ + -webkit-box-orient: vertical; + + // text-overflow: ellipsis; + // overflow: hidden; + // width: 160px; + // height: 1.2em; + // white-space: nowrap; +} + +.category-label { + padding: 2px 6px; + background: #629cff; + color: #fff; + box-shadow: 0 2px 3px #c8bbbb; +} diff --git a/ng6-seed/src/app/template/questions/list/list.component.spec.ts b/ng6-seed/src/app/template/questions/list/list.component.spec.ts new file mode 100644 index 000000000..beacd156f --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/list/list.component.ts b/ng6-seed/src/app/template/questions/list/list.component.ts new file mode 100644 index 000000000..c670fd325 --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.ts @@ -0,0 +1,119 @@ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent} from '@angular/material'; +import { FormGroup, FormControl } from '@angular/forms'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { QuestionsService } from './../../service/questions/questions.service'; +import { MastersService } from './../../service/masters/masters.service'; +/** Dialog Component */ +import { AddComponent } from './../add/add.component'; +import { EditComponent } from './../edit/edit.component'; + +@Component({ + selector: 'app-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] +}) +export class ListComponent implements OnInit { + + public productList: any[] = []; + public paginationList: any[] = []; + public categories: any = []; + public search_cid :any = null; + + public filterFormCtrl : FormControl = new FormControl(); + /** control for the MatSelect filter keyword */ + // public masterFilterCtrl: FormControl = new FormControl(); + + length = 50; + pageIndex = 0; + pageSize = 10; + + pageEvent: PageEvent; + + questionListData = null; + public dataLength: number; + public dataSource = new MatTableDataSource(); + displayedColumns = ['categroy_name', 'question', 'actions']; + + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + + constructor(private dialog: MatDialog, + private questionsService: QuestionsService, + private masterService: MastersService) { + this.getQuestionsMasters(); + } + + getQuestionsMasters(){ + this.search_cid = this.filterFormCtrl.value; + console.log(this.filterFormCtrl); + this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe( + data => { + this.productList = data.records; + this.questionListData = data.records; + // alert(this.userData); + this.dataLength = data.records.length; + this.dataSource.data = this.questionListData; + } + ) + } + + ngOnInit() { + this.getCategorMaster(); + } + + getCategorMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + // this.errorMessage = "No Category Record Found."; + } + ) + } + + ngAfterViewInit() { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + applyFilter(filterValue: string) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches + this.dataSource.filter = filterValue; + } + + // add questions popup model call + addNewQuestion() { + const dialogRef = this.dialog.open(AddComponent, { + data: {} + }); + + dialogRef.afterClosed() + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); + } + + editQuestion(rowDetails: any){ + const dialogRef = this.dialog.open(EditComponent, { + data: rowDetails + }); + + dialogRef.afterClosed() + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); + } + + pageChange(e) { + console.log(e); + } + +} diff --git a/ng6-seed/src/app/template/questions/questions.module.ts b/ng6-seed/src/app/template/questions/questions.module.ts new file mode 100644 index 000000000..0c8a20bd5 --- /dev/null +++ b/ng6-seed/src/app/template/questions/questions.module.ts @@ -0,0 +1,109 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { NotifierModule, NotifierOptions } from 'angular-notifier'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule, + MatListModule, MatMenuModule, + MatCheckboxModule +} from '@angular/material'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +// Questions Routing import +import { QuestionsRouting } from './questions.routing'; +// Questions List +import { ListComponent } from './list/list.component'; + +import { QuestionsService } from './../service/questions/questions.service'; +import { AddComponent } from './add/add.component'; +import { EditComponent } from './edit/edit.component'; +/* +* Question Master Module details +*/ + + +/** + * Custom angular notifier options + */ +const customNotifierOptions: NotifierOptions = { + position: { + horizontal: { + position: 'right', + distance: 12 + }, + vertical: { + position: 'top', + distance: 12, + gap: 10 + } + }, + theme: 'material', + behaviour: { + autoHide: 5000, + onClick: 'hide', + onMouseover: 'pauseAutoHide', + showDismissButton: true, + stacking: 4 + }, + animations: { + enabled: true, + show: { + preset: 'slide', + speed: 300, + easing: 'ease' + }, + hide: { + preset: 'fade', + speed: 300, + easing: 'ease', + offset: 50 + }, + shift: { + speed: 300, + easing: 'ease' + }, + overlap: 150 + } +}; + +@NgModule({ + imports: [ + CommonModule, + NotifierModule.withConfig(customNotifierOptions), + FlexLayoutModule, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule, + MatSlideToggleModule, + MatCheckboxModule, + FormsModule, + ReactiveFormsModule, + QuestionsRouting + ], + declarations: [ + ListComponent, + AddComponent, + EditComponent + ], + entryComponents: [ + AddComponent, + EditComponent + ], + providers: [ + QuestionsService + ] +}) +export class QuestionsModule { } diff --git a/ng6-seed/src/app/template/questions/questions.routing.ts b/ng6-seed/src/app/template/questions/questions.routing.ts new file mode 100644 index 000000000..0f07ea048 --- /dev/null +++ b/ng6-seed/src/app/template/questions/questions.routing.ts @@ -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 {} diff --git a/ng6-seed/src/app/template/service/masters/masters.service.spec.ts b/ng6-seed/src/app/template/service/masters/masters.service.spec.ts new file mode 100644 index 000000000..2550bd5a4 --- /dev/null +++ b/ng6-seed/src/app/template/service/masters/masters.service.spec.ts @@ -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(); + })); +}); diff --git a/ng6-seed/src/app/template/service/masters/masters.service.ts b/ng6-seed/src/app/template/service/masters/masters.service.ts new file mode 100644 index 000000000..0448504d2 --- /dev/null +++ b/ng6-seed/src/app/template/service/masters/masters.service.ts @@ -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 { + 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(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 { + + 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 { + + //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 { + return this._http.post(this.apiUrl+"getListOfMaster", { "master_name":TableName }) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + /** + * TO get Branch Data For Listing Screen + */ + getAllBranch(): Observable { + return this._http.get(this.apiUrl+'getListOfBranches') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + + + /** + * TO get Subproduct Data For Listing Screen + */ + getAllSubProduct(): Observable { + + return this._http.get(this.apiUrl+'getListOfSubProduct') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + + /** + * TO get State Data For Listing Screen + */ + getAllState(): Observable { + + return this._http.get(this.apiUrl+'getListOfState') + .pipe( + catchError(this.handleError('role', [])) + ) + + + } + + /** + * TO get Company Data For Listing Screen + */ + getAllCompany(): Observable { + + return this._http.get(this.apiUrl+'getListOfCompany') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + /** + * TO get City Data For Listing Screen + */ + getAllCity(): Observable { + + return this._http.get(this.apiUrl+'getListOfCity') + .pipe( + catchError(this.handleError('role', [])) + ) + +} + + + /** Get All EntityType Data using API call With master Keyword */ + // getAllEntityType(): Observable { + // 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(operation = 'operation', result?: T) { + + return (error: any): Observable => { + return of(result as T); + }; +} +addCompanyDetails +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/service/questions/questions.service.spec.ts b/ng6-seed/src/app/template/service/questions/questions.service.spec.ts new file mode 100644 index 000000000..831ec17b2 --- /dev/null +++ b/ng6-seed/src/app/template/service/questions/questions.service.spec.ts @@ -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(); + }); +}); diff --git a/ng6-seed/src/app/template/service/questions/questions.service.ts b/ng6-seed/src/app/template/service/questions/questions.service.ts new file mode 100644 index 000000000..1b532635c --- /dev/null +++ b/ng6-seed/src/app/template/service/questions/questions.service.ts @@ -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 { + return this._http.get(this.serviceUrl); + } + + // get questions master details list + getQuestionMasterDetails(cid: any): Observable { + // 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(this.apiUrl + "listAllQuestions/get", options); + } + + // add question master + addQuestionMasterDetails(Records: any): Observable { + 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(this.apiUrl + "saveNewQuestion", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + updateQuestionMasterDetails(Records: any): Observable { + 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(this.apiUrl + "saveExistQuestion", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + /** + * TO Handle The Error + */ + private handleError(operation = 'operation', result?: T) { + + return (error: any): Observable => { + return of(result as T); + }; + } + +} diff --git a/ng6-seed/src/app/template/template.module.ts b/ng6-seed/src/app/template/template.module.ts new file mode 100644 index 000000000..452fcd0cc --- /dev/null +++ b/ng6-seed/src/app/template/template.module.ts @@ -0,0 +1,54 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule } from '@angular/material'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; +import { TreeModule } from 'angular-tree-component'; +import { NgxDatatableModule } from '@swimlane/ngx-datatable'; +import { FlexLayoutModule } from '@angular/flex-layout'; + +import { DemoMaterialModule } from '../shared/demo.module'; +// import { NgxMatSelectSearchModule } from 'ngx-mat-select-search'; +import 'hammerjs'; +import { RouterModule } from '@angular/router'; + + +import { QuestionsModule } from './questions/questions.module'; +/** Template Routes */ +import { TemplateRoutes } from './template.routing'; + +/** Master Service */ +import { MastersService } from './service/masters/masters.service'; + + +// import { HttpClientModule } from '@angular/common/http'; +@NgModule({ + imports: [ + CommonModule, + RouterModule.forChild(TemplateRoutes), + QuestionsModule, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule, + FormsModule,ReactiveFormsModule, + // HttpClientModule, + ], + + providers:[ + MastersService + ] +}) +export class TemplateModule { } diff --git a/ng6-seed/src/app/template/template.routing.ts b/ng6-seed/src/app/template/template.routing.ts new file mode 100644 index 000000000..0aee5b6fd --- /dev/null +++ b/ng6-seed/src/app/template/template.routing.ts @@ -0,0 +1,11 @@ +import { Routes } from '@angular/router'; +import { QuestionsModule } from './questions/questions.module'; + +export const TemplateRoutes: Routes = [{ + path: '', + children:[{ + path:'questions', + loadChildren:'./questions/questions.module#QuestionsModule' + } +] +}] diff --git a/ng6-seed/src/assets/styles/app.scss b/ng6-seed/src/assets/styles/app.scss index d966db745..a5b6d83cc 100644 --- a/ng6-seed/src/assets/styles/app.scss +++ b/ng6-seed/src/assets/styles/app.scss @@ -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"; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..48e341a09 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} From 43b67bb7d3c7faa2fb1b11e7a18c08de150fe28b Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 3 Oct 2018 11:20:41 +0530 Subject: [PATCH 6/7] questions conflict changes --- ng6-seed/package-lock.json | 10 + .../template/questions/add/add.component.html | 215 ++++--------- .../template/questions/add/add.component.ts | 63 ---- .../questions/edit/edit.component.html | 169 +++++----- .../template/questions/edit/edit.component.ts | 64 ---- .../questions/list/list.component.html | 303 ++++++------------ .../questions/list/list.component.scss | 5 +- .../template/questions/list/list.component.ts | 89 ----- .../template/questions/questions.module.ts | 10 - 9 files changed, 266 insertions(+), 662 deletions(-) diff --git a/ng6-seed/package-lock.json b/ng6-seed/package-lock.json index acab22cae..656543677 100644 --- a/ng6-seed/package-lock.json +++ b/ng6-seed/package-lock.json @@ -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", diff --git a/ng6-seed/src/app/template/questions/add/add.component.html b/ng6-seed/src/app/template/questions/add/add.component.html index f9dc06f56..c088d4150 100644 --- a/ng6-seed/src/app/template/questions/add/add.component.html +++ b/ng6-seed/src/app/template/questions/add/add.component.html @@ -1,154 +1,77 @@
-<<<<<<< HEAD - -
-

{{pageTitle}}

-
-
- -
-
-
- -
- - - {{ ct.categroy_name }} - - You must Select Category. - -
-
- - - You must Include Question. - -
-
- - - You must Include Description. - -
-
- - - {{ ans.answer_type_name }} - - You must Select Answer Type. - -
-
-
-
-
-
-
- - - - - -
-
- - - -
-
-
+ +
+

{{pageTitle}}

+
+
+
- -
-
- - -
- - - {{ ct.categroy_name }} - - You must Select Category. - -
-
- - - You must Include Question. - -
-
- - - You must Include Description. - -
-
- - - {{ ans.answer_type_name }} - - You must Select Answer Type. - -
-
-
-
-
-
-
- - - - - -
-
- - - + + +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + +
+ +
- -
-
- - -<<<<<<< HEAD -
- - -
- - - -======= -
- - -
- - - ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe -
\ No newline at end of file + + +
+ + +
+ + + +
\ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.ts b/ng6-seed/src/app/template/questions/add/add.component.ts index d904ca310..c8824cd9e 100644 --- a/ng6-seed/src/app/template/questions/add/add.component.ts +++ b/ng6-seed/src/app/template/questions/add/add.component.ts @@ -12,11 +12,8 @@ import { FormArray, } from '@angular/forms'; -<<<<<<< HEAD -======= import { NotifierService } from 'angular-notifier'; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe import { MatDialog, MatDialogRef, @@ -26,38 +23,24 @@ import { import { MastersService } from './../../service/masters/masters.service'; import { QuestionsService } from './../../service/questions/questions.service'; -<<<<<<< HEAD -======= /* * Question master add details * : kdk */ ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe @Component({ selector: 'app-add', templateUrl: './add.component.html', styleUrls: ['./add.component.scss'] }) export class AddComponent implements OnInit { -<<<<<<< HEAD - - public pageTitle : string = "Add Question Details"; -======= public pageTitle: string = "Add Question Details"; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe public _addQuesFrom: FormGroup; public submitted = false; public categories: any = []; public questionsOptions: any = []; errorMessage: string; -<<<<<<< HEAD - constructor(private _formBuilder: FormBuilder, - private dialogRef: MatDialogRef, - private masterService: MastersService, - private questionsService: QuestionsService) { } -======= /** * Notifier service */ @@ -71,7 +54,6 @@ export class AddComponent implements OnInit { private questionsService: QuestionsService) { this.notifier = notifier; } ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe ngOnInit() { @@ -88,22 +70,6 @@ export class AddComponent implements OnInit { // OnInit Load Category and Question Type Masters this.getCategoryListMaster(); this.getQuestionOptionsMaster(); -<<<<<<< HEAD - - // /** For SelectDrop Datas*/ - // this._mastersService.getAllMasterData('CITY') - // .subscribe( - // data => { - - // if (data.status == 200) { - // this.citydatas = data.records; - // this.citydatas = this.citydatas.filter(city=>city.isactive == 1 ); - // } - - // }, error => this.errorMessage = error); - -======= ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe } // convenience getter for easy access to form fields @@ -132,12 +98,8 @@ export class AddComponent implements OnInit { this.categories = data.records.filter(category => category.isactive == 1); }, error => { -<<<<<<< HEAD - this.errorMessage = "No Category Record Found."; -======= this.notifier.notify('warning', 'No Category Records Found.!'); this.errorMessage = "No Category Records Found."; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe } ) } @@ -147,10 +109,7 @@ export class AddComponent implements OnInit { this.questionsOptions = data.records; }, error => { -<<<<<<< HEAD -======= this.notifier.notify('warning', 'No Answer Type Records Found.!'); ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.errorMessage = "No Answer Type Record Found."; } ) @@ -171,27 +130,6 @@ export class AddComponent implements OnInit { } else { var answerFormValues = this._addQuesFrom.value; -<<<<<<< HEAD - //To Remove The "Null" With Key also - Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); - - //Add BRANCH data with help Service File - this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe( - dataresult => { - if (dataresult.status == 200) { - console.log(dataresult); - alert("sample alert for Saving"); - } - else { - this.errorMessage = "Some Thing Wents Wrong Try Again !"; - } - } , error => { - this.errorMessage = "Some Thing Wents Wrong Try Again !"; - this.dialogRef.close(); - }); - //After Saving the BRANCH data then popup close - // this.dialogRef.close(); -======= //To Remove The "Null" With Key also Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); @@ -215,7 +153,6 @@ export class AddComponent implements OnInit { }); //After Saving the BRANCH data then popup close // this.dialogRef.close(); ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe } } diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.html b/ng6-seed/src/app/template/questions/edit/edit.component.html index 0d2782356..159e706ca 100644 --- a/ng6-seed/src/app/template/questions/edit/edit.component.html +++ b/ng6-seed/src/app/template/questions/edit/edit.component.html @@ -1,96 +1,87 @@
- -
-

{{pageTitle}}

-
-
- + +
+

{{pageTitle}}

+
+
+ +
-
- -
- -
- - - {{ ct.categroy_name }} - - You must Select Category. - -
-
- - - You must Include Question. - -
-
- - - You must Include Description. - -
-
- - - {{ ans.answer_type_name }} - - You must Select Answer Type. - -
-
-
-
-
-
-
- - - - - -
-
- - - - + + + +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + + +
+ +
- -
-
-
-<<<<<<< HEAD - Active/InActive -======= - Active/InActive ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe -
- - -
-<<<<<<< HEAD - -======= - ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe - -
- - - -
- - \ No newline at end of file +
+ Active/InActive +
+ + +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.ts b/ng6-seed/src/app/template/questions/edit/edit.component.ts index dfd3287c1..20dd63a40 100644 --- a/ng6-seed/src/app/template/questions/edit/edit.component.ts +++ b/ng6-seed/src/app/template/questions/edit/edit.component.ts @@ -23,13 +23,10 @@ import { import { MastersService } from './../../service/masters/masters.service'; import { QuestionsService } from './../../service/questions/questions.service'; -<<<<<<< HEAD -======= /* * Question master details edit component * : kdk */ ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe @Component({ selector: 'app-edit', templateUrl: './edit.component.html', @@ -38,30 +35,18 @@ import { QuestionsService } from './../../service/questions/questions.service'; export class EditComponent implements OnInit { -<<<<<<< HEAD - public pageTitle : string = "Edit Question Details"; -======= public pageTitle: string = "Edit Question Details"; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe public _addQuesFrom: FormGroup; public submitted = false; public categories: any = []; public questionsOptions: any = []; errorMessage: string; -<<<<<<< HEAD - - /** - * Notifier service - */ - private notifier: NotifierService; -======= /** * Notifier service */ private notifier: NotifierService; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe constructor( notifier: NotifierService, @@ -70,13 +55,8 @@ export class EditComponent implements OnInit { private masterService: MastersService, private questionsService: QuestionsService, @Inject(MAT_DIALOG_DATA) public data: any) { -<<<<<<< HEAD - this.notifier = notifier; - } -======= this.notifier = notifier; } ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe ngOnInit() { this.loadFormData(); @@ -87,23 +67,14 @@ export class EditComponent implements OnInit { this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); } } -<<<<<<< HEAD - -======= ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe // OnInit Load Category and Question Type Masters this.getCategoryListMaster(); this.getQuestionOptionsMaster(); } -<<<<<<< HEAD - loadAnsData(){ - if (this.data["0"].length > 0) { -======= // load answer details list loadAnsData() { if (this.data["0"].length > 0) { ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe for (let val of this.data["0"]) { // alert(JSON.stringify(val)); let vals = val; @@ -112,38 +83,22 @@ export class EditComponent implements OnInit { } } -<<<<<<< HEAD - loadFormData() { - /** Questions Form Datas*/ -======= // load form data form the master loadFormData() { /** Questions Form Datas*/ ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe 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])], -<<<<<<< HEAD - isactive:[this.data.isactive], -======= isactive: [this.data.isactive], ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe answers: this._formBuilder.array([ // this.initAnswers(null, null), ]) }); } -<<<<<<< HEAD - get f_ans() { return this._addQuesFrom.get('answers'); } - - // convenience getter for easy access to form fields - get f() { return this._addQuesFrom.controls; } - -======= // convenience getter for easy access to form fields get f() { return this._addQuesFrom.controls; } @@ -151,7 +106,6 @@ export class EditComponent implements OnInit { get f_ans() { return this._addQuesFrom.get('answers'); } ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe // Dynamic Form field creation Functionality : START ===> initAnswers(ans, fk_id, isAct) { isAct = isAct == null ? 1 : isAct; @@ -178,10 +132,7 @@ export class EditComponent implements OnInit { this.categories = data.records.filter(category => category.isactive == 1); }, error => { -<<<<<<< HEAD -======= this.notifier.notify('warning', 'No Category Records Found.!'); ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.errorMessage = "No Category Record Found."; } ) @@ -192,10 +143,7 @@ export class EditComponent implements OnInit { this.questionsOptions = data.records; }, error => { -<<<<<<< HEAD -======= this.notifier.notify('warning', 'No Answer Type Records Found.!'); ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.errorMessage = "No Answer Type Record Found."; } ) @@ -224,30 +172,18 @@ export class EditComponent implements OnInit { dataresult => { if (dataresult.status == 200) { console.log(dataresult); -<<<<<<< HEAD - this.notifier.notify( 'success', 'Your Changes Updated!' ); -======= this.notifier.notify('success', 'Your Changes Updated.!'); ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.dialogRef.close(); // this.notifierService('success', 'You are awesome! I mean it!'); // alert("sample alert for Saving"); } else { -<<<<<<< HEAD - this.notifier.notify( 'warning', 'Something Wents Wrong Try Again !' ); - this.errorMessage = "Something Wents Wrong Try Again !"; - } - }, error => { - this.errorMessage = "Some Thing Wents Wrong Try Again !"; -======= this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); this.errorMessage = "Something Wents Wrong Try Again.!"; } }, error => { this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); this.errorMessage = "Some Thing Wents Wrong Try Again.!"; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.dialogRef.close(); }); //After Saving the BRANCH data then popup close diff --git a/ng6-seed/src/app/template/questions/list/list.component.html b/ng6-seed/src/app/template/questions/list/list.component.html index 7ca772592..d4f6ed730 100644 --- a/ng6-seed/src/app/template/questions/list/list.component.html +++ b/ng6-seed/src/app/template/questions/list/list.component.html @@ -1,210 +1,119 @@
- -<<<<<<< HEAD - - -
-
Questions Master
-
List of Questions
-
-
-
-
- - - - - - {{cat.categroy_name}} - - - - + + +
+
Questions Master
+
List of Questions
-
-
- -
-
- - - - -
- -
- -
- -
-
- {{ product.categroy_name }} +
+
+
+
+ + + + + {{cat.categroy_name}} + +
-
-
{{ product.question }} -
-
-
+ +
+
+
-
- -
-
- - - - -
- -
- -
- -
-
- {{ product.categroy_name }} -
-
-
{{ product.question }} + + + + +
+ +
+ +
+ +
+
+ {{ product.categroy_name }} +
+
+
{{ product.question }} +
-
-
- - + + + --> +
-
- -<<<<<<< HEAD + + +
+ + +
No Record Found ...
-
- - - - - - - - - - - - - -
- - - - \ No newline at end of file +
+ + + + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.scss b/ng6-seed/src/app/template/questions/list/list.component.scss index 7792de345..fa863a272 100644 --- a/ng6-seed/src/app/template/questions/list/list.component.scss +++ b/ng6-seed/src/app/template/questions/list/list.component.scss @@ -44,12 +44,9 @@ color: #fff; box-shadow: 0 2px 3px #c8bbbb; } -<<<<<<< HEAD -======= .no-record-found { font-size: 18px; color: #03a9f4; padding : 12px 8px; -} ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.ts b/ng6-seed/src/app/template/questions/list/list.component.ts index ea4e65f38..4ef7238db 100644 --- a/ng6-seed/src/app/template/questions/list/list.component.ts +++ b/ng6-seed/src/app/template/questions/list/list.component.ts @@ -1,11 +1,6 @@ import { Component, ViewChild, OnInit } from '@angular/core'; -<<<<<<< HEAD -import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent} from '@angular/material'; -import { FormGroup, FormControl } from '@angular/forms'; -======= import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material'; import { FormGroup, FormControl, FormBuilder } from '@angular/forms'; ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe import { DataSource } from '@angular/cdk/table'; import { Observable } from 'rxjs/Observable'; import { QuestionsService } from './../../service/questions/questions.service'; @@ -14,37 +9,16 @@ import { MastersService } from './../../service/masters/masters.service'; import { AddComponent } from './../add/add.component'; import { EditComponent } from './../edit/edit.component'; -<<<<<<< HEAD -======= /* * Questions master List component * : kdk */ ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe @Component({ selector: 'app-list', templateUrl: './list.component.html', styleUrls: ['./list.component.scss'] }) export class ListComponent implements OnInit { -<<<<<<< HEAD - - public productList: any[] = []; - public paginationList: any[] = []; - public categories: any = []; - public search_cid :any = null; - - public filterFormCtrl : FormControl = new FormControl(); - /** control for the MatSelect filter keyword */ - // public masterFilterCtrl: FormControl = new FormControl(); - - length = 50; - pageIndex = 0; - pageSize = 10; - - pageEvent: PageEvent; - -======= public productList: any[] = []; public paginationList: any[] = []; @@ -61,46 +35,15 @@ export class ListComponent implements OnInit { pageEvent: PageEvent; // data source variable details ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe questionListData = null; public dataLength: number; public dataSource = new MatTableDataSource(); displayedColumns = ['categroy_name', 'question', 'actions']; -<<<<<<< HEAD - -======= ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; constructor(private dialog: MatDialog, -<<<<<<< HEAD - private questionsService: QuestionsService, - private masterService: MastersService) { - this.getQuestionsMasters(); - } - - getQuestionsMasters(){ - this.search_cid = this.filterFormCtrl.value; - console.log(this.filterFormCtrl); - this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe( - data => { - this.productList = data.records; - this.questionListData = data.records; - // alert(this.userData); - this.dataLength = data.records.length; - this.dataSource.data = this.questionListData; - } - ) - } - - ngOnInit() { - this.getCategorMaster(); - } - - getCategorMaster() { -======= private questionsService: QuestionsService, private masterService: MastersService, private _formBuilder: FormBuilder) { @@ -143,7 +86,6 @@ export class ListComponent implements OnInit { // get category master details getCategorMaster() { ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( data => { this.categories = data.records.filter(category => category.isactive == 1); @@ -154,11 +96,7 @@ export class ListComponent implements OnInit { ) } -<<<<<<< HEAD - ngAfterViewInit() { -======= ngAfterViewInit() { ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; } @@ -172,32 +110,6 @@ export class ListComponent implements OnInit { // add questions popup model call addNewQuestion() { const dialogRef = this.dialog.open(AddComponent, { -<<<<<<< HEAD - data: {} - }); - - dialogRef.afterClosed() - .subscribe(dataresult => { - this.getQuestionsMasters(); - // this.getBranch(); - // this.isPopupOpened = false; - }); - } - - editQuestion(rowDetails: any){ - const dialogRef = this.dialog.open(EditComponent, { - data: rowDetails - }); - - dialogRef.afterClosed() - .subscribe(dataresult => { - this.getQuestionsMasters(); - // this.getBranch(); - // this.isPopupOpened = false; - }); - } - -======= data: {}, disableClose: true }); @@ -223,7 +135,6 @@ export class ListComponent implements OnInit { }); } // padination page event call ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe pageChange(e) { console.log(e); } diff --git a/ng6-seed/src/app/template/questions/questions.module.ts b/ng6-seed/src/app/template/questions/questions.module.ts index 872db1b18..e5e6301fb 100644 --- a/ng6-seed/src/app/template/questions/questions.module.ts +++ b/ng6-seed/src/app/template/questions/questions.module.ts @@ -28,14 +28,8 @@ import { AddComponent } from './add/add.component'; import { EditComponent } from './edit/edit.component'; /* * Question Master Module details -<<<<<<< HEAD -*/ - - -======= * : kdk */ ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe /** * Custom angular notifier options */ @@ -47,11 +41,7 @@ const customNotifierOptions: NotifierOptions = { }, vertical: { position: 'top', -<<<<<<< HEAD - distance: 12, -======= distance: 32, ->>>>>>> 3bdd446b0760f030c46f5bea12469a0a15829ebe gap: 10 } }, From 2bad305dbd5520a5fda571999c537492b6fd2c43 Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Thu, 4 Oct 2018 10:58:11 +0530 Subject: [PATCH 7/7] template pages created : kdk --- ng6-seed/src/app/template/template.module.ts | 3 +- ng6-seed/src/app/template/template.routing.ts | 6 +- .../edit/templates.edit.component.html | 2 + .../edit/templates.edit.component.ts | 24 ++++ .../templates.list.component.html | 7 ++ .../templates.list.component.ts | 32 ++++++ .../template/templates/templates.component.ts | 10 ++ .../template/templates/templates.module.ts | 106 ++++++++++++++++++ .../template/templates/templates.routing.ts | 32 ++++++ 9 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html create mode 100644 ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts create mode 100644 ng6-seed/src/app/template/templates/templates-list/templates.list.component.html create mode 100644 ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts create mode 100644 ng6-seed/src/app/template/templates/templates.component.ts create mode 100644 ng6-seed/src/app/template/templates/templates.module.ts create mode 100644 ng6-seed/src/app/template/templates/templates.routing.ts diff --git a/ng6-seed/src/app/template/template.module.ts b/ng6-seed/src/app/template/template.module.ts index 452fcd0cc..732349611 100644 --- a/ng6-seed/src/app/template/template.module.ts +++ b/ng6-seed/src/app/template/template.module.ts @@ -21,7 +21,7 @@ import { DemoMaterialModule } from '../shared/demo.module'; 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'; @@ -35,6 +35,7 @@ import { MastersService } from './service/masters/masters.service'; imports: [ CommonModule, RouterModule.forChild(TemplateRoutes), + TemplatesModule, QuestionsModule, MatCardModule, MatIconModule, diff --git a/ng6-seed/src/app/template/template.routing.ts b/ng6-seed/src/app/template/template.routing.ts index 0aee5b6fd..0872de9b2 100644 --- a/ng6-seed/src/app/template/template.routing.ts +++ b/ng6-seed/src/app/template/template.routing.ts @@ -6,6 +6,10 @@ export const TemplateRoutes: Routes = [{ children:[{ path:'questions', loadChildren:'./questions/questions.module#QuestionsModule' - } + }, + // { + // path:'templates', + // loadChildren:'./templates/templates.module#TemplatesModule' + // } ] }] diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html new file mode 100644 index 000000000..57f5a2657 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html @@ -0,0 +1,2 @@ + +

Template Edit Component

diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts new file mode 100644 index 000000000..f9fbfe5b9 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts @@ -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() { + } + +} diff --git a/ng6-seed/src/app/template/templates/templates-list/templates.list.component.html b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.html new file mode 100644 index 000000000..44ad3e64f --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.html @@ -0,0 +1,7 @@ +
+

Template List Component

+ +
+
+ +
\ No newline at end of file diff --git a/ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts new file mode 100644 index 000000000..0c9bdd767 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts @@ -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); + } + +} diff --git a/ng6-seed/src/app/template/templates/templates.component.ts b/ng6-seed/src/app/template/templates/templates.component.ts new file mode 100644 index 000000000..ace2651e4 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; +@Component({ + template: `

Templates Master Details List

+
+ +
+ ` +}) +export class TemplatesComponent { +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/templates/templates.module.ts b/ng6-seed/src/app/template/templates/templates.module.ts new file mode 100644 index 000000000..2da2ac707 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates.module.ts @@ -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 { } diff --git a/ng6-seed/src/app/template/templates/templates.routing.ts b/ng6-seed/src/app/template/templates/templates.routing.ts new file mode 100644 index 000000000..6afa2b2f0 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates.routing.ts @@ -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 {}