Fix: Bill Type was not being shown properly

This commit is contained in:
2020-11-22 23:20:43 +05:30
parent e8ae39cd7a
commit f7b4b29d3a
2 changed files with 14 additions and 32 deletions

View File

@ -3,8 +3,8 @@
fxLayout="column" fxLayout="column"
class="square-button" class="square-button"
matRipple matRipple
(click)="selectRegularBill()" (click)="select('REGULAR_BILL')"
[class.selected]="selectRegularBill()" [class.selected]="selected === 'REGULAR_BILL'"
> >
<h3 class="item-name">Regular</h3> <h3 class="item-name">Regular</h3>
</mat-card> </mat-card>
@ -12,8 +12,8 @@
fxLayout="column" fxLayout="column"
class="square-button" class="square-button"
matRipple matRipple
(click)="selectStaff()" (click)="select('STAFF')"
[class.selected]="selectedStaff()" [class.selected]="selected === 'STAFF'"
> >
<h3 class="item-name">Staff</h3> <h3 class="item-name">Staff</h3>
</mat-card> </mat-card>
@ -21,8 +21,8 @@
fxLayout="column" fxLayout="column"
class="square-button" class="square-button"
matRipple matRipple
(click)="selectNoCharge()" (click)="select('NO_CHARGE')"
[class.selected]="selectedNoCharge()" [class.selected]="selected === 'NO_CHARGE'"
> >
<h3 class="item-name">No Charge</h3> <h3 class="item-name">No Charge</h3>
</mat-card> </mat-card>

View File

@ -9,38 +9,20 @@ import { VoucherType } from '../bills/voucher-type';
styleUrls: ['./bill-type.component.css'], styleUrls: ['./bill-type.component.css'],
}) })
export class BillTypeComponent { export class BillTypeComponent {
selected: VoucherType | null; selected: string;
constructor(public dialogRef: MatDialogRef<BillTypeComponent>) { constructor(public dialogRef: MatDialogRef<BillTypeComponent>) {
this.selected = null; this.selected = '';
} }
selectRegularBill() { select(voucherType: string) {
this.selected = VoucherType.Bill; this.selected = voucherType;
}
selectedRegularBill() {
return this.selected === VoucherType.Bill;
}
selectStaff() {
this.selected = VoucherType.Staff;
}
selectedStaff() {
return this.selected === VoucherType.Staff;
}
selectNoCharge() {
this.selected = VoucherType.NoCharge;
}
selectedNoCharge() {
return this.selected === VoucherType.NoCharge;
} }
accept(): void { accept(): void {
if (this.selected === null) this.dialogRef.close(); if (this.selected === 'REGULAR_BILL') this.dialogRef.close(VoucherType.Bill)
else this.dialogRef.close(this.selected); else if (this.selected === 'STAFF') this.dialogRef.close(VoucherType.Staff)
else if (this.selected === 'NO_CHARGE') this.dialogRef.close(VoucherType.NoCharge)
else this.dialogRef.close();
} }
} }