Commit 4df01d80e7a41a91f1151f391bede99a1c344b93

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

Agregada funcion para quitar un producto del carrito para volver a personalizarlo.

src/app/app-routing.module.ts
... ... @@ -28,7 +28,7 @@ const routes: Routes = [
28 28 ];
29 29  
30 30 @NgModule({
31   - imports: [RouterModule.forRoot(routes)],
  31 + imports: [RouterModule.forRoot(routes, {onSameUrlNavigation: 'reload'})],
32 32 exports: [RouterModule]
33 33 })
34 34  
src/app/components/sidebar/sidebar.component.html
... ... @@ -52,8 +52,8 @@
52 52 *ngIf="esPersonalizable(producto)"
53 53 type="button"
54 54 class="btn btn-light btn-sm my-auto float-left border shadow"
55   - (click)="personalizarPromo">
56   - <i class="fa fa-hand-o-up" aria-hidden="true"></i>
  55 + (click)="personalizarPromo(producto, i)">
  56 + <i class="fa fa-refresh text-purple" aria-hidden="true"></i>
57 57 </button>
58 58 </div>
59 59  
src/app/components/sidebar/sidebar.component.ts
... ... @@ -2,6 +2,7 @@ import { Component, OnInit } from &#39;@angular/core&#39;;
2 2 import { Producto } from 'src/app/wrappers/producto';
3 3 import { appSettings } from 'src/etc/AppSettings';
4 4 import { ProductoService } from 'src/app/services/producto.service';
  5 +import { Router } from '@angular/router';
5 6  
6 7 @Component({
7 8 selector: 'app-sidebar',
... ... @@ -18,7 +19,13 @@ export class SidebarComponent implements OnInit {
18 19  
19 20 public productosCarrito: Producto[] = [];
20 21  
21   - constructor(private productoService: ProductoService) { }
  22 + constructor(
  23 + private productoService: ProductoService,
  24 + private router: Router) {
  25 + this.router.routeReuseStrategy.shouldReuseRoute = function () {
  26 + return false;
  27 + }
  28 + }
22 29  
23 30 ngOnInit() {
24 31  
... ... @@ -80,4 +87,11 @@ export class SidebarComponent implements OnInit {
80 87 return esPersonalizable;
81 88 }
82 89  
  90 + personalizarPromo(producto: Producto, index) {
  91 +
  92 + this.productoService.productoAcargar = producto;
  93 + this.deleteProducto(producto, index);
  94 + this.router.navigate(['inicio']);
  95 + }
  96 +
83 97 }