Fix: Bill Type was not being shown properly

This commit is contained in:
Amritanshu Agrawal 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"
class="square-button"
matRipple
(click)="selectRegularBill()"
[class.selected]="selectRegularBill()"
(click)="select('REGULAR_BILL')"
[class.selected]="selected === 'REGULAR_BILL'"
>
<h3 class="item-name">Regular</h3>
</mat-card>
@ -12,8 +12,8 @@
fxLayout="column"
class="square-button"
matRipple
(click)="selectStaff()"
[class.selected]="selectedStaff()"
(click)="select('STAFF')"
[class.selected]="selected === 'STAFF'"
>
<h3 class="item-name">Staff</h3>
</mat-card>
@ -21,8 +21,8 @@
fxLayout="column"
class="square-button"
matRipple
(click)="selectNoCharge()"
[class.selected]="selectedNoCharge()"
(click)="select('NO_CHARGE')"
[class.selected]="selected === 'NO_CHARGE'"
>
<h3 class="item-name">No Charge</h3>
</mat-card>

View File

@ -9,38 +9,20 @@ import { VoucherType } from '../bills/voucher-type';
styleUrls: ['./bill-type.component.css'],
})
export class BillTypeComponent {
selected: VoucherType | null;
selected: string;
constructor(public dialogRef: MatDialogRef<BillTypeComponent>) {
this.selected = null;
this.selected = '';
}
selectRegularBill() {
this.selected = VoucherType.Bill;
}
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;
select(voucherType: string) {
this.selected = voucherType;
}
accept(): void {
if (this.selected === null) this.dialogRef.close();
else this.dialogRef.close(this.selected);
if (this.selected === 'REGULAR_BILL') this.dialogRef.close(VoucherType.Bill)
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();
}
}