Components/create-edit-modal: fix date input in edit mode
This commit is contained in:
parent
ef02fe8c82
commit
ee6ebfd98c
1 changed files with 8 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import {ShowsApiService} from '../../../services/shows/shows-api.service';
|
|||
import {ShowsApiCreation} from '../../../interfaces/shows-api-creation';
|
||||
import {ToastService} from '../../../services/toast/toast.service';
|
||||
import {Show} from '../../../interfaces/show';
|
||||
import {formatDate} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-edit-modal',
|
||||
|
|
@ -28,13 +29,19 @@ export class CreateEditModalComponent {
|
|||
}
|
||||
|
||||
private initForm() {
|
||||
let formattedDate: string
|
||||
this.newShowForm = new FormGroup({
|
||||
title: new FormControl(this.show?.title, Validators.required),
|
||||
date: new FormControl(this.show?.date, Validators.required),
|
||||
seasons: new FormControl(this.show?.seasons, [Validators.required, Validators.min(1)]),
|
||||
episodes: new FormControl(this.show?.episodes, [Validators.required, Validators.min(1)]),
|
||||
description: new FormControl(this.show?.description, Validators.required)
|
||||
})
|
||||
if (this.show?.date !== undefined) {
|
||||
formattedDate = formatDate(this.show?.date, "YYYY-MM-dd", "en")
|
||||
} else {
|
||||
formattedDate = ""
|
||||
}
|
||||
this.newShowForm.addControl("date", new FormControl(formattedDate, Validators.required))
|
||||
}
|
||||
|
||||
protected dismiss() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue