Commit 7faebe91 authored by Sandeep Sagar Panjala's avatar Sandeep Sagar Panjala

added ambulance, role pages

parent 3cf6ed3d
......@@ -48,6 +48,10 @@ const routes: Routes = [
path: "admissions",
loadChildren: () => import('./areas/admin/admissions/admissions.module').then(m => m.AdmissionsModule)
},
{
path: "ambulance",
loadChildren: () => import('./areas/admin/ambulance/ambulance.module').then(m => m.AmbulanceModule)
},
]
},
{ path: "**", redirectTo: "not-found" },
......
<router-outlet></router-outlet>
\ No newline at end of file
import { NgModule } from '@angular/core';
import { SharedModule } from '@src/app/shared/shared.module';
import { ReactiveFormsModule } from '@angular/forms';
import { AmbulanceRoutingModule } from './ambulance.routing.module';
import { NewAmbulanceModulePage } from './ambulance.page';
import { AmbulanceMasterPage } from './pages/masters/masters.page';
import { AmbulanceReceiptPage } from './pages/reciept/reciept.page';
import { AddAmbulancePage } from './pages/masters/add-ambulance/add-ambulance.page';
import { DriverDetailPage } from './pages/masters/driver-detail/driverDetail.page';
@NgModule({
declarations: [
NewAmbulanceModulePage, AmbulanceMasterPage, AmbulanceReceiptPage, AddAmbulancePage, DriverDetailPage
],
imports: [
AmbulanceRoutingModule,
ReactiveFormsModule,
SharedModule
]
})
export class AmbulanceModule { }
\ No newline at end of file
import { Component } from "@angular/core";
@Component({
templateUrl: "./ambulance.html"
})
export class NewAmbulanceModulePage {
}
\ No newline at end of file
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from '@src/app/shared/guards';
import { NewAmbulanceModulePage } from './ambulance.page';
import { AmbulanceReceiptPage } from './pages/reciept/reciept.page';
import { AmbulanceMasterPage } from './pages/masters/masters.page';
import { AddAmbulancePage } from './pages/masters/add-ambulance/add-ambulance.page';
import { DriverDetailPage } from './pages/masters/driver-detail/driverDetail.page';
const routes: Routes = [
{
path: "",
data: { title: "Ambulance" },
canActivate: [AuthGuard],
canActivateChild: [AuthGuard],
component: NewAmbulanceModulePage,
children: [
{ path: "", redirectTo: "ambulance-receipt", pathMatch: "full" },
{ path: "ambulance-receipt", component: AmbulanceReceiptPage, data: { title: "Ambulance Receipts" } },
{
path: "masters",
component: AmbulanceMasterPage,
children: [
{ path: "add-ambulance", component: AddAmbulancePage, data: { title: "Add Ambulance" } },
{ path: "driver-detail", component: DriverDetailPage, data: { title: "Driver Detail" } },
{ path: "**", redirectTo: "add-ambulance" }
]
},
{ path: "**", redirectTo: "ambulance-receipt" }
]
}
]
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AmbulanceRoutingModule { }
\ No newline at end of file
export * from "./ambulance.page";
export * from "./pages/reciept/reciept.page";
export * from "./pages/masters/masters.page";
export * from "./pages/masters/add-ambulance/add-ambulance.page";
export * from "./pages/masters/driver-detail/driverDetail.page";
\ No newline at end of file
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<button type="button" class="btn btn-primary btn-sm" (click)="onOpenModel(ambulanceTemplate)"><i class="fe-plus mr-1"></i> Add </button>
</div>
<h4 class="page-title">Ambulance</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card-box p-0">
<div class="row p-2" *ngIf="loading">
<div class="col-12">
<div class="d-flex align-items-center">
<span class="spinner-grow text-warning" role="status" aria-hidden="true"></span>
<span class="ml-2">Please wait while loading ...</span>
</div>
</div>
</div>
<div class="row p-2" *ngIf="!loading && (!ambulancerecords || !ambulancerecords.length)">
<div class="col-12 mh-400">
<div class="no-data">
<img src="assets/images/no-data.png" alt="No data" />
<p class="sub-title">There is no data to show you right now.</p>
<button type="button" class="btn btn-primary btn-sm" (click)="onOpenModel(ambulanceTemplate)"><i class="fe-plus mr-1"></i> Add </button>
</div>
</div>
</div>
<div class="table-responsive" *ngIf="!loading && ambulancerecords.length > 0">
<table class="table table-sm">
<thead class="table-info">
<tr>
<th>Ambulance No</th>
<th>Assigned No</th>
<th>CreatedBy</th>
<th>Created Date</th>
<th>Modified By</th>
<th>Modified Date</th>
<th>Status</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of ambulancerecords;index as i;">
<td>
<span [textContent]="item.ambulanceNo"></span>
</td>
<td>
<span [textContent]="item.assignedNo"></span>
</td>
<td>
<span class="font-13 mb-0" [textContent]="item.createdByName"></span>
<!--<span class="badge badge-outline-info font-11" [textContent]="item.createdByRole"></span>-->
</td>
<td>
<span [textContent]="item.createdDate | date:'dd-MM-yyyy, hh:mm a'"></span>
</td>
<td>
<div *ngIf="item.modifiedBy">
<h5 class="font-13 mb-0" [textContent]="item.modifiedByName"></h5>
<!--<span class="badge badge-outline-secondary font-11" [textContent]="item.modifiedByRole"></span>-->
</div>
<span *ngIf="!item.modifiedBy">-----</span>
</td>
<td>
<span *ngIf="item.modifiedDate" [textContent]="item.modifiedDate | date:'dd-MM-yyyy, hh:mm a'"></span>
<span *ngIf="!item.modifiedDate">----</span>
</td>
<td>
<span class="badge badge-soft-success" *ngIf="item.active">Active</span>
<span class="badge badge-soft-danger" *ngIf="!item.active">Inactive</span>
</td>
<td>
<div class="d-flex align-items-center justify-content-end">
<a href="javascript:;" class="action-icon text-primary mr-1" placement="left" ngbTooltip="Edit" (click)="onOpenModel(ambulanceTemplate, item)"><i class="fe-edit"></i></a>
<a class="action-icon text-primary mr-1" href="javascript:;" placement="left" ngbTooltip="{{item.active?'Inactive':'Active'}}" (click)="updateStatus(item)"><i *ngIf="item.active" class="fe-x"></i><i *ngIf="!item.active" class="fe-check"></i></a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<ng-template #ambulanceTemplate>
<form [formGroup]="ambulanceForm" (ngSubmit)="onSubmit()">
<div class="modal-header">
<h4 class="modal-title"><i class="mdi mdi-human-edit mr-1"></i>{{ambulanceForm.value.ambulanceId === 0 ? 'Add' : 'Edit'}} Ambulance</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="onCloseModal();">×</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<div class="form-group">
<label class="mb-1">Ambulance No <code>*</code></label>
<input oninput="this.value = this.value.toUpperCase()" class="form-control" placeholder="Enter ambulance no." formControlName="ambulanceNo"
[ngClass]="{ 'is-invalid': submitted && form.ambulanceNo.errors }"
/>
<div class="text-danger" *ngIf="submitted && form.ambulanceNo.errors">
<p *ngIf="form.ambulanceNo.errors.required">Ambulance No is required.</p>
<p *ngIf="form.ambulanceNo.errors.maxlength">Only 250 characters are allowed.</p>
<p *ngIf="form.ambulanceNo.errors.whiteSpaces">Please remove white space...</p>
</div>
</div>
</div>
<div class="col-12">
<div class="form-group">
<label class="mb-1">Assigned Vehicle No <code>*</code></label>
<input type="text" class="form-control" placeholder="Enter Assigned No." formControlName="assignedNo"
[ngClass]="{ 'is-invalid': submitted && form.assignedNo.errors }" />
<div class="text-danger" *ngIf="submitted && form.assignedNo.errors">
<p *ngIf="form.assignedNo.errors.required">Assigned No is required.</p>
<p *ngIf="form.assignedNo.errors.maxlength">Only 250 characters are allowed.</p>
<p *ngIf="form.assignedNo.errors.whiteSpaces">Please remove white space...</p>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light btn-sm mr-1" (click)="onCloseModal();">Cancel</button>
<button type="submit" [disabled]="submitting" class="btn btn-primary btn-sm">
<span *ngIf="submitting">
<span class="spinner-border spinner-border-sm mr-1" role="status" aria-hidden="true"></span>
Please wait..
</span>
<span *ngIf="!submitting">Submit</span>
</button>
</div>
</form>
</ng-template>
\ No newline at end of file
import { Component, ViewEncapsulation, OnInit, OnDestroy, TemplateRef } from "@angular/core";
import { Page, IUserAccount } from "../../../../../../shared/models";
import { Ambulance } from "../../../../../../shared/entities";
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { NgbModalRef, NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { AppData } from "../../../../../../app.data";
import { HttpService, NotifyService } from "../../../../../../shared/services";
import { ApiResources } from "../../../../../../shared/helpers";
import { takeUntil, finalize } from "rxjs/operators";
import { WhiteSpaceValidator } from "../../../../../../shared/validators";
@Component({
templateUrl: "./add-ambulance.html",
encapsulation: ViewEncapsulation.None
})
export class AddAmbulancePage implements OnInit, OnDestroy {
page: Page;
loading: boolean;
ambulancerecords: Array<Ambulance>;
submitting: boolean;
submitted: boolean;
ambulanceForm: FormGroup;
modalRef: NgbModalRef;
constructor(
private readonly formBuilder: FormBuilder,
private readonly modalService: NgbModal,
private readonly appData: AppData,
private readonly httpService: HttpService,
private readonly notifyService: NotifyService
) {
this.page = new Page();
this.loading = true;
}
onSubmit() {
this.submitted = true;
if (this.ambulanceForm.invalid) {
return;
}
this.submitting = true;
const request = {
...this.ambulanceForm.getRawValue(),
createdBy: this.page.userAccount.accountId,
loginRoleId: this.page.userAccount.roleId,
createdByName: this.page.userAccount.fullName
};
var url = ApiResources.getURI(ApiResources.ambulance.base, ApiResources.ambulance.insert);
if (request["ambulanceId"] > 0) {
url = ApiResources.getURI(ApiResources.ambulance.base, ApiResources.ambulance.update);
}
this.httpService.post(url, request)
.pipe(takeUntil(this.page.unSubscribe))
.pipe(finalize(() => this.submitted = this.submitting = false))
.subscribe(
(response: number) => {
if (response > 0) {
this.notifyService.successToast(`Record ${request["ambulanceId"] > 0 ? 'updated' : 'added'} successfully.`);
this.fetchAmbulance();
}
if (response === -1) {
this.notifyService.warningToast("This ambulance No already exists.");
return;
}
this.onCloseModal();
},
);
}
fetchAmbulance() {
this.loading = true;
const request = {
};
this.httpService.post(ApiResources.getURI(ApiResources.ambulance.base, ApiResources.ambulance.fetch), request)
.pipe(takeUntil(this.page.unSubscribe))
.pipe(finalize(() => this.loading = false))
.subscribe((responce: Array<Ambulance>) => {
this.ambulancerecords = responce;
});
}
//onDelete(record: Ambulance) {
// this.notifyService.delete(() => {
// const request = {
// ambulanceId: record.ambulanceId,
// ambulanceNo: record.ambulanceNo,
// createdBy: this.page.userAccount.accountId,
// loginRoleId: this.page.userAccount.roleId,
// createdByName: this.page.userAccount.fullName
// };
// this.httpService.post(ApiResources.getURI(ApiResources.ambulance.base, ApiResources.ambulance.delete), request)
// .pipe(takeUntil(this.page.unSubscribe))
// .pipe(finalize(() => this.loading = false))
// .subscribe(
// (response: number) => {
// if (response > 0) {
// this.notifyService.successToast("Record deleted successfully.");
// }
// if (response === -3) {
// this.notifyService.warningToast("The record you tried to delete can't be deleted because it is being used.");
// }
// this.fetchAmbulance();
// },
// //(error: HttpErrorResponse) => {
// // this.onError(error)
// //}
// );
// })
//}
updateStatus(ambulance: Ambulance) {
ambulance.modifiedBy = this.page.userAccount.accountId;
this.httpService
.put(ApiResources.getURI(ApiResources.ambulance.base, ApiResources.ambulance.modifyStatus), ambulance)
.subscribe(() => {
ambulance.active = !ambulance.active;
this.fetchAmbulance();
});
}
private buildForm() {
this.ambulanceForm = this.formBuilder.group({
ambulanceId: 0,
ambulanceNo: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
assignedNo: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
})
}
onOpenModel(content: TemplateRef<any>, ambulanceRecord?: Ambulance) {
this.buildForm();
if (ambulanceRecord)
this.ambulanceForm.patchValue({
ambulanceId: ambulanceRecord.ambulanceId,
ambulanceNo: ambulanceRecord.ambulanceNo,
assignedNo: ambulanceRecord.assignedNo,
});
this.modalRef = this.modalService.open(content, {
backdrop: "static",
keyboard: false,
centered: false,
windowClass: "custom-modal effect-scale"
});
}
get form() { return this.ambulanceForm.controls; }
ngOnInit() {
this.appData.userAccount
.pipe(takeUntil(this.page.unSubscribe))
.subscribe((userAccount: IUserAccount) => {
if (userAccount) {
this.page.userAccount = userAccount;
this.fetchAmbulance();
} else {
this.page.userAccount = undefined;
}
});
}
ngOnDestroy() {
this.page.unsubscribeAll();
}
onCloseModal() {
try {
this.modalRef.close();
this.modalRef = undefined;
} catch (e) {
// ignored;
}
this.loading = false;
this.submitting = undefined;
this.submitted = undefined;
}
}
\ No newline at end of file
import { Component, ViewEncapsulation, OnInit, OnDestroy, TemplateRef } from "@angular/core";
import { Page, IUserAccount } from "../../../../../../shared/models";
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { NgbModalRef, NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { AppData } from "../../../../../../app.data";
import { HttpService, NotifyService } from "../../../../../../shared/services";
import { takeUntil, finalize } from "rxjs/operators";
import { ApiResources } from "../../../../../../shared/helpers";
import { DriverDetails } from "../../../../../../shared/entities/ambulance/driver-details.entity";
import { WhiteSpaceValidator } from "../../../../../../shared/validators";
import { HttpErrorResponse } from "@angular/common/http";
@Component({
templateUrl: "./driverDetail.html",
encapsulation: ViewEncapsulation.None
})
export class DriverDetailPage implements OnInit, OnDestroy {
page: Page;
loading: boolean;
driverDetails: Array<DriverDetails>;
submitting: boolean;
submitted: boolean;
driverDetailForm: FormGroup;
modalRef: NgbModalRef;
constructor(
private readonly formBuilder: FormBuilder,
private readonly modalService: NgbModal,
private readonly appData: AppData,
private readonly httpService: HttpService,
private readonly notifyService: NotifyService
) {
this.page = new Page();
this.loading = true;
}
onSubmit() {
this.submitted = true;
if (this.driverDetailForm.invalid) {
return;
}
this.submitting = true;
const request = {
...this.driverDetailForm.getRawValue(),
createdBy: this.page.userAccount.accountId,
loginRoleId: this.page.userAccount.roleId,
createdByName: this.page.userAccount.fullName
};
var url = ApiResources.getURI(ApiResources.driverDetail.base, ApiResources.driverDetail.insert);
if (request["driverDetailId"] > 0) {
url = ApiResources.getURI(ApiResources.driverDetail.base, ApiResources.driverDetail.update);
}
this.httpService.post(url, request)
.pipe(takeUntil(this.page.unSubscribe))
.pipe(finalize(() => this.submitted = this.submitting = false))
.subscribe(
(response: number) => {
if (response > 0) {
this.notifyService.successToast(`Record ${request["driverDetailId"] > 0 ? 'updated' : 'added'} successfully.`);
this.fetchDriver();
}
if (response === -1) {
this.notifyService.warningToast("This driver name already exists.");
return;
}
this.onCloseModal();
},
);
}
fetchDriver() {
this.loading = true;
const request = {
};
this.httpService.post(ApiResources.getURI(ApiResources.driverDetail.base, ApiResources.driverDetail.fetch), request)
.pipe(takeUntil(this.page.unSubscribe))
.pipe(finalize(() => this.loading = false))
.subscribe((responce: Array<DriverDetails>) => {
this.driverDetails = responce;
});
}
//onDelete(record: DriverDetails) {
// this.notifyService.delete(() => {
// const request = {
// driverDetailId: record.driverDetailId,
// driverDetailName: record.driverDetailName,
// createdBy: this.page.userAccount.accountId,
// loginRoleId: this.page.userAccount.roleId,
// createdByName: this.page.userAccount.fullName
// };
// this.httpService.post(ApiResources.getURI(ApiResources.driverDetail.base, ApiResources.driverDetail.delete), request)
// .pipe(takeUntil(this.page.unSubscribe))
// .pipe(finalize(() => this.loading = false))
// .subscribe(
// (response: number) => {
// if (response > 0) {
// this.notifyService.successToast("Record deleted successfully.");
// }
// if (response === -3) {
// this.notifyService.warningToast("The record you tried to delete can't be deleted because it is being used.");
// }
// this.fetchDriver();
// },
// //(error: HttpErrorResponse) => {
// // this.onError(error)
// //}
// );
// })
//}
updateStatus(driverDetail: DriverDetails) {
driverDetail.modifiedBy = this.page.userAccount.accountId;
this.httpService
.put(ApiResources.getURI(ApiResources.driverDetail.base, ApiResources.driverDetail.modifyStatus), driverDetail)
.subscribe((response: number) => {
if (response > 0) {
this.notifyService.successToast(`${status ? 'Activated' : 'Deactivated'} successfully.`);
}
this.fetchDriver();
}, (error: HttpErrorResponse) => {
this.notifyService.errorToast(error.error);
});
}
private buildForm() {
this.driverDetailForm = this.formBuilder.group({
driverDetailId: 0,
driverDetailName: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid, Validators.pattern('^[a-zA-Z]*$')]],
mobileNo: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid, Validators.pattern('^[0-9]*$')]],
aadharNo: [null, [Validators.required, Validators.maxLength(12), WhiteSpaceValidator.isValid, Validators.pattern('^[0-9]*$')]],
address: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
fromTime: [null, [Validators.required]],
toTime: [null, [Validators.required]],
})
}
onOpenModel(content: TemplateRef<any>, driverDetail?: DriverDetails) {
this.buildForm();
if (driverDetail)
this.driverDetailForm.patchValue({
driverDetailId: driverDetail.driverDetailId,
driverDetailName: driverDetail.driverDetailName,
mobileNo: driverDetail.mobileNo,
aadharNo: driverDetail.aadharNo,
address: driverDetail.address,
fromTime: driverDetail.fromTime,
toTime: driverDetail.toTime
});
this.modalRef = this.modalService.open(content, {
backdrop: "static",
keyboard: false,
centered: false,
windowClass: "custom-modal effect-scale"
});
}
get form() { return this.driverDetailForm.controls; }
ngOnInit() {
this.appData.userAccount
.pipe(takeUntil(this.page.unSubscribe))
.subscribe((userAccount: IUserAccount) => {
if (userAccount) {
this.page.userAccount = userAccount;
this.fetchDriver();
} else {
this.page.userAccount = undefined;
}
});
}
ngOnDestroy() {
this.page.unsubscribeAll();
}
onCloseModal() {
try {
this.modalRef.close();
this.modalRef = undefined;
} catch (e) {
// ignored;
}
this.loading = false;
this.submitting = undefined;
this.submitted = undefined;
}
}
\ No newline at end of file
<router-outlet></router-outlet>
\ No newline at end of file
import { Component, ViewEncapsulation } from "@angular/core";
@Component({
templateUrl: "./masters.html",
encapsulation: ViewEncapsulation.None
})
export class AmbulanceMasterPage {
}
\ No newline at end of file
import { Component, ViewEncapsulation, TemplateRef } from "@angular/core";
import { Page, IUserAccount, IResource } from "../../../../../shared/models";
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { NgbModalRef, NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { AppData } from "../../../../../app.data";
import { HttpService, NotifyService, ResourceService } from "../../../../../shared/services";
import { ApiResources } from "../../../../../shared/helpers";
import { takeUntil, finalize } from "rxjs/operators";
import { WhiteSpaceValidator, MobileValidator } from "../../../../../shared/validators";
import { AmbulanceReceipt } from "../../../../../shared/entities/ambulance/ambulance-receipt.entity";
@Component({
templateUrl: "./receipt.html",
encapsulation: ViewEncapsulation.None
})
export class AmbulanceReceiptPage {
page: Page;
loadingambulancereceipts: boolean;
ambulancereceipts: Array<AmbulanceReceipt>;
ambulancerecords: Array<IResource>;
driverDetail: Array<IResource>;
submitting: boolean;
submitted: boolean;
ambulanceReceiptForm: FormGroup;
modalRef: NgbModalRef;
loadingAmbulances: boolean;
loadingDrivers: boolean;
constructor(
private readonly formBuilder: FormBuilder,
private readonly modalService: NgbModal,
private readonly appData: AppData,
private readonly httpService: HttpService,
private readonly notifyService: NotifyService,
private readonly resourceService: ResourceService
) {
this.page = new Page();
this.loadingambulancereceipts = true;
}
onSubmit() {
this.submitted = true;
if (this.ambulanceReceiptForm.invalid) {
return;
}
this.submitting = true;
const request = {
...this.ambulanceReceiptForm.getRawValue(),
createdBy: this.page.userAccount.accountId,
loginRoleId: this.page.userAccount.roleId,
createdByName: this.page.userAccount.fullName
};
var url = ApiResources.getURI(ApiResources.ambulanceReceipt.base, ApiResources.ambulanceReceipt.insert);
if (request["ambulanceRecieptId"] > 0) {
url = ApiResources.getURI(ApiResources.ambulanceReceipt.base, ApiResources.ambulanceReceipt.update);
}
this.httpService.post(url, request)
.pipe(takeUntil(this.page.unSubscribe))
.pipe(finalize(() => this.submitted = this.submitting = false))
.subscribe(
(response: number) => {
if (response > 0) {
this.notifyService.successToast(`Record ${request["ambulanceRecieptId"] ==0 ? 'added' : 'updated' } successfully.`);
this.fetchReceipt();
}
if (response === -1) {
this.notifyService.warningToast("This ambulance No already exists.");
return;
}
this.onCloseModal();
},
);
}
fetchReceipt() {
this.loadingambulancereceipts = true;
const request = {
};
this.httpService.post(ApiResources.getURI(ApiResources.ambulanceReceipt.base, ApiResources.ambulanceReceipt.fetch), request)
.pipe(takeUntil(this.page.unSubscribe))
.pipe(finalize(() => this.loadingambulancereceipts = false))
.subscribe((responce: Array<AmbulanceReceipt>) => {
this.ambulancereceipts = responce;
});
}
private fetchAmbulances() {
this.loadingAmbulances = true;
this.resourceService.ambulances()
.pipe(finalize(() => { this.loadingAmbulances = false }))
.pipe(takeUntil(this.page.unSubscribe))
.subscribe((response: Array<IResource>) => {
this.ambulancerecords = response;
});
}
private fetchDriverDetail() {
this.loadingDrivers = true;
this.resourceService.driversDetails()
.pipe(finalize(() => { this.loadingDrivers = false }))
.pipe(takeUntil(this.page.unSubscribe))
.subscribe((response: Array<IResource>) => {
this.driverDetail = response;
});
}
private buildForm() {
this.ambulanceReceiptForm = this.formBuilder.group({
ambulanceRecieptId: 0,
recieptNo:[null],
ambulanceId: [null, [Validators.required]],
driverDetailId: [null, [Validators.required]],
patientName: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
address: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
patientMobile: [null, [Validators.required, MobileValidator.isValid, WhiteSpaceValidator.isValid]],
amount: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
fromLocation: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
toLocation: [null, [Validators.required, Validators.maxLength(250), WhiteSpaceValidator.isValid]],
})
}
onOpenModel(content: TemplateRef<any>, ambulanceReceipt?: AmbulanceReceipt) {
this.buildForm();
if (ambulanceReceipt) {
this.ambulanceReceiptForm.patchValue({
ambulanceRecieptId: ambulanceReceipt.ambulanceRecieptId,
recieptNo: ambulanceReceipt.recieptNo,
ambulanceId: ambulanceReceipt.ambulanceId,
driverDetailId: ambulanceReceipt.driverDetailId,
patientName: ambulanceReceipt.patientName,
address: ambulanceReceipt.address,
patientMobile: ambulanceReceipt.patientMobile,
amount: ambulanceReceipt.amount,
fromLocation: ambulanceReceipt.fromLocation,
toLocation: ambulanceReceipt.toLocation
});
}
this.modalRef = this.modalService.open(content, {
backdrop: "static",
keyboard: false,
centered: false,
windowClass: "custom-modal effect-scale"
});
}
get form() { return this.ambulanceReceiptForm.controls; }
ngOnInit() {
this.appData.userAccount
.pipe(takeUntil(this.page.unSubscribe))
.subscribe((userAccount: IUserAccount) => {
if (userAccount) {
this.page.userAccount = userAccount;
this.fetchReceipt();
this.fetchAmbulances();
this.fetchDriverDetail();
} else {
this.page.userAccount = undefined;
}
});
}
ngOnDestroy() {
this.page.unsubscribeAll()
}
onCloseModal() {
try {
this.modalRef.close();
this.modalRef = undefined;
} catch (e) {
// ignored;
}
this.loadingambulancereceipts = false;
this.submitting = undefined;
this.submitted = undefined;
}
}
\ No newline at end of file
......@@ -4,12 +4,14 @@ import { CubiclePage } from './pages/cubicle/cubicle.page';
import { SharedModule } from '@src/app/shared/shared.module';
import { MastersRoutingModule } from './masters.routing.module';
import { AppointmentTypePage } from './pages/appointment-types/appointment-types.page';
import { RolePage } from './pages/roles/roles.page';
@NgModule({
declarations: [
MastersPage,
CubiclePage,
AppointmentTypePage
AppointmentTypePage,
RolePage
],
imports: [
MastersRoutingModule,
......
......@@ -4,6 +4,7 @@ import { CubiclePage } from './pages/cubicle/cubicle.page';
import { MastersPage } from './masters.page';
import { AuthGuard } from '@src/app/shared/guards';
import { AppointmentTypePage } from './pages/appointment-types/appointment-types.page';
import { RolePage } from './pages/roles/roles.page';
const routes: Routes = [
{
......@@ -16,6 +17,7 @@ const routes: Routes = [
{ path: "", redirectTo: "cubicle", pathMatch: "full" },
{ path: "cubicle", component: CubiclePage, data: { title: "cubicle" } },
{ path: "appointment-types", component: AppointmentTypePage, data: { title: "Appointment Types" } },
{ path: "role", component: RolePage, data: { title: "Roles" } },
{ path: "**", redirectTo: "cubicle" },
]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment