Commit ba0d5294d399ca50b9dd323880d3dca66779af5b
1 parent
536bb85311
Exists in
master
Logica de get sinonimos en otro metodo.
Showing
1 changed file
with
25 additions
and
19 deletions
Show diff stats
src/app/components/inicio/inicio.component.ts
... | ... | @@ -127,32 +127,38 @@ export class InicioComponent implements OnInit { |
127 | 127 | if (this.promoAcargar.tieneSinonimos) { |
128 | 128 | var sector = this.promoAcargar.CodSec; |
129 | 129 | var codigo = this.promoAcargar.CodArt; |
130 | - this.productoService.getPromocionSinonimos(sector, codigo) | |
131 | - .subscribe((res: Sinonimo[]) => { | |
130 | + this.getSinonimos(sector, codigo); | |
132 | 131 | |
133 | - res.forEach(sinonimo => { | |
132 | + } else if (this.popoverDirective) { | |
133 | + this.popoverDirective.hide(); | |
134 | + } | |
135 | + } | |
136 | + | |
137 | + getSinonimos(sector, codigo) { | |
138 | + | |
139 | + this.productoService.getPromocionSinonimos(sector, codigo) | |
140 | + .subscribe((res: Sinonimo[]) => { | |
141 | + | |
142 | + res.forEach(sinonimo => { | |
134 | 143 | |
135 | - sinonimo.productos.forEach(productoSinonimo => { | |
144 | + sinonimo.productos.forEach(productoSinonimo => { | |
136 | 145 | |
137 | - this.promoAcargar.productos.forEach(productoPromo => { | |
146 | + this.promoAcargar.productos.forEach(productoPromo => { | |
138 | 147 | |
139 | - if (productoSinonimo.id === productoPromo.id) { | |
140 | - sinonimo.cantidad = productoPromo.cantidad; | |
141 | - sinonimo.productoPadre = productoPromo.id; | |
142 | - } | |
143 | - }) | |
148 | + if (productoSinonimo.id === productoPromo.id) { | |
149 | + sinonimo.cantidad = productoPromo.cantidad; | |
150 | + sinonimo.productoPadre = productoPromo.id; | |
151 | + } | |
144 | 152 | }) |
145 | 153 | }) |
146 | - | |
147 | - this.sinonimos = res; | |
148 | - if (res.length > 0) | |
149 | - this.popoverDirective.show(); | |
150 | - else | |
151 | - this.popoverDirective.hide(); | |
152 | 154 | }) |
153 | - } else if (this.popoverDirective) { | |
154 | - this.popoverDirective.hide(); | |
155 | - } | |
155 | + | |
156 | + this.sinonimos = res; | |
157 | + if (res.length > 0) | |
158 | + this.popoverDirective.show(); | |
159 | + else | |
160 | + this.popoverDirective.hide(); | |
161 | + }) | |
156 | 162 | } |
157 | 163 | |
158 | 164 | productosPersonalizados($event: Producto[]) { |