added edit function for author and book pages
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Component, input} from '@angular/core';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||
import {GetBookDto, GetLoanDto} from "../../services/api";
|
||||
|
||||
@Component({
|
||||
selector: 'app-update-loan',
|
||||
@@ -28,14 +29,15 @@ export class UpdateLoan {
|
||||
effectiveDate: new FormControl(null, [Validators.required]),
|
||||
})
|
||||
|
||||
submitForm() {
|
||||
// Pour annuler si le formulaire est invalide
|
||||
if (this.updateLoanForm.invalid) return;
|
||||
|
||||
// Pour obtenir la valeur du formulaire
|
||||
console.log(this.updateLoanForm.getRawValue())
|
||||
|
||||
// Pour vider le formulaire
|
||||
this.updateLoanForm.reset()
|
||||
loan = input.required<GetLoanDto>()
|
||||
ngOnChanges() {
|
||||
if (this.loan) {
|
||||
this.updateLoanForm.patchValue({
|
||||
name: this.loan().userName,
|
||||
book: this.loan().bookTitle,
|
||||
plannedDate: new Date(this.loan().plannedReturningDate),
|
||||
effectiveDate: new Date(this.loan().effectiveReturningDate)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user