diff --git a/src/components/create-edit-modal/create-edit-modal.component.ts b/src/components/create-edit-modal/create-edit-modal.component.ts index 91864f8..2700659 100644 --- a/src/components/create-edit-modal/create-edit-modal.component.ts +++ b/src/components/create-edit-modal/create-edit-modal.component.ts @@ -45,7 +45,13 @@ export class CreateEditModalComponent { 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 { @@ -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) => {