Chore: Eslint v9

Chore: Angular Zoneless
Chore: Removed Angular-Hotkeys dependency
Fix: Localization works properly now
Chore: Using Material 3 theme now
Chore: Removed toaster service to use snackbar directly
Fix: F2 Date working on all components now
This commit is contained in:
2024-07-25 10:16:48 +05:30
parent c07c79ffda
commit 336a8f59c5
94 changed files with 846 additions and 1030 deletions
@@ -7,7 +7,14 @@
<div class="flex flex-row justify-around content-start items-start">
<mat-form-field class="flex-auto">
<mat-label>Date</mat-label>
<input matInput [matDatepicker]="date" (focus)="date.open()" formControlName="date" autocomplete="off" />
<input
matInput
#dateElement
[matDatepicker]="date"
(focus)="dateElement.select()"
formControlName="date"
autocomplete="off"
/>
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date></mat-datepicker>
</mat-form-field>
@@ -36,7 +36,7 @@ import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { Incentive } from '../core/incentive';
import { ToasterService } from '../core/toaster.service';
import { MatSnackBar } from '@angular/material/snack-bar';
import { User } from '../core/user';
import { Voucher } from '../core/voucher';
import { VoucherService } from '../core/voucher.service';
@@ -44,6 +44,9 @@ import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.
import { LocalTimePipe } from '../shared/local-time.pipe';
import { IncentiveDataSource } from './incentive-datasource';
import { ViewChild } from '@angular/core';
import { ElementRef } from '@angular/core';
import { HostListener } from '@angular/core';
@Component({
selector: 'app-incentive',
@@ -85,6 +88,7 @@ import { IncentiveDataSource } from './incentive-datasource';
],
})
export class IncentiveComponent implements OnInit {
@ViewChild('dateElement', { static: true }) dateElement!: ElementRef<HTMLInputElement>;
public incentiveObservable = new BehaviorSubject<Incentive[]>([]);
dataSource: IncentiveDataSource = new IncentiveDataSource(this.incentiveObservable);
form: FormGroup<{
@@ -102,11 +106,18 @@ export class IncentiveComponent implements OnInit {
displayedColumns = ['name', 'designation', 'department', 'daysWorked', 'points', 'amount'];
@HostListener('window:keydown.f2', ['$event'])
focusDate(event: KeyboardEvent) {
event.preventDefault();
this.dateElement.nativeElement.focus();
this.dateElement.nativeElement.select();
}
constructor(
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private toaster: ToasterService,
private snackBar: MatSnackBar,
public auth: AuthService,
private ser: VoucherService,
) {
@@ -193,10 +204,10 @@ export class IncentiveComponent implements OnInit {
this.ser.post(this.voucher.id as string).subscribe({
next: (result) => {
this.loadVoucher(result);
this.toaster.show('Success', 'Voucher Posted');
this.snackBar.open('Voucher Posted', 'Success');
},
error: (error) => {
this.toaster.show('Danger', error);
this.snackBar.open(error, 'Danger');
},
});
}
@@ -212,7 +223,7 @@ export class IncentiveComponent implements OnInit {
}
},
error: (error) => {
this.toaster.show('Danger', error);
this.snackBar.open(error, 'Danger');
},
});
}
@@ -231,11 +242,11 @@ export class IncentiveComponent implements OnInit {
delete() {
this.ser.delete(this.voucher.id as string).subscribe({
next: () => {
this.toaster.show('Success', '');
this.snackBar.open('', 'Success');
this.router.navigate(['/incentive'], { replaceUrl: true });
},
error: (error) => {
this.toaster.show('Danger', error);
this.snackBar.open(error, 'Danger');
},
});
}