Commit 2faef52ed0128c936c0e8bcc970db4421fc59028
1 parent
411952c8b2
Exists in
develop
Fix
en seleccion de sinonimo
Showing
4 changed files
with
13 additions
and
28 deletions
Show diff stats
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
... | ... | @@ -158,13 +158,7 @@ export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDes |
158 | 158 | .subscribe((res: any) => { |
159 | 159 | this.modalRef = null; |
160 | 160 | if (!res) return; |
161 | - for (const a of articulo.productos) { | |
162 | - for (const aRes of res.articulos) { | |
163 | - if (a.idSinonimo === aRes.ID_SIN) { | |
164 | - this.articuloService.changeArticulo(a, aRes); | |
165 | - } | |
166 | - } | |
167 | - } | |
161 | + articulo.productos = res.articulos; | |
168 | 162 | this.articuloService.setArticulo(articulo); |
169 | 163 | }); |
170 | 164 | this.mediaPantalla(); |
src/app/shared/header-publicidad/header-publicidad.component.ts
... | ... | @@ -119,13 +119,8 @@ export class HeaderPublicidadComponent implements OnInit { |
119 | 119 | this.modalSinonimo.content.onClose |
120 | 120 | .subscribe((res: any) => { |
121 | 121 | this.modalSinonimo = null; |
122 | - for (const a of articulo.productos) { | |
123 | - for (const aRes of res.articulos) { | |
124 | - if (a.idSinonimo === aRes.ID_SIN) { | |
125 | - this.articuloService.changeArticulo(a, aRes); | |
126 | - } | |
127 | - } | |
128 | - } | |
122 | + if (!res) return; | |
123 | + articulo.productos = res.articulos; | |
129 | 124 | this.articuloService.setArticulo(articulo); |
130 | 125 | }); |
131 | 126 | } |
src/app/shared/promocion/promocion.component.ts
... | ... | @@ -86,13 +86,7 @@ export class PromocionComponent implements OnInit { |
86 | 86 | this.modalPromocion.hide(); |
87 | 87 | return; |
88 | 88 | } |
89 | - for (const a of articulo.productos) { | |
90 | - for (const aRes of res.articulos) { | |
91 | - if (a.idSinonimo === aRes.ID_SIN) { | |
92 | - this.articuloService.changeArticulo(a, aRes); | |
93 | - } | |
94 | - } | |
95 | - } | |
89 | + articulo.productos = res.articulos; | |
96 | 90 | this.articuloService.setArticulo(articulo); |
97 | 91 | this.onClose.next(); |
98 | 92 | this.modalPromocion.hide(); |
src/app/shared/sinonimo/sinonimo.component.ts
... | ... | @@ -49,18 +49,20 @@ export class SinonimoComponent implements OnInit { |
49 | 49 | if (!this.isValid) return; |
50 | 50 | if (this.isSinonimoSelected) return; |
51 | 51 | this.isSinonimoSelected = true; |
52 | - const ID_SINS = []; | |
53 | 52 | const observables = []; |
53 | + const cantidades = []; | |
54 | 54 | |
55 | - // for (const articulo of this.articulosSelected) { | |
56 | - // ID_SINS.push(articulo.ID_SIN); | |
57 | - // observables.push(this.articuloService.getById(articulo.id)); | |
58 | - // } | |
59 | - | |
55 | + for (const s of this.sinonimos) { | |
56 | + for (const articulo of s.productos) { | |
57 | + if (articulo.cantidad === 0) continue; | |
58 | + cantidades.push(articulo.cantidad); | |
59 | + observables.push(this.articuloService.getById(articulo.id)); | |
60 | + } | |
61 | + } | |
60 | 62 | forkJoin(observables) |
61 | 63 | .subscribe((res: IArticulo[]) => { |
62 | 64 | res.forEach((articulo, i) => { |
63 | - articulo.ID_SIN = ID_SINS[i]; | |
65 | + articulo.cantidad = cantidades[i]; | |
64 | 66 | }); |
65 | 67 | this.modalRef.hide(); |
66 | 68 | this.onClose.next({ |