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:
@@ -27,7 +27,7 @@ import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import { Product, StockKeepingUnit } from '../../core/product';
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { ProductService } from '../product.service';
|
||||
|
||||
@@ -69,7 +69,7 @@ import { ProductDetailDialogComponent } from './product-detail-dialog.component'
|
||||
],
|
||||
})
|
||||
export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
@ViewChild('nameElement', { static: true }) nameElement!: ElementRef<HTMLInputElement>;
|
||||
form: FormGroup<{
|
||||
code: FormControl<string | number>;
|
||||
name: FormControl<string | null>;
|
||||
@@ -115,7 +115,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private snackBar: MatSnackBar,
|
||||
private ser: ProductService,
|
||||
) {
|
||||
this.form = new FormGroup({
|
||||
@@ -182,7 +182,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
isPurchased: this.item.isPurchased,
|
||||
isSold: this.item.isSold,
|
||||
isActive: this.item.isActive,
|
||||
productGroup: this.item.productGroup ? this.item.productGroup.id ?? '' : '',
|
||||
productGroup: this.item.productGroup ? (this.item.productGroup.id ?? '') : '',
|
||||
|
||||
allergen: this.item.allergen ?? '',
|
||||
protein: this.item.protein,
|
||||
@@ -204,9 +204,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
if (this.nameElement) {
|
||||
this.nameElement.nativeElement.focus();
|
||||
}
|
||||
this.nameElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@@ -221,22 +219,22 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
const fraction = Number(formValue.fraction);
|
||||
if (fraction < 1) {
|
||||
this.toaster.show('Danger', 'Fraction has to be >= 1');
|
||||
this.snackBar.open('Fraction has to be >= 1', 'Danger');
|
||||
return;
|
||||
}
|
||||
const productYield = Number(formValue.productYield);
|
||||
if (productYield < 0 || productYield > 1) {
|
||||
this.toaster.show('Danger', 'Product Yield has to be > 0 and <= 1');
|
||||
this.snackBar.open('Product Yield has to be > 0 and <= 1', 'Danger');
|
||||
return;
|
||||
}
|
||||
const costPrice = Number(formValue.costPrice);
|
||||
if (costPrice < 0) {
|
||||
this.toaster.show('Danger', 'Price has to be >= 0');
|
||||
this.snackBar.open('Price has to be >= 0', 'Danger');
|
||||
return;
|
||||
}
|
||||
const salePrice = Number(formValue.salePrice);
|
||||
if (salePrice < 0) {
|
||||
this.toaster.show('Danger', 'Sale Price has to be >= 0');
|
||||
this.snackBar.open('Sale Price has to be >= 0', 'Danger');
|
||||
return;
|
||||
}
|
||||
this.item.skus.push(
|
||||
@@ -285,11 +283,11 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe({
|
||||
next: () => {
|
||||
this.toaster.show('Success', '');
|
||||
this.snackBar.open('', 'Success');
|
||||
this.router.navigateByUrl('/products');
|
||||
},
|
||||
error: (error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
this.snackBar.open(error, 'Danger');
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -297,11 +295,11 @@ export class ProductDetailComponent 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('/products');
|
||||
},
|
||||
error: (error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
this.snackBar.open(error, 'Danger');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ import { ProductListDataSource } from './product-list-datasource';
|
||||
],
|
||||
})
|
||||
export class ProductListComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('filterElement', { static: true }) filterElement?: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
|
||||
@ViewChild(MatSort, { static: true }) sort?: MatSort;
|
||||
@ViewChild('filterElement', { static: true }) filterElement!: ElementRef<HTMLInputElement>;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator!: MatPaginator;
|
||||
@ViewChild(MatSort, { static: true }) sort!: MatSort;
|
||||
list: Product[] = [];
|
||||
filter: Observable<string>;
|
||||
dataSource: ProductListDataSource;
|
||||
@@ -90,7 +90,7 @@ export class ProductListComponent implements OnInit, AfterViewInit {
|
||||
filter: new FormControl<string>('', { nonNullable: true }),
|
||||
});
|
||||
this.filter = this.form.controls.filter.valueChanges.pipe(debounceTime(150), distinctUntilChanged());
|
||||
this.dataSource = new ProductListDataSource(this.list, this.filter);
|
||||
this.dataSource = new ProductListDataSource(this.list, this.filter, this.paginator, this.sort);
|
||||
}
|
||||
|
||||
get showExtended(): boolean {
|
||||
@@ -117,9 +117,7 @@ export class ProductListComponent implements OnInit, AfterViewInit {
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
if (this.filterElement) {
|
||||
this.filterElement.nativeElement.focus();
|
||||
}
|
||||
this.filterElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user