Commit 5962f7dea6014988c2e8344066b3c3f669c3b013
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master(mpuebla) See merge request !72
Showing
6 changed files
Show diff stats
src/app/components/inicio/inicio.component.ts
| ... | ... | @@ -96,6 +96,7 @@ export class InicioComponent implements OnInit, AfterViewInit { |
| 96 | 96 | producto.cantidad = 1; |
| 97 | 97 | this.productoService.setProductos(producto); |
| 98 | 98 | this.productoService.productoAcargar = this.promoAcargar = this.productoAcargar = undefined; |
| 99 | + this.productoService.esPromoPersonalizada = false; | |
| 99 | 100 | this.promociones = []; |
| 100 | 101 | this.popoverDirective.hide(); |
| 101 | 102 | } |
| ... | ... | @@ -184,6 +185,7 @@ export class InicioComponent implements OnInit, AfterViewInit { |
| 184 | 185 | |
| 185 | 186 | if (this.sinonimos.length > 0) { |
| 186 | 187 | this.sinonimos = []; |
| 188 | + this.productoService.esPromoPersonalizada = false; | |
| 187 | 189 | this.popoverDirective.hide(); |
| 188 | 190 | } |
| 189 | 191 |
src/app/components/popover-sinonimos/popover-sinonimos.component.html
| ... | ... | @@ -13,10 +13,17 @@ |
| 13 | 13 | <div class="row mb-2" *ngFor="let sinonimo of popoverContent; let i = index"> |
| 14 | 14 | <div class="col p-0"> |
| 15 | 15 | |
| 16 | - <div class="row m-0"> | |
| 16 | + <div class="row bg-white text-dark m-0 py-1 shadow"> | |
| 17 | 17 | <div class="col text-left"> |
| 18 | - <p class="h5 card-title"> | |
| 19 | - Elija opción - Cantidad Restante {{cantidadRestanteSinonimos[i]}} | |
| 18 | + <p class="h5 m-0 card-title"> | |
| 19 | + Elija opción - | |
| 20 | + <span [ngClass]=" | |
| 21 | + { | |
| 22 | + 'text-success': cantidadRestanteSinonimos == 0, | |
| 23 | + 'text-danger': cantidadRestanteSinonimos > 0 | |
| 24 | + }"> | |
| 25 | + Cantidad Restante {{cantidadRestanteSinonimos}} | |
| 26 | + </span> | |
| 20 | 27 | </p> |
| 21 | 28 | </div> |
| 22 | 29 | </div> |
src/app/components/popover-sinonimos/popover-sinonimos.component.ts
| ... | ... | @@ -17,7 +17,7 @@ export class PopoverSinonimosComponent implements OnInit { |
| 17 | 17 | @Output() productosPersonalizados = new EventEmitter<Producto[]>(); |
| 18 | 18 | // sinonimo: Sinonimo; |
| 19 | 19 | |
| 20 | - private cantidadRestanteSinonimos: number[] = []; | |
| 20 | + private cantidadRestanteSinonimos: number = 0; | |
| 21 | 21 | |
| 22 | 22 | constructor(private productoService: ProductoService) { } |
| 23 | 23 | |
| ... | ... | @@ -25,14 +25,13 @@ export class PopoverSinonimosComponent implements OnInit { |
| 25 | 25 | |
| 26 | 26 | this.popoverContent.forEach(sinonimo => { |
| 27 | 27 | |
| 28 | - this.cantidadRestanteSinonimos.push(0); | |
| 29 | - | |
| 30 | 28 | sinonimo.productos.forEach((producto, index) => { |
| 31 | 29 | |
| 32 | - if (producto.cantidad) { | |
| 33 | - sinonimo.productos.splice(index, 1); | |
| 34 | - sinonimo.productos.splice(0, 0, producto); | |
| 30 | + if (this.productoService.esPromoPersonalizada) { | |
| 31 | + producto.cantidad = producto.cantidad ? producto.cantidad : 0; | |
| 32 | + this.cantidadRestanteSinonimos = 0; | |
| 35 | 33 | } else { |
| 34 | + this.cantidadRestanteSinonimos += producto.cantidad ? producto.cantidad : 0; | |
| 36 | 35 | producto.cantidad = 0; |
| 37 | 36 | } |
| 38 | 37 | |
| ... | ... | @@ -43,10 +42,7 @@ export class PopoverSinonimosComponent implements OnInit { |
| 43 | 42 | continuar() { |
| 44 | 43 | |
| 45 | 44 | //Si aún quedan articulos que agregar no deja continuar. |
| 46 | - for (let i = 0; i < this.cantidadRestanteSinonimos.length; i++) { | |
| 47 | - | |
| 48 | - if (this.cantidadRestanteSinonimos[i] > 0) return; | |
| 49 | - } | |
| 45 | + if (this.cantidadRestanteSinonimos > 0) return; | |
| 50 | 46 | |
| 51 | 47 | var productosAenviar: Producto[] = []; |
| 52 | 48 | |
| ... | ... | @@ -68,17 +64,17 @@ export class PopoverSinonimosComponent implements OnInit { |
| 68 | 64 | |
| 69 | 65 | sumarCantidad(producto: Producto, i: number) { |
| 70 | 66 | |
| 71 | - if (this.cantidadRestanteSinonimos[i] === 0) return; | |
| 67 | + if (this.cantidadRestanteSinonimos === 0) return; | |
| 72 | 68 | producto.cantidad++; |
| 73 | - this.cantidadRestanteSinonimos[i]--; | |
| 69 | + this.cantidadRestanteSinonimos--; | |
| 74 | 70 | } |
| 75 | 71 | |
| 76 | 72 | restarCantidad(producto: Producto, i: number) { |
| 77 | 73 | |
| 78 | - if (this.cantidadRestanteSinonimos[i] === this.popoverContent[i].cantidad) return; | |
| 74 | + if (this.cantidadRestanteSinonimos === this.popoverContent[i].cantidad) return; | |
| 79 | 75 | if (producto.cantidad === 0) return; |
| 80 | 76 | producto.cantidad--; |
| 81 | - this.cantidadRestanteSinonimos[i]++; | |
| 77 | + this.cantidadRestanteSinonimos++; | |
| 82 | 78 | } |
| 83 | 79 | |
| 84 | 80 | } |
src/app/components/sidebar/sidebar.component.html
| ... | ... | @@ -6,10 +6,10 @@ |
| 6 | 6 | <i class="fa fa-shopping-cart" aria-hidden="true"></i> |
| 7 | 7 | </p> |
| 8 | 8 | |
| 9 | - <div class="overflow-auto overflow-scroll mb-2 w-100"> | |
| 9 | + <div class="overflow-scroll px-1 mb-2 w-100"> | |
| 10 | 10 | <!-- PRODUCTOS CARRITO --> |
| 11 | 11 | <div |
| 12 | - class="slide-in-bl my-2 bg-white border-0 rounded-sm" | |
| 12 | + class="my-2 bg-white border-0 rounded-sm" | |
| 13 | 13 | *ngFor="let producto of productosCarrito.slice().reverse(); let i = index"> |
| 14 | 14 | <img class="w-100 m-auto rounded-sm shadow" src="{{apiImagenes}}/imagenes/{{producto.imagenes[0].imagen}}"> |
| 15 | 15 | <div class="row m-0 p-0 px-1 py-1 shadow rounded-sm"> |
src/app/components/sidebar/sidebar.component.ts
| ... | ... | @@ -80,6 +80,7 @@ export class SidebarComponent implements OnInit { |
| 80 | 80 | personalizarPromo(producto: Producto, index) { |
| 81 | 81 | |
| 82 | 82 | this.productoService.productoAcargar = producto; |
| 83 | + this.productoService.esPromoPersonalizada = true; | |
| 83 | 84 | this.deleteProducto(producto, index); |
| 84 | 85 | this.router.navigate(['inicio']); |
| 85 | 86 | } |
src/app/services/producto.service.ts