Components/create-edit-modal: send and recieve images from api
This commit is contained in:
parent
cae2fd1e09
commit
a52a76b6d0
1 changed files with 10 additions and 4 deletions
|
|
@ -45,8 +45,14 @@ export class CreateEditModalComponent {
|
|||
images: new FormArray([])
|
||||
})
|
||||
|
||||
if (this.show?.images !== undefined) {
|
||||
this.show?.images.forEach((imageUrl: string) => {
|
||||
this.addImageControl(imageUrl)
|
||||
})
|
||||
} else {
|
||||
this.addImageControl()
|
||||
}
|
||||
}
|
||||
|
||||
get images(): FormArray {
|
||||
return this.newShowForm.get("images") as FormArray
|
||||
|
|
@ -56,9 +62,9 @@ export class CreateEditModalComponent {
|
|||
this.activeModal.dismiss()
|
||||
}
|
||||
|
||||
protected addImageControl() {
|
||||
protected addImageControl(value: string = "") {
|
||||
const urlRegex: string = '(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?'
|
||||
this.images.push(new FormControl("", [Validators.required, Validators.pattern(urlRegex)]))
|
||||
this.images.push(new FormControl(value, [Validators.required, Validators.pattern(urlRegex)]))
|
||||
}
|
||||
|
||||
protected removeImageControl(index: number) {
|
||||
|
|
@ -72,11 +78,11 @@ export class CreateEditModalComponent {
|
|||
seasons: form.get("seasons")?.value,
|
||||
episodes: form.get("episodes")?.value,
|
||||
description: form.get("description")?.value,
|
||||
images: form.get("images")?.value,
|
||||
//TODO: Allow user to specify genres
|
||||
genres: []
|
||||
}
|
||||
|
||||
|
||||
if (!this.editMode) {
|
||||
this.showsService.sendShow(show).subscribe({
|
||||
next: (response: ShowsApiCreation) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue