diff --git a/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts b/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts index c309a98..b65913a 100644 --- a/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts +++ b/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts @@ -57,10 +57,7 @@ export class BusinessListComponent implements OnInit { this._bus.getBusinessListDetails().subscribe(res => { if (res.status == 200) { this.businessList = res.data; - } - else{ - - } + } } // , error => {this.errorMessage = error}); ,error => { @@ -81,8 +78,8 @@ export class BusinessListComponent implements OnInit { } } - confirmBox(name,element){ - console.log(name,element) + confirmBox(event,element){ + console.log(event,element) Swal.fire({ title: 'Are you sure want to remove?', text: 'You will not be able to recover this file!', @@ -92,7 +89,7 @@ export class BusinessListComponent implements OnInit { cancelButtonText: 'No, keep it' }).then((result) => { if (result.value) { - this.deleteRowData(element); + this.formAddUpdateAndDelete(event,element) Swal.fire( 'Deleted!', 'Your imaginary file has been deleted.', @@ -111,61 +108,91 @@ export class BusinessListComponent implements OnInit { openDialog(action,obj) { obj.action = action; const dialogRef = this.dialog.open(DialogBoxComponent, { - width: '32%', + width: '39%', height: '100%', // maxWidth: '38vw', position: { right: '0' }, data:obj }); dialogRef.afterClosed().subscribe(result => { + if(result != undefined){ console.log(result) - if(result.event == 'Add'){ - this.addRowData(result.data); - }else if(result.event == 'Update'){ - this.updateRowData(result.data); - }else if(result.event == 'Delete'){ - this.deleteRowData(result.data); + this.formAddUpdateAndDelete(result,result.data) } }); } - addRowData(row_obj){ - var d = this.dataSource.data.length+1 - console.log(this.dataSource) - this.dataSource.data.push - ({ - id: d, - logo: row_obj.logo, - name: row_obj.name, - email: row_obj.email, - phone: row_obj.phone, - address: row_obj.address, - city: row_obj.city, - state: row_obj.state - - }); - this.table.renderRows(); - } - updateRowData(row_obj){ - console.log(row_obj) - this.dataSource = this.dataSource.data.filter((value,key)=>{ - if(value.id == row_obj.id){ - value.logo = row_obj.logo; - value.name = row_obj.name; - value.email = row_obj.email; - value.phone = row_obj.phone; - value.address = row_obj.address; - value.city = row_obj.city; - value.state = row_obj.state; + + formAddUpdateAndDelete(result,row_obj){ + console.log(result,row_obj) + let formValue = [] + if(result.event == 'Add'){ + console.log('add') + let addFormData = { + address: row_obj.address, + // busId: 'abc123', + city: row_obj.city, + busName: row_obj.busName, + email: row_obj.email, + contactNo: row_obj.contactNo, + pincode: row_obj.pincode, + state: row_obj.state , + workingHrsJson: row_obj.workingHrsJson + }; + formValue.push(addFormData); + }else if(result.event == 'Update'){ + console.log('Update') + formValue.push(row_obj); + } + else if(result == 'Delete'){ + console.log('delete') + let val = { + isActive:0, + id: row_obj.id } - return true; + formValue.push(val); + } + + // var d = this.customersList.length+1 + console.log(formValue[0]) + this._bus.addFormDetails(formValue[0]).subscribe(res => { + if (res.status == 200) { + // this.customersList = res.data; + this.getBusinessList() + } + else{ + // this.customersList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + // , error => {this.errorMessage = error}); + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); }); } - deleteRowData(row_obj){ - console.log(this.dataSource.data,row_obj) - this.dataSource.data = this.dataSource.data.filter((value,key)=>{ - return value.id != row_obj.id - }); - console.log(this.dataSource) - } + // updateRowData(row_obj){ + // console.log(row_obj) + // this.dataSource = this.dataSource.data.filter((value,key)=>{ + // if(value.id == row_obj.id){ + // value.logo = row_obj.logo; + // value.name = row_obj.name; + // value.email = row_obj.email; + // value.phone = row_obj.phone; + // value.address = row_obj.address; + // value.city = row_obj.city; + // value.state = row_obj.state; + // } + // return true; + // }); + // } + // deleteRowData(row_obj){ + // console.log(this.dataSource.data,row_obj) + // this.dataSource.data = this.dataSource.data.filter((value,key)=>{ + // return value.id != row_obj.id + // }); + // console.log(this.dataSource) + // } } diff --git a/ng-seed/src/app/appoinment/business/business-service/business.service.ts b/ng-seed/src/app/appoinment/business/business-service/business.service.ts index a3b70d8..77d638f 100644 --- a/ng-seed/src/app/appoinment/business/business-service/business.service.ts +++ b/ng-seed/src/app/appoinment/business/business-service/business.service.ts @@ -18,6 +18,13 @@ export class BusinessService { catchError(this.handleError('role', [])) ) } + + addFormDetails(addParams): Observable { + return this._http.post(this.apiUrl + 'createBusinessDetails', addParams) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } private handleError(operation = 'operation', result?: T) { return (error: any): Observable => { diff --git a/ng-seed/src/app/appoinment/business/business.module.ts b/ng-seed/src/app/appoinment/business/business.module.ts index fb3a170..cfbad6d 100644 --- a/ng-seed/src/app/appoinment/business/business.module.ts +++ b/ng-seed/src/app/appoinment/business/business.module.ts @@ -9,6 +9,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { DialogBoxComponent } from './dialog-box/dialog-box.component'; import { ScrollingModule } from '@angular/cdk/scrolling'; import { DemoMaterialModule } from 'app/shared/demo.module'; +import { NgScrollbarModule } from 'ngx-scrollbar'; @@ -25,8 +26,8 @@ import { DemoMaterialModule } from 'app/shared/demo.module'; BusinessRoutingModule, MatSidenavModule, MatFormFieldModule, - ScrollingModule - + ScrollingModule, + NgScrollbarModule ] }) diff --git a/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.html b/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.html index 91e2d0a..81dda04 100644 --- a/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.html +++ b/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.html @@ -1,14 +1,15 @@ - +
{{action}} Business
- -
+ +
+ - - Name is required - Limit exceed + + Name is required + Limit exceed @@ -21,9 +22,9 @@ - - Contact No is required - Limit exceed + + Contact No is required + Limit exceed @@ -40,18 +41,25 @@ City is required Limit exceed - - - -
+ + + Working Hrs is required + Limit exceed + + + - - Sure to delete {{local_data.name}}? -
-
- -
- +
+ + Sure to delete {{local_data.name}}? + +
+ + +
+ + + \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.scss b/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.scss index cf68fba..ad079c5 100644 --- a/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.scss +++ b/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.scss @@ -48,9 +48,15 @@ } } ::ng-deep .mat-dialog-content { - max-height: 75vh!important; + max-height: 170vh !important; overflow: hidden!important; } ::ng-deep .mat-dialog-container{ overflow: hidden!important; +} +.scrollHV { + height: calc(100vh - 150px); +} +:ng-deep .ng-scroll-viewport-wrapper{ + right: -25px !important; } \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.ts b/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.ts index 201478a..7d99131 100644 --- a/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.ts +++ b/ng-seed/src/app/appoinment/business/dialog-box/dialog-box.component.ts @@ -28,13 +28,9 @@ export class DialogBoxComponent implements OnInit { get f(){ return this.form.controls; } - doAction(){ - let tmp = this.form.value - tmp.id = this.local_data.id - this.dialogRef.close({event:this.action,data:tmp}); - console.log(this.form.value); - console.log(this.action,this.local_data) - } + // doAction(){ + + // } closeDialog(){ this.dialogRef.close({event:'Cancel'}); } @@ -52,16 +48,16 @@ export class DialogBoxComponent implements OnInit { } ngOnInit() { this.form = new FormGroup({ - businessselect: new FormControl('', [Validators.required]), - image: new FormControl('', null), - name: new FormControl('', [Validators.required, Validators.maxLength(20)]), + workingHrsJson: new FormControl('', [Validators.required]), + logo: new FormControl('', null), + busName: new FormControl('', [Validators.required, Validators.maxLength(20)]), address: new FormControl('', [Validators.required, Validators.maxLength(50)]), city: new FormControl('', [Validators.required, Validators.maxLength(10)]), state: new FormControl('', [Validators.required, Validators.maxLength(10)]), email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', ),]), - contact_no: new FormControl('', [Validators.required, Validators.maxLength(10)]), + contactNo: new FormControl('', [Validators.required, Validators.maxLength(10)]), }); this.form.patchValue(this.local_data) } @@ -69,6 +65,10 @@ export class DialogBoxComponent implements OnInit { return this.form.controls[controlName].hasError(errorName); } submit(){ + let tmp = this.form.value + tmp.id = this.local_data.id + this.dialogRef.close({event:this.action,data:tmp}); console.log(this.form.value); + console.log(this.action,this.local_data) } } diff --git a/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts b/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts index e836fc7..3ad75fe 100644 --- a/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts +++ b/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts @@ -129,15 +129,17 @@ export class CustomersListComponent implements OnInit { openDialog(action,obj) { obj.action = action; const dialogRef = this.dialog.open(DialogBoxComponent, { - // width: '30%', + width: '39%', height: '100%', // maxWidth: '38vw', position: { right: '0' }, data:obj }); dialogRef.afterClosed().subscribe(result => { - console.log(result) - this.formAddUpdateAndDelete(result,result.data) + if(result != undefined){ + console.log(result) + this.formAddUpdateAndDelete(result,result.data) + } }); } diff --git a/ng-seed/src/app/appoinment/customers/customers.module.ts b/ng-seed/src/app/appoinment/customers/customers.module.ts index 133b556..08254f7 100644 --- a/ng-seed/src/app/appoinment/customers/customers.module.ts +++ b/ng-seed/src/app/appoinment/customers/customers.module.ts @@ -7,6 +7,7 @@ import { MatSidenavModule } from '@angular/material/sidenav'; import { MatFormFieldModule } from '@angular/material/form-field'; import { DialogBoxComponent } from './dialog-box/dialog-box.component'; import { DemoMaterialModule } from 'app/shared/demo.module'; +import { NgScrollbarModule } from 'ngx-scrollbar'; @NgModule({ @@ -20,6 +21,7 @@ import { DemoMaterialModule } from 'app/shared/demo.module'; CustomersRoutingModule, MatSidenavModule, MatFormFieldModule, + NgScrollbarModule ] }) export class CustomersModule { } diff --git a/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.html b/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.html index 5868bed..8518807 100644 --- a/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.html +++ b/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.html @@ -1,10 +1,11 @@ - +
{{action}} Customers
- -
+ +
+ Name is required @@ -49,15 +50,15 @@ --> Sure to delete {{local_data.cusName}}? -
+ +
+
-
-
-
- +
+ -
+ \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.scss b/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.scss index e7ca036..07b61ed 100644 --- a/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.scss +++ b/ng-seed/src/app/appoinment/customers/dialog-box/dialog-box.component.scss @@ -48,7 +48,10 @@ } } ::ng-deep .mat-dialog-content { - max-height: 80vh!important; + max-height: 170vh!important; overflow: hidden!important; } +.scrollHV { + height: calc(100vh - 150px); +} diff --git a/ng-seed/src/app/layouts/admin/admin-layout.component.ts b/ng-seed/src/app/layouts/admin/admin-layout.component.ts index 5d188ca..4ad56de 100644 --- a/ng-seed/src/app/layouts/admin/admin-layout.component.ts +++ b/ng-seed/src/app/layouts/admin/admin-layout.component.ts @@ -218,6 +218,7 @@ users() { }); } logout() { + localStorage.clear(); this.router.navigate(['/']); }