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,7 +45,13 @@ export class CreateEditModalComponent {
|
||||||
images: new FormArray([])
|
images: new FormArray([])
|
||||||
})
|
})
|
||||||
|
|
||||||
this.addImageControl()
|
if (this.show?.images !== undefined) {
|
||||||
|
this.show?.images.forEach((imageUrl: string) => {
|
||||||
|
this.addImageControl(imageUrl)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.addImageControl()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get images(): FormArray {
|
get images(): FormArray {
|
||||||
|
|
@ -56,9 +62,9 @@ export class CreateEditModalComponent {
|
||||||
this.activeModal.dismiss()
|
this.activeModal.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected addImageControl() {
|
protected addImageControl(value: string = "") {
|
||||||
const urlRegex: string = '(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?'
|
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) {
|
protected removeImageControl(index: number) {
|
||||||
|
|
@ -72,11 +78,11 @@ export class CreateEditModalComponent {
|
||||||
seasons: form.get("seasons")?.value,
|
seasons: form.get("seasons")?.value,
|
||||||
episodes: form.get("episodes")?.value,
|
episodes: form.get("episodes")?.value,
|
||||||
description: form.get("description")?.value,
|
description: form.get("description")?.value,
|
||||||
|
images: form.get("images")?.value,
|
||||||
//TODO: Allow user to specify genres
|
//TODO: Allow user to specify genres
|
||||||
genres: []
|
genres: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!this.editMode) {
|
if (!this.editMode) {
|
||||||
this.showsService.sendShow(show).subscribe({
|
this.showsService.sendShow(show).subscribe({
|
||||||
next: (response: ShowsApiCreation) => {
|
next: (response: ShowsApiCreation) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue