Chore:
Moved to sqlalchemy 2.0 Added type checking as much as possible Updated angular to 15 Moved from Angular flex layout to tailwind css Started developing on vscode with devcontainers
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
import { MathService } from '../../shared/math.service';
|
||||
@ -10,28 +10,29 @@ import { MathService } from '../../shared/math.service';
|
||||
styleUrls: ['./quantity.component.css'],
|
||||
})
|
||||
export class QuantityComponent implements OnInit {
|
||||
form: UntypedFormGroup;
|
||||
form: FormGroup<{
|
||||
quantity: FormControl<string>;
|
||||
}>;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<QuantityComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: number,
|
||||
private fb: UntypedFormBuilder,
|
||||
private math: MathService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
quantity: '',
|
||||
this.form = new FormGroup({
|
||||
quantity: new FormControl<string>('', { nonNullable: true }),
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.form.setValue({
|
||||
quantity: this.data,
|
||||
quantity: `${this.data}`,
|
||||
});
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
const quantity = this.math.parseAmount(this.form.value.quantity);
|
||||
const quantity = this.math.parseAmount(this.form.value.quantity ?? '');
|
||||
this.dialogRef.close(quantity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user