feat: add create cashier component (#1064)

Fixes: #161
This commit is contained in:
Karan Takalkar
2020-07-12 14:23:33 +05:30
committed by GitHub
parent 3a78659d4b
commit b2afabc8d0
31 changed files with 316 additions and 59 deletions
@@ -0,0 +1,75 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<button mat-raised-button color="primary" [routerLink]="['edit']">
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;
Edit
</button>
<button mat-raised-button color="warn" (click)="deleteCashier()">
<fa-icon icon="trash"></fa-icon>&nbsp;&nbsp;
Delete
</button>
</div>
<div class="container">
<mat-card>
<mat-card-content>
<div fxLayout="row wrap" class="content">
<div fxFlex="50%" class="header">
Name
</div>
<div fxFlex="50%">
{{ cashierData.staffName}}
</div>
<div fxFlex="50%" class="header">
Teller
</div>
<div fxFlex="50%">
{{ cashierData.tellerName }}
</div>
<div fxFlex="50%" class="header" *ngIf="cashierData.description !== ''">
Description
</div>
<div fxFlex="50%" *ngIf="cashierData.description !== ''">
{{ cashierData.description }}
</div>
<div fxFlex="50%" class="header">
Start Date
</div>
<div fxFlex="50%">
{{ cashierData.startDate | date }}
</div>
<div fxFlex="50%" class="header">
End Date
</div>
<div fxFlex="50%">
{{ cashierData.endDate | date }}
</div>
<div fxFlex="50%" class="header">
Full Day?
</div>
<div fxFlex="50%">
{{ cashierData.isFullDay }}
</div>
</div>
</mat-card-content>
</mat-card>
</div>
@@ -0,0 +1,14 @@
.container {
max-width: 37rem;
.content {
div {
margin: 1rem 0;
word-wrap: break-word;
&.header {
font-weight: 500;
}
}
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewCashierComponent } from './view-cashier.component';
describe('ViewCashierComponent', () => {
let component: ViewCashierComponent;
let fixture: ComponentFixture<ViewCashierComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewCashierComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewCashierComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,57 @@
/** Angular Imports. */
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Dialogs */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { MatDialog } from '@angular/material';
/** Custom Services */
import { OrganizationService } from 'app/organization/organization.service';
/**
* View Cashier component.
*/
@Component({
selector: 'mifosx-view-cashier',
templateUrl: './view-cashier.component.html',
styleUrls: ['./view-cashier.component.scss']
})
export class ViewCashierComponent {
/** Cashier data. */
cashierData: any;
/**
* Get cashier data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router
* @param {OrganizationService} organizationService Organization Service
* @param {MatDialog} dialog Mat Dialog
*/
constructor(private route: ActivatedRoute,
private router: Router,
private organizationService: OrganizationService,
public dialog: MatDialog) {
this.route.data.subscribe((data: { cashier: any }) => {
this.cashierData = data.cashier;
});
}
/**
* Deletes the cashier.
*/
deleteCashier() {
const deleteCashierDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `Cashier id: ${this.cashierData.id}` }
});
deleteCashierDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.organizationService.deleteCashier(this.cashierData.tellerId, this.cashierData.id).subscribe(() => {
this.router.navigate(['../'], {relativeTo: this.route});
});
}
});
}
}