Chore:
Upgraded to Angular 14
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
@ -8,9 +8,9 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
styleUrls: ['./bill-number.component.css'],
|
||||
})
|
||||
export class BillNumberComponent implements OnInit {
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<BillNumberComponent>, private fb: FormBuilder) {
|
||||
constructor(public dialogRef: MatDialogRef<BillNumberComponent>, private fb: UntypedFormBuilder) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
billType: '',
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import {
|
||||
UntypedFormArray,
|
||||
UntypedFormBuilder,
|
||||
UntypedFormControl,
|
||||
UntypedFormGroup,
|
||||
} from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { round } from 'mathjs';
|
||||
@ -15,14 +20,14 @@ import { CustomerService } from '../../customers/customer.service';
|
||||
styleUrls: ['./choose-customer.component.css'],
|
||||
})
|
||||
export class ChooseCustomerComponent {
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
item: Customer = new Customer();
|
||||
customers: Observable<Customer[]>;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ChooseCustomerComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: string | undefined,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private ser: CustomerService,
|
||||
) {
|
||||
// Create form
|
||||
@ -34,7 +39,7 @@ export class ChooseCustomerComponent {
|
||||
discounts: this.fb.array([]),
|
||||
});
|
||||
// Setup Account Autocomplete
|
||||
this.customers = (this.form.get('phone') as FormControl).valueChanges.pipe(
|
||||
this.customers = (this.form.get('phone') as UntypedFormControl).valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x === this.item.phone ? '' : x)),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
@ -93,7 +98,7 @@ export class ChooseCustomerComponent {
|
||||
this.item.phone = formModel.phone;
|
||||
this.item.address = formModel.address;
|
||||
this.item.printInBill = formModel.printInBill;
|
||||
const array = this.form.get('discounts') as FormArray;
|
||||
const array = this.form.get('discounts') as UntypedFormArray;
|
||||
this.item.discounts.forEach((item, index) => {
|
||||
item.discount = Math.max(
|
||||
Math.min(round(array.controls[index].value.discount / 100, 5), 100),
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import {
|
||||
UntypedFormArray,
|
||||
UntypedFormBuilder,
|
||||
UntypedFormControl,
|
||||
UntypedFormGroup,
|
||||
Validators,
|
||||
} from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { round } from 'mathjs';
|
||||
import { Observable } from 'rxjs';
|
||||
@ -14,14 +20,14 @@ import { DiscountItem } from './discount-item';
|
||||
})
|
||||
export class DiscountComponent {
|
||||
list: DiscountItem[] = [];
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
dataSource: DiscountDataSource = new DiscountDataSource([]);
|
||||
|
||||
displayedColumns = ['name', 'discount'];
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<DiscountComponent>,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
@Inject(MAT_DIALOG_DATA)
|
||||
public data: Observable<DiscountItem[]>,
|
||||
) {
|
||||
@ -49,10 +55,11 @@ export class DiscountComponent {
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
const array = this.form.get('discounts') as FormArray;
|
||||
const array = this.form.get('discounts') as UntypedFormArray;
|
||||
for (let i = this.list.length - 1; i >= 0; i--) {
|
||||
const item = this.list[i];
|
||||
const control = (array.controls[i] as FormGroup).controls.discount as FormControl;
|
||||
const control = (array.controls[i] as UntypedFormGroup).controls
|
||||
.discount as UntypedFormControl;
|
||||
if (
|
||||
control.value === null ||
|
||||
control.value === '' ||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
@ -8,12 +8,12 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
styleUrls: ['./pax.component.css'],
|
||||
})
|
||||
export class PaxComponent implements OnInit {
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<PaxComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: number,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
import { MathService } from '../../shared/math.service';
|
||||
@ -10,12 +10,12 @@ import { MathService } from '../../shared/math.service';
|
||||
styleUrls: ['./quantity.component.css'],
|
||||
})
|
||||
export class QuantityComponent implements OnInit {
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<QuantityComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: number,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private math: MathService,
|
||||
) {
|
||||
// Create form
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, ElementRef, Inject, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
import { ReasonDatasource } from './reason-datasource';
|
||||
@ -11,7 +11,7 @@ import { ReasonDatasource } from './reason-datasource';
|
||||
})
|
||||
export class ReasonComponent {
|
||||
@ViewChild('son', { static: true }) son?: ElementRef;
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
dataSource: ReasonDatasource;
|
||||
title: string;
|
||||
selected = '';
|
||||
@ -21,7 +21,7 @@ export class ReasonComponent {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ReasonComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) private data: { title: string; reasons: string[] },
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
) {
|
||||
this.reasons = data.reasons || [];
|
||||
this.title = data.title;
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
import { Component, ElementRef, Inject, ViewChild } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import {
|
||||
UntypedFormArray,
|
||||
UntypedFormBuilder,
|
||||
UntypedFormControl,
|
||||
UntypedFormGroup,
|
||||
} from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
|
||||
|
||||
@ -25,14 +30,14 @@ export class ReceivePaymentComponent {
|
||||
reason = '';
|
||||
displayReason: boolean;
|
||||
displayTable: boolean;
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
dataSource: ReceivePaymentDatasource;
|
||||
|
||||
displayedColumns = ['name', 'amount'];
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ReceivePaymentComponent>,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private ser: SettleOptionService,
|
||||
@Inject(MAT_DIALOG_DATA) public data: { type: VoucherType; amount: number },
|
||||
) {
|
||||
@ -81,7 +86,7 @@ export class ReceivePaymentComponent {
|
||||
}
|
||||
|
||||
listenToAmountChange() {
|
||||
const array = this.form.get('amounts') as FormArray;
|
||||
const array = this.form.get('amounts') as UntypedFormArray;
|
||||
this.choices.forEach((z, i) =>
|
||||
array.controls[i].valueChanges.pipe(distinctUntilChanged()).subscribe((x) => {
|
||||
(this.choices.find((s) => s.name === x.name) as ReceivePaymentItem).amount =
|
||||
@ -101,8 +106,8 @@ export class ReceivePaymentComponent {
|
||||
}
|
||||
|
||||
maxAmount(row: ReceivePaymentItem, index: number) {
|
||||
const array = this.form.get('amounts') as FormArray;
|
||||
const ctrl = array.controls[index].get('amount') as FormControl;
|
||||
const array = this.form.get('amounts') as UntypedFormArray;
|
||||
const ctrl = array.controls[index].get('amount') as UntypedFormControl;
|
||||
ctrl.setValue('' + (row.amount + this.balance));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@ -10,11 +10,11 @@ import { Observable } from 'rxjs';
|
||||
})
|
||||
export class SplitBillComponent {
|
||||
list: { id: string; name: string; selected: boolean }[] = [];
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<SplitBillComponent>,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
@Inject(MAT_DIALOG_DATA)
|
||||
public data: Observable<{ id: string; name: string; selected: boolean }[]>,
|
||||
) {
|
||||
@ -37,7 +37,7 @@ export class SplitBillComponent {
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
const array = this.form.get('saleCategories') as FormArray;
|
||||
const array = this.form.get('saleCategories') as UntypedFormArray;
|
||||
this.list.forEach((item, index) => {
|
||||
item.selected = array.controls[index].value.saleCategory;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user