From 50b94aeb234e3cf9af395a054a41d48fbcbd5672 Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Fri, 19 Oct 2018 10:30:19 +0530 Subject: [PATCH] template creation edit screen changes : kdk --- .../service/templates/templates.service.ts | 13 ++ .../edit-category.component.html | 40 ++--- .../edit-lender/edit-lender.component.html | 38 ++--- .../category-question-answer.component.html | 143 +++++++----------- .../category-question-answer.component.ts | 25 ++- .../dialog-category-question-list.html | 7 +- .../templates-add.component.html | 22 +++ .../templates-add.component.scss | 0 .../templates-add.component.spec.ts | 25 +++ .../templates-add/templates-add.component.ts | 87 +++++++++++ .../templates.list.component.html | 2 +- .../templates.list.component.ts | 23 ++- .../template/templates/templates.module.ts | 7 +- 13 files changed, 299 insertions(+), 133 deletions(-) create mode 100644 ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.html create mode 100644 ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.scss create mode 100644 ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.spec.ts create mode 100644 ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.ts diff --git a/ng6-seed/src/app/template/service/templates/templates.service.ts b/ng6-seed/src/app/template/service/templates/templates.service.ts index 149cd3265..e7349be3a 100644 --- a/ng6-seed/src/app/template/service/templates/templates.service.ts +++ b/ng6-seed/src/app/template/service/templates/templates.service.ts @@ -28,6 +28,12 @@ export class TemplatesService { return this._http.get(this.apiUrl + "listAllTemplates/any", options); } + addNewTemplate(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 + "saveNewTemplateName", {'records': Records }); + } + getTemplateIDNameDetails(temp_id: number): Observable{ // Add safe, URL encoded search parameter if there is a search term return this._http.post(this.apiUrl + "getTemplateMaster", {'template_id': temp_id }); @@ -49,6 +55,8 @@ export class TemplatesService { let records = Records.map(item=>{ item.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record item.updatedon = currentdate;//to get Current date and Time for when the Record is created + item.createdon = item.createdon == null ? currentdate : item.createdon; + item.fk_createdby = item.fk_createdby == null ? this._aws.getlocale() : item.fk_createdby; return item; }); return this._http.post(this.apiUrl + "saveTemplateLenderDetails", {'records': records }); @@ -65,6 +73,8 @@ export class TemplatesService { let records = Records.map(item=>{ item.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record item.updatedon = currentdate;//to get Current date and Time for when the Record is created + item.createdon = item.createdon == null ? currentdate : item.createdon; + item.fk_createdby = item.fk_createdby == null ? this._aws.getlocale() : item.fk_createdby; return item; }); return this._http.post(this.apiUrl + "saveTemplateCategoryDetails", {'records': records }); @@ -81,6 +91,9 @@ export class TemplatesService { let records = Records.map(item=>{ item.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record item.updatedon = currentdate; + item.createdon = item.createdon == null ? currentdate : item.createdon; + item.fk_createdby = item.fk_createdby == null ? this._aws.getlocale() : item.fk_createdby; + // item.answers = item.answers.map(subItem=>{ // subItem.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record // subItem.updatedon = currentdate; diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/edit-category/edit-category.component.html b/ng6-seed/src/app/template/templates/templates-list/edit/edit-category/edit-category.component.html index 0aa387ce1..16e1c1011 100644 --- a/ng6-seed/src/app/template/templates/templates-list/edit/edit-category/edit-category.component.html +++ b/ng6-seed/src/app/template/templates/templates-list/edit/edit-category/edit-category.component.html @@ -4,38 +4,35 @@
- - - - -
-
-
-
+ + +
+
+
- + {{ category.category_name }} + Category Required.! This Category Already Exist.!
-
- - +
+ + % + Weightage Required.!
-
- - -
-
+
+ +
+
This Category Already Exist.! -
+
+
+ +
diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/edit-lender/edit-lender.component.html b/ng6-seed/src/app/template/templates/templates-list/edit/edit-lender/edit-lender.component.html index c1a06d41c..44294fcb1 100644 --- a/ng6-seed/src/app/template/templates/templates-list/edit/edit-lender/edit-lender.component.html +++ b/ng6-seed/src/app/template/templates/templates-list/edit/edit-lender/edit-lender.component.html @@ -7,42 +7,42 @@
-
+
-
- - +
+ + {{ lend.full_name }} - + Lender Type Required.! - - + + {{ prcd.product_name }} - + Product Required.! - - + + {{ cusSeg.customer_segment }} - + Customer Segment Required.! -
- - - - - +
+ + + + +
-
+
diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.html b/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.html index a5c7e95da..376ea5f45 100644 --- a/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.html +++ b/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.html @@ -1,102 +1,71 @@ - - - - - -
- -
- -
- - -
+
+ + + - + +
+ This Question Answer Already Exist.! +
+ + +
+
- -
-
- +
+
+ {{i+1}} ) +
+
+ + + % + Ques. WT is Required.! +
+
+ +
-
- - - % -
-
- -
-
-
- - -
+
+
-
-
- - - - +
+
+
+ {{i_ans+1}}. {{answ.get('answer').value}} +
+
-
- +
+
-
-
- - - - - +
-
- This Category Already Exist.! -
-
-
- -
- \ No newline at end of file + +
+ +
+
+ +
+ + + + \ No newline at end of file diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.ts b/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.ts index d75b7680b..b585f3ffb 100644 --- a/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.ts +++ b/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component.ts @@ -14,6 +14,9 @@ export interface DialogData { name: string; } +/**sweet alert */ +// import Swal from 'sweetalert2'; + @Component({ selector: 'app-category-question-answer', templateUrl: './category-question-answer.component.html', @@ -21,6 +24,9 @@ export interface DialogData { }) export class CategoryQuestionAnswerComponent implements OnInit { + countries = ['d', 'd', 'd', 'd', 'd' ,'d']; + regularDistribution = 100 / 3; + @Input() CaterogyQuesAns: any; _editquestionAnswerForm: FormGroup; @@ -246,7 +252,8 @@ alert(); alert("duplication records occured.!"); } } else { - alert("value should equal to 100") + // Swal('value should equal to 100.!','error'); + alert("value should equal to 100"); } } @@ -276,6 +283,11 @@ alert(); @Component({ selector: 'dialog-overview-example-dialog', + styles:[` +.listHover: hover { + background: yellow; + }` + ], templateUrl: './dialog-category-question-list.html' }) export class DialogOverviewExampleDialog { @@ -301,12 +313,21 @@ export class DialogOverviewExampleDialog { this.dialogRef.close(ques); } + errorRecord : string; + noRecordFound: boolean; + getCategoryRemainingQuesMasters() { this.templatesService.getRemaningQuestionCategory(this.data).subscribe( data => { - this.m_questions = data.records; + if(data.status === 200 && data.dataStatus){ + this.noRecordFound = true; + this.m_questions = data.records; + } else { + this.noRecordFound = false; + } }, error => { + this.noRecordFound = true; // this.notifier.notify('warning', 'No Category Master Records Found.!'); // this.m_category = "No Category Master Records Found."; } diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/dialog-category-question-list.html b/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/dialog-category-question-list.html index 1a0eee7f0..23123f789 100644 --- a/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/dialog-category-question-list.html +++ b/ng6-seed/src/app/template/templates/templates-list/edit/edit-question-answer/category-question-answer/dialog-category-question-list.html @@ -1,5 +1,10 @@
- +
+ {{question.question}} +
+
+
No Records Found.!
+
\ No newline at end of file diff --git a/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.html b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.html new file mode 100644 index 000000000..dfb621198 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.html @@ -0,0 +1,22 @@ +
+
+ +
+ +
Add New Template
+
+
+
+ + + You must Include Template Name. + +
+
+ + +
+
+
+
diff --git a/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.scss b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.spec.ts b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.spec.ts new file mode 100644 index 000000000..e56816d05 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TemplatesAddComponent } from './templates-add.component'; + +describe('TemplatesAddComponent', () => { + let component: TemplatesAddComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TemplatesAddComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TemplatesAddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.ts b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.ts new file mode 100644 index 000000000..ced56c9af --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates-add/templates-add.component.ts @@ -0,0 +1,87 @@ +/** 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 { TemplatesService } from './../../../service/templates/templates.service'; + +@Component({ + selector: 'app-templates-add', + templateUrl: './templates-add.component.html', + styleUrls: ['./templates-add.component.scss'] +}) +export class TemplatesAddComponent implements OnInit { + + + public _addTemplateFrom: FormGroup; + public submitted = false; + + constructor(private _formBuilder: FormBuilder, + private templatesService: TemplatesService, + private dialogRef: MatDialogRef) { + /** Add New Template Name Form Datas*/ + this._addTemplateFrom = this._formBuilder.group({ + template_id: [''], + template_name: [null, Validators.compose([Validators.required])], + isactive: [1] + }); + } + + // convenience getter for easy access to form fields + get f() { return this._addTemplateFrom.controls; } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addTemplateFrom.invalid) { + // this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var answerFormValues = this._addTemplateFrom.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.templatesService.addNewTemplate(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + // {"dataStatus":true,"status":200,"records":4} + this.dialogRef.close(dataresult); + } + else { + + } + }, error => { + this.dialogRef.close(null); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + onClose() { + this.dialogRef.close(null); + } + + 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 index ab73ed692..ad83465a8 100644 --- 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 @@ -21,7 +21,7 @@ -->
- +
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 index f2c7aefba..259130ea9 100644 --- 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 @@ -7,6 +7,8 @@ import { Observable } from 'rxjs/Observable'; import { TemplatesService } from './../../service/templates/templates.service'; +import { TemplatesAddComponent } from './templates-add/templates-add.component'; + /* * Template List component * : kdk @@ -42,7 +44,8 @@ export class TemplateListComponent implements OnInit, OnDestroy { constructor( private route: ActivatedRoute, private router: Router, - private templatesService: TemplatesService) { + private templatesService: TemplatesService, + public dialog: MatDialog) { this.listView = true; // this.names = 'dinesh'; } @@ -85,6 +88,24 @@ export class TemplateListComponent implements OnInit, OnDestroy { ) } + addNewTemplate(): void { + const dialogRef = this.dialog.open(TemplatesAddComponent, { + disableClose: true, + data: { } + }); + + dialogRef.afterClosed().subscribe(result => { + if(result != null) { + this.goToEdit(result.records); + } else { + + } + console.log('The dialog was closed'); + // alert(result); + }); + } + + diff --git a/ng6-seed/src/app/template/templates/templates.module.ts b/ng6-seed/src/app/template/templates/templates.module.ts index 4a9106265..3b4651786 100644 --- a/ng6-seed/src/app/template/templates/templates.module.ts +++ b/ng6-seed/src/app/template/templates/templates.module.ts @@ -33,6 +33,7 @@ import { EditQuestionAnswerComponent } from './templates-list/edit/edit-question import { TemplatesService } from './../service/templates/templates.service'; import { CategoryQuestionAnswerComponent } from './templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component'; import { DialogOverviewExampleDialog } from './templates-list/edit/edit-question-answer/category-question-answer/category-question-answer.component'; +import { TemplatesAddComponent } from './templates-list/templates-add/templates-add.component'; /* * Question Master Module details @@ -111,10 +112,12 @@ const customNotifierOptions: NotifierOptions = { EditLenderComponent, EditQuestionAnswerComponent, CategoryQuestionAnswerComponent, - DialogOverviewExampleDialog + DialogOverviewExampleDialog, + TemplatesAddComponent ], entryComponents: [ - DialogOverviewExampleDialog + DialogOverviewExampleDialog, + TemplatesAddComponent ], providers: [ TemplatesService