Commit b023575075183e501158f6b2c825f048a5722014
1 parent
134630072f
Exists in
develop
Fix
Manejo de modales.
Showing
3 changed files
with
25 additions
and
5 deletions
Show diff stats
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
... | ... | @@ -142,16 +142,19 @@ export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDes |
142 | 142 | } |
143 | 143 | |
144 | 144 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { |
145 | + if (this.modalRef) return; | |
145 | 146 | this.modalRef = this.modalService.show(SinonimoComponent, { |
146 | 147 | initialState: { |
147 | 148 | sinonimos: sinonimosData, |
148 | 149 | articulo |
149 | 150 | }, |
150 | - class: 'modal-dialog-centered' | |
151 | + class: 'modal-dialog-centered', | |
152 | + ignoreBackdropClick: true, | |
151 | 153 | }); |
152 | 154 | |
153 | 155 | this.modalRef.content.onClose |
154 | 156 | .subscribe((res: any) => { |
157 | + this.modalRef = null; | |
155 | 158 | for (const a of articulo.productos) { |
156 | 159 | for (const aRes of res.articulos) { |
157 | 160 | if (a.idSinonimo === aRes.ID_SIN) { |
src/app/shared/promocion/promocion.component.ts
... | ... | @@ -22,9 +22,11 @@ export class PromocionComponent implements OnInit { |
22 | 22 | onClose: Subject<any>; |
23 | 23 | urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; |
24 | 24 | loading = true; |
25 | + modalSinonimo: BsModalRef; | |
26 | + isPromoSelected = false; | |
25 | 27 | |
26 | 28 | constructor( |
27 | - public modalPromocion: BsModalRef, | |
29 | + private modalPromocion: BsModalRef, | |
28 | 30 | private modalService: BsModalService, |
29 | 31 | private articuloService: ArticuloService, |
30 | 32 | private promocionService: PromocionService, |
... | ... | @@ -39,6 +41,8 @@ export class PromocionComponent implements OnInit { |
39 | 41 | } |
40 | 42 | |
41 | 43 | selectPromo(promo: IArticulo) { |
44 | + if (this.isPromoSelected) return; | |
45 | + this.isPromoSelected = true; | |
42 | 46 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) |
43 | 47 | .subscribe((res: ISinonimo[]) => { |
44 | 48 | if (res.length) { |
... | ... | @@ -60,16 +64,24 @@ export class PromocionComponent implements OnInit { |
60 | 64 | } |
61 | 65 | |
62 | 66 | openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { |
63 | - const modalSinonimo = this.modalService.show(SinonimoComponent, { | |
67 | + if (this.modalSinonimo) return; | |
68 | + this.modalSinonimo = this.modalService.show(SinonimoComponent, { | |
64 | 69 | initialState: { |
65 | 70 | sinonimos: sinonimosData, |
66 | 71 | articulo |
67 | 72 | }, |
68 | - class: 'modal-dialog-centered' | |
73 | + class: 'modal-dialog-centered', | |
74 | + ignoreBackdropClick: true, | |
69 | 75 | }); |
70 | 76 | |
71 | - modalSinonimo.content.onClose | |
77 | + this.modalSinonimo.content.onClose | |
72 | 78 | .subscribe((res: any) => { |
79 | + this.modalSinonimo = null; | |
80 | + if (!res) { | |
81 | + this.onClose.next(); | |
82 | + this.modalPromocion.hide(); | |
83 | + return; | |
84 | + } | |
73 | 85 | for (const a of articulo.productos) { |
74 | 86 | for (const aRes of res.articulos) { |
75 | 87 | if (a.idSinonimo === aRes.ID_SIN) { |
... | ... | @@ -85,6 +97,7 @@ export class PromocionComponent implements OnInit { |
85 | 97 | } |
86 | 98 | } |
87 | 99 | this.articuloService.setArticulo(articulo); |
100 | + this.onClose.next(); | |
88 | 101 | this.modalPromocion.hide(); |
89 | 102 | }); |
90 | 103 | } |
src/app/shared/sinonimo/sinonimo.component.ts
... | ... | @@ -17,6 +17,7 @@ export class SinonimoComponent implements OnInit { |
17 | 17 | onClose: Subject<any>; |
18 | 18 | articulosSelected: IArticulo[] = []; |
19 | 19 | articulo: IArticulo; |
20 | + isSinonimoSelected = false; | |
20 | 21 | |
21 | 22 | constructor( |
22 | 23 | private modalRef: BsModalRef, |
... | ... | @@ -50,6 +51,8 @@ export class SinonimoComponent implements OnInit { |
50 | 51 | |
51 | 52 | continue() { |
52 | 53 | if (!this.isValid) return; |
54 | + if (this.isSinonimoSelected) return; | |
55 | + this.isSinonimoSelected = true; | |
53 | 56 | const ID_SINS = []; |
54 | 57 | const observables = []; |
55 | 58 | |
... | ... | @@ -82,6 +85,7 @@ export class SinonimoComponent implements OnInit { |
82 | 85 | |
83 | 86 | close() { |
84 | 87 | this.modalRef.hide(); |
88 | + this.onClose.next(); | |
85 | 89 | } |
86 | 90 | |
87 | 91 | } |