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:
+20
-15
@@ -32,7 +32,7 @@ import { Account } from '../../core/account';
|
||||
import { AccountService } from '../../core/account.service';
|
||||
import { Product } from '../../core/product';
|
||||
import { ProductSku } from '../../core/product-sku';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ProductService } from '../../product/product.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MathService } from '../../shared/math.service';
|
||||
@@ -41,6 +41,7 @@ import { RateContractItem } from '../rate-contract-item';
|
||||
import { RateContractService } from '../rate-contract.service';
|
||||
|
||||
import { RateContractDetailDatasource } from './rate-contract-detail-datasource';
|
||||
import { HostListener } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-rate-contract-detail',
|
||||
@@ -83,8 +84,9 @@ import { RateContractDetailDatasource } from './rate-contract-detail-datasource'
|
||||
],
|
||||
})
|
||||
export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('accountElement', { static: true }) accountElement?: ElementRef;
|
||||
@ViewChild('productElement', { static: true }) productElement?: ElementRef;
|
||||
@ViewChild('accountElement', { static: true }) accountElement!: ElementRef<HTMLInputElement>;
|
||||
@ViewChild('productElement', { static: true }) productElement!: ElementRef<HTMLInputElement>;
|
||||
@ViewChild('dateElement', { static: true }) dateElement!: ElementRef<HTMLInputElement>;
|
||||
public itemsObservable = new BehaviorSubject<RateContractItem[]>([]);
|
||||
dataSource: RateContractDetailDatasource = new RateContractDetailDatasource(this.itemsObservable);
|
||||
form: FormGroup<{
|
||||
@@ -109,10 +111,17 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
accounts: Observable<Account[]>;
|
||||
products: Observable<ProductSku[]>;
|
||||
|
||||
@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 toaster: ToasterService,
|
||||
private snackBar: MatSnackBar,
|
||||
private dialog: MatDialog,
|
||||
private math: MathService,
|
||||
private ser: RateContractService,
|
||||
@@ -169,9 +178,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
if (this.accountElement) {
|
||||
this.accountElement.nativeElement.focus();
|
||||
}
|
||||
this.accountElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@@ -186,7 +193,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
const oldFiltered = this.item.items.filter((x) => x.sku.id === (this.product as Product).id);
|
||||
if (oldFiltered.length) {
|
||||
this.toaster.show('Danger', 'Product already added');
|
||||
this.snackBar.open('Product already added', 'Danger');
|
||||
return;
|
||||
}
|
||||
this.item.items.push(
|
||||
@@ -203,9 +210,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form.controls.addRow.reset();
|
||||
this.product = null;
|
||||
setTimeout(() => {
|
||||
if (this.productElement) {
|
||||
this.productElement.nativeElement.focus();
|
||||
}
|
||||
this.productElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@@ -233,11 +238,11 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe({
|
||||
next: () => {
|
||||
this.toaster.show('Success', '');
|
||||
this.snackBar.open('', 'Success');
|
||||
this.router.navigateByUrl('/rate-contracts');
|
||||
},
|
||||
error: (error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
this.snackBar.open(error, 'Danger');
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -245,11 +250,11 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
delete() {
|
||||
this.ser.delete(this.item.id as string).subscribe({
|
||||
next: () => {
|
||||
this.toaster.show('Success', '');
|
||||
this.snackBar.open('', 'Success');
|
||||
this.router.navigateByUrl('/rate-contracts');
|
||||
},
|
||||
error: (error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
this.snackBar.open(error, 'Danger');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user