Commit b98fa43e302d27092b73e3da6018b5237cd58566
1 parent
42f74088a6
Exists in
master
and in
1 other branch
Agregado filtro Todos.
Showing
2 changed files
with
13 additions
and
4 deletions
Show diff stats
src/app/components/busqueda-productos/busqueda-productos.component.html
| ... | ... | @@ -20,6 +20,12 @@ |
| 20 | 20 | </div> |
| 21 | 21 | <ul class="list-group"> |
| 22 | 22 | <li |
| 23 | + [ngClass]="{active: categoriaActive == 0}" | |
| 24 | + (click)="categoriaActive = 0; filterItems()" | |
| 25 | + class="list-group-item list-group-item-action text-center my-1 p-2 h6"> | |
| 26 | + Todos | |
| 27 | + </li> | |
| 28 | + <li | |
| 23 | 29 | *ngFor="let categoria of categorias" |
| 24 | 30 | [ngClass]="{active: categoriaActive == categoria.id}" |
| 25 | 31 | (click)="categoriaActive = categoria.id; filterItems()" |
src/app/components/busqueda-productos/busqueda-productos.component.ts
| ... | ... | @@ -33,7 +33,7 @@ export class BusquedaProductosComponent implements OnInit { |
| 33 | 33 | this.productoService.getCategorias() |
| 34 | 34 | .subscribe((categorias: Categoria[]) => { |
| 35 | 35 | this.categorias = categorias; |
| 36 | - this.categoriaActive = this.verCategorias ? 1 : categorias[0].id; | |
| 36 | + this.categoriaActive = this.verCategorias ? 0 : categorias[0].id; | |
| 37 | 37 | }); |
| 38 | 38 | |
| 39 | 39 | this.productoService.productoAcargar = undefined; |
| ... | ... | @@ -51,8 +51,11 @@ export class BusquedaProductosComponent implements OnInit { |
| 51 | 51 | filterItems() { |
| 52 | 52 | |
| 53 | 53 | this.auxProductos = this.productos.filter(x => { |
| 54 | - return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) && | |
| 55 | - x.categoria_selfservice == this.categoriaActive; | |
| 54 | + if (this.categoriaActive === 0) | |
| 55 | + return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) | |
| 56 | + else | |
| 57 | + return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) && | |
| 58 | + x.categoria_selfservice === this.categoriaActive; | |
| 56 | 59 | }); |
| 57 | 60 | } |
| 58 | 61 | |
| ... | ... | @@ -80,7 +83,7 @@ export class BusquedaProductosComponent implements OnInit { |
| 80 | 83 | }, |
| 81 | 84 | error => { console.error(error); } |
| 82 | 85 | ); |
| 83 | - }else { | |
| 86 | + } else { | |
| 84 | 87 | |
| 85 | 88 | this.productoService.productoAcargar = producto; |
| 86 | 89 | this.router.navigate(['inicio']); |