41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import {Component, effect, input} from '@angular/core';
|
|
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
|
import {NzColDirective} from "ng-zorro-antd/grid";
|
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
import {GetProductDto} from "../../services/api";
|
|
|
|
@Component({
|
|
selector: 'app-stock-form',
|
|
imports: [
|
|
NzFormItemComponent,
|
|
NzFormLabelComponent,
|
|
NzFormControlComponent,
|
|
NzInputDirective,
|
|
NzColDirective,
|
|
NzFormDirective,
|
|
ReactiveFormsModule,
|
|
NzFlexDirective
|
|
],
|
|
templateUrl: './stock-form.html',
|
|
styleUrl: './stock-form.css',
|
|
})
|
|
export class StockForm {
|
|
stockForm = new FormGroup({
|
|
id: new FormControl<number>(null),
|
|
minimalQuantity: new FormControl<number>(null, [Validators.required])
|
|
})
|
|
|
|
product= input<GetProductDto>();
|
|
constructor() {
|
|
effect(() => {
|
|
if (this.product()) {
|
|
this.stockForm.patchValue({
|
|
id: this.product().id,
|
|
minimalQuantity: this.product().minimalQuantity,
|
|
});
|
|
}
|
|
});
|
|
}
|
|
} |