Components/create-edit-modal: return new show instead of id on creation
This commit is contained in:
parent
b52a8af0bf
commit
77be63e88f
2 changed files with 4 additions and 14 deletions
|
|
@ -58,10 +58,9 @@ export class CreateEditModalComponent {
|
||||||
//TODO: Allow user to specify genres
|
//TODO: Allow user to specify genres
|
||||||
genres: []
|
genres: []
|
||||||
}
|
}
|
||||||
let newId: string;
|
|
||||||
this.showsService.sendShow(show).subscribe({
|
this.showsService.sendShow(show).subscribe({
|
||||||
next: (response: ShowsApiCreation) => {
|
next: (response: ShowsApiCreation) => {
|
||||||
newId = response.newId
|
show._id = response.newId
|
||||||
}, error: err => {
|
}, error: err => {
|
||||||
this.toastService.show({
|
this.toastService.show({
|
||||||
body: "Could not add show!",
|
body: "Could not add show!",
|
||||||
|
|
@ -73,7 +72,7 @@ export class CreateEditModalComponent {
|
||||||
body: "Show added successfully!",
|
body: "Show added successfully!",
|
||||||
htmlClass: "bg-success text-light"
|
htmlClass: "bg-success text-light"
|
||||||
})
|
})
|
||||||
this.activeModal.close(newId)
|
this.activeModal.close(show)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,17 +48,8 @@ export class ShowsComponent {
|
||||||
|
|
||||||
createNewShow() {
|
createNewShow() {
|
||||||
this.modalService.open(CreateEditModalComponent).result.then(
|
this.modalService.open(CreateEditModalComponent).result.then(
|
||||||
(result) => {
|
(result: Show) => {
|
||||||
console.log(`Result: ${result}`)
|
this.shows.push(result)
|
||||||
|
|
||||||
this.api.getShow(result).subscribe({
|
|
||||||
next: (response: ShowsApiIdResponse) => {
|
|
||||||
this.shows.push(response.show)
|
|
||||||
}, error: (err: any) => {
|
|
||||||
console.error(`Error: ${err}`)
|
|
||||||
}, complete: () => {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
(result) => {
|
(result) => {
|
||||||
// Dismissed, do nothing
|
// Dismissed, do nothing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue