Moved from tslint to eslint as tslint was depreciated.
Added prettier and also prettied all the typescript files using prettier ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import {Component, Inject, OnInit} from '@angular/core';
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {Observable, of as observableOf} from 'rxjs';
|
||||
import {Product} from '../core/product';
|
||||
import {ProductService} from '../product/product.service';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { Product } from '../core/product';
|
||||
import { ProductService } from '../product/product.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-purchase-dialog',
|
||||
templateUrl: './purchase-dialog.component.html',
|
||||
styleUrls: ['./purchase-dialog.component.css']
|
||||
styleUrls: ['./purchase-dialog.component.css'],
|
||||
})
|
||||
export class PurchaseDialogComponent implements OnInit {
|
||||
products: Observable<Product[]>;
|
||||
@@ -21,7 +21,8 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
public dialogRef: MatDialogRef<PurchaseDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private fb: FormBuilder,
|
||||
private productSer: ProductService) {
|
||||
private productSer: ProductService,
|
||||
) {
|
||||
this.createForm();
|
||||
this.listenToProductAutocompleteChange();
|
||||
}
|
||||
@@ -32,7 +33,7 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
quantity: this.data.inventory.quantity,
|
||||
price: this.data.inventory.rate,
|
||||
tax: this.data.inventory.tax,
|
||||
discount: this.data.inventory.discount
|
||||
discount: this.data.inventory.discount,
|
||||
});
|
||||
this.product = this.data.inventory.product;
|
||||
}
|
||||
@@ -43,20 +44,19 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
quantity: '',
|
||||
price: '',
|
||||
tax: '',
|
||||
discount: ''
|
||||
discount: '',
|
||||
});
|
||||
}
|
||||
|
||||
listenToProductAutocompleteChange(): void {
|
||||
const control = this.form.get('product');
|
||||
this.products = control.valueChanges
|
||||
.pipe(
|
||||
startWith(null),
|
||||
map(x => (x !== null && x.length >= 1) ? x : null),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap(x => (x === null) ? observableOf([]) : this.productSer.autocomplete(x))
|
||||
);
|
||||
this.products = control.valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.productSer.autocomplete(x))),
|
||||
);
|
||||
}
|
||||
|
||||
displayProductName(product?: Product): string | undefined {
|
||||
@@ -70,10 +70,10 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
|
||||
accept(): void {
|
||||
const formValue = this.form.value;
|
||||
const quantity = +(formValue.quantity);
|
||||
const price = +(formValue.price);
|
||||
const tax = +(formValue.tax);
|
||||
const discount = +(formValue.discount);
|
||||
const quantity = +formValue.quantity;
|
||||
const price = +formValue.price;
|
||||
const tax = +formValue.tax;
|
||||
const discount = +formValue.discount;
|
||||
this.data.inventory.product = this.product;
|
||||
this.data.inventory.quantity = quantity;
|
||||
this.data.inventory.rate = price;
|
||||
|
||||
Reference in New Issue
Block a user