Chore: Upgrade to Angular v14
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { Observable } from 'rxjs';
|
||||
@ -17,13 +17,13 @@ import { MathService } from '../shared/math.service';
|
||||
})
|
||||
export class IssueDialogComponent implements OnInit {
|
||||
batches: Observable<Batch[]>;
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
batch: Batch = new Batch();
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<IssueDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: { inventory: Inventory; date: string },
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private math: MathService,
|
||||
private batchSer: BatchService,
|
||||
) {
|
||||
@ -32,7 +32,7 @@ export class IssueDialogComponent implements OnInit {
|
||||
quantity: '',
|
||||
});
|
||||
// Listen to Batch Autocomplete Change
|
||||
this.batches = (this.form.get('batch') as FormControl).valueChanges.pipe(
|
||||
this.batches = (this.form.get('batch') as UntypedFormControl).valueChanges.pipe(
|
||||
startWith(''),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@ -39,7 +39,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
public gridObservable = new BehaviorSubject<IssueGridItem[]>([]);
|
||||
dataSource: IssueDataSource = new IssueDataSource(this.inventoryObservable);
|
||||
gridDataSource: IssueGridDataSource = new IssueGridDataSource(this.gridObservable);
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
voucher: Voucher = new Voucher();
|
||||
costCentres: CostCentre[] = [];
|
||||
batch: Batch | null = null;
|
||||
@ -52,7 +52,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private dialog: MatDialog,
|
||||
private hotkeys: HotkeysService,
|
||||
private toaster: ToasterService,
|
||||
@ -75,7 +75,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
// Listen to Batch Autocomplete Change
|
||||
this.batches = (
|
||||
(this.form.get('addRow') as FormControl).get('batch') as FormControl
|
||||
(this.form.get('addRow') as UntypedFormControl).get('batch') as UntypedFormControl
|
||||
).valueChanges.pipe(
|
||||
startWith('null'),
|
||||
debounceTime(150),
|
||||
@ -85,7 +85,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
),
|
||||
);
|
||||
// Listen to Date Change
|
||||
(this.form.get('date') as FormControl).valueChanges
|
||||
(this.form.get('date') as UntypedFormControl).valueChanges
|
||||
.pipe(map((x) => moment(x).format('DD-MMM-YYYY')))
|
||||
.subscribe((x) => this.showGrid(x));
|
||||
}
|
||||
@ -160,7 +160,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
addRow() {
|
||||
const formValue = (this.form.get('addRow') as FormControl).value;
|
||||
const formValue = (this.form.get('addRow') as UntypedFormControl).value;
|
||||
const quantity = this.math.parseAmount(formValue.quantity, 2);
|
||||
const isConsumption = this.form.value.source === '7b845f95-dfef-fa4a-897c-f0baf15284a3';
|
||||
if (this.batch === null || quantity <= 0) {
|
||||
@ -194,7 +194,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
resetAddRow() {
|
||||
(this.form.get('addRow') as FormControl).reset({
|
||||
(this.form.get('addRow') as UntypedFormControl).reset({
|
||||
batch: null,
|
||||
quantity: '',
|
||||
});
|
||||
@ -212,7 +212,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0)),
|
||||
2,
|
||||
);
|
||||
(this.form.get('amount') as FormControl).setValue(amount);
|
||||
(this.form.get('amount') as UntypedFormControl).setValue(amount);
|
||||
}
|
||||
|
||||
editRow(row: Inventory) {
|
||||
|
||||
Reference in New Issue
Block a user