Commit 269677a9aa3de539bbd350588f80be75d8a3af14
1 parent
3860f1b8db
Exists in
master
controlo cuando el comprobante existe
Showing
2 changed files
with
19 additions
and
5 deletions
Show diff stats
src/app/comprobantes/comprobantes.component.ts
... | ... | @@ -74,13 +74,25 @@ export class ComprobantesComponent implements OnInit { |
74 | 74 | .saveComprobantes({cabecera: this.cabecera, cuerpo: this.cuerpo}) |
75 | 75 | .subscribe(data => { |
76 | 76 | |
77 | - this.modal.alert('Comprobante guardado con éxito'); | |
78 | - this.saveLoading = false; | |
79 | - this.router.navigateByUrl('/home'); | |
77 | + this.modal.alert('Comprobante guardado con éxito').result.then( () => { | |
78 | + | |
79 | + this.saveLoading = false; | |
80 | + this.router.navigateByUrl('/home'); | |
81 | + }); | |
80 | 82 | |
81 | 83 | }, err => { |
82 | 84 | |
83 | - this.modal.alert('Algo salió mal...'); | |
85 | + if (err.status == 510) { | |
86 | + | |
87 | + this.modal.alert('Ya existe el comprobante').result.then(() => { | |
88 | + | |
89 | + this.router.navigateByUrl('/home'); | |
90 | + }); | |
91 | + } else { | |
92 | + | |
93 | + this.modal.alert('Algo salió mal...'); | |
94 | + } | |
95 | + | |
84 | 96 | this.saveLoading = false; |
85 | 97 | console.log(err); |
86 | 98 | }); |
src/app/modal/modal.service.ts
... | ... | @@ -12,6 +12,8 @@ export class ModalService { |
12 | 12 | modalComponent: ModalAlertComponent; |
13 | 13 | |
14 | 14 | alert(texto: string) { |
15 | - return this.modalService.open(ModalAlertComponent).componentInstance.textoModal = texto; | |
15 | + let modal = this.modalService.open(ModalAlertComponent) | |
16 | + modal.componentInstance.textoModal = texto; | |
17 | + return modal; | |
16 | 18 | } |
17 | 19 | } |