Commit ee99e503b10202339c62b437dfba6424081dd2a8

Authored by Marcelo Puebla
1 parent 099c7c0baa
Exists in master and in 1 other branch validar_pve

Arreglo para mantener el valor de la personalizacion.

src/app/components/inicio/inicio.component.ts
... ... @@ -21,7 +21,7 @@ export class InicioComponent implements OnInit, AfterViewInit {
21 21 private productos: Producto[] = [];
22 22 private promociones: Producto[] = [];
23 23 private sinonimos: Sinonimo[] = [];
24   - private apiUrl: string = appSettings.apiUrl
  24 + private apiUrl: string = appSettings.apiUrl;
25 25  
26 26 @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective;
27 27  
... ... @@ -104,7 +104,7 @@ export class InicioComponent implements OnInit, AfterViewInit {
104 104  
105 105 this.productoService.getProductoById($event.id)
106 106 .subscribe((res: Producto) => {
107   -
  107 +
108 108 $event.imagenes = res.imagenes.length == 0 ? [{ imagen: 'noImage.jpg' }] : res.imagenes;
109 109 this.promoAcargar = $event;
110 110  
... ... @@ -127,18 +127,18 @@ export class InicioComponent implements OnInit, AfterViewInit {
127 127  
128 128 res.forEach(sinonimo => {
129 129  
130   - sinonimo.productos.forEach(productoSinonimo => {
  130 + sinonimo.cantidad = 0;
  131 + this.promoAcargar.productos.forEach(productoPromo => {
131 132  
132   - this.promoAcargar.productos.forEach(productoPromo => {
  133 + sinonimo.productos.forEach(productoSinonimo => {
133 134  
134 135 if (productoSinonimo.id === productoPromo.id) {
135   - sinonimo.cantidad = productoPromo.cantidad;
136   - sinonimo.productoPadre = productoPromo.id;
  136 + productoSinonimo.cantidad = productoPromo.cantidad;
  137 + sinonimo.cantidad += productoPromo.cantidad;
137 138 }
138 139 })
139 140 })
140 141 })
141   -
142 142 this.sinonimos = res;
143 143 (this.sinonimos.length > 0) ? this.popoverDirective.show() : this.popoverDirective.hide();
144 144 })
src/app/components/popover-sinonimos/popover-sinonimos.component.html
... ... @@ -61,10 +61,10 @@
61 61 </div>
62 62  
63 63 <div class="row mt-3 justify-content-end">
64   - <div class="col-auto">
  64 + <div class="col">
65 65 <button
66 66 type="button"
67   - class="btn btn-sm btn-light shadow"
  67 + class="btn btn-block btn-light shadow"
68 68 (click)="continuar()">
69 69 <span class="font-weight-bold pr-2">Continuar</span>
70 70 <i class="fa fa-check text-success" aria-hidden="true"></i>
src/app/components/popover-sinonimos/popover-sinonimos.component.ts
... ... @@ -28,11 +28,10 @@ export class PopoverSinonimosComponent implements OnInit {
28 28 this.cantidadRestanteSinonimos.push(0);
29 29  
30 30 sinonimo.productos.forEach((producto, index) => {
31   -
32   - if (producto.id === sinonimo.productoPadre) {
  31 +
  32 + if (producto.cantidad) {
33 33 sinonimo.productos.splice(index, 1);
34 34 sinonimo.productos.splice(0, 0, producto);
35   - producto.cantidad = sinonimo.cantidad;
36 35 } else {
37 36 producto.cantidad = 0;
38 37 }