Commit 1abd6a9f974396ee4203aa7e7ab00d3eb71be765
1 parent
2bfe01da15
Exists in
master
and in
1 other branch
Agregado enum para filtro por categoria.
Showing
2 changed files
with
34 additions
and
8 deletions
Show diff stats
src/app/components/busqueda-productos/busqueda-productos.component.html
| 1 | <div class="row m-0 fade-in"> | 1 | <div class="row m-0 fade-in"> |
| 2 | <div class="col-10 p-0"> | 2 | <div class="col-10 p-0"> |
| 3 | <!-- TOP HEADER --> | 3 | <!-- TOP HEADER --> |
| 4 | <app-header></app-header> | 4 | <app-header></app-header> |
| 5 | 5 | ||
| 6 | <!-- NOMBRE DE SECCION --> | 6 | <!-- NOMBRE DE SECCION --> |
| 7 | <div class="row m-0"> | 7 | <div class="row m-0"> |
| 8 | <div class="col-12 p-0"> | 8 | <div class="col-12 p-0"> |
| 9 | <p class="h5 py-1 bg-light text-muted text-center"> | 9 | <p class="h5 py-1 bg-light text-muted text-center"> |
| 10 | Búsqueda | 10 | Búsqueda |
| 11 | <i class="fa fa-search"></i> | 11 | <i class="fa fa-search"></i> |
| 12 | </p> | 12 | </p> |
| 13 | </div> | 13 | </div> |
| 14 | </div> | 14 | </div> |
| 15 | 15 | ||
| 16 | <div class="row m-4 disable-user-select"> | 16 | <div class="row m-4 disable-user-select"> |
| 17 | 17 | ||
| 18 | <!-- FILTROS --> | 18 | <!-- FILTROS --> |
| 19 | <div class="col-sm-2"> | 19 | <div class="col-sm-2 p-1"> |
| 20 | <div class="text-center"> | 20 | <div class="text-center"> |
| 21 | <p class="font-weight-bold text-muted border-bottom pb-2">Buscar por Categoría</p> | 21 | <p class="font-weight-bold text-muted border-bottom pb-2">Buscar por Categoría</p> |
| 22 | </div> | 22 | </div> |
| 23 | <ul class="list-group"> | 23 | <ul class="list-group"> |
| 24 | <li class="list-group-item list-group-item-action my-1 py-2 h6"> | 24 | <li |
| 25 | [ngClass]="{active: categoria == 1}" | ||
| 26 | (click)="categoria = 1" | ||
| 27 | class="list-group-item list-group-item-action text-center my-1 p-2 h6"> | ||
| 25 | Combos y Promociones | 28 | Combos y Promociones |
| 26 | </li> | 29 | </li> |
| 27 | <li | 30 | <li |
| 28 | class="list-group-item list-group-item-action my-1 p-2 h6 shadow-sm font-weight-bold"> | 31 | [ngClass]="{active: categoria == 2}" |
| 32 | (click)="categoria = 2" | ||
| 33 | class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | ||
| 29 | Todos | 34 | Todos |
| 30 | </li> | 35 | </li> |
| 31 | <li | 36 | <li |
| 32 | class="list-group-item list-group-item-action my-1 p-2 h6 shadow-sm"> | 37 | [ngClass]="{active: categoria == 3}" |
| 38 | (click)="categoria = 3" | ||
| 39 | class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | ||
| 33 | Bebidas | 40 | Bebidas |
| 34 | </li> | 41 | </li> |
| 35 | <li | 42 | <li |
| 36 | class="list-group-item list-group-item-action my-1 p-2 h6 shadow-sm"> | 43 | [ngClass]="{active: categoria == 4}" |
| 44 | (click)="categoria = 4" | ||
| 45 | class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | ||
| 37 | Sandwichería | 46 | Sandwichería |
| 38 | </li> | 47 | </li> |
| 39 | <li | 48 | <li |
| 40 | class="list-group-item list-group-item-action my-1 p-2 h6 shadow-sm"> | 49 | [ngClass]="{active: categoria == 5}" |
| 50 | (click)="categoria = 5" | ||
| 51 | class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | ||
| 41 | Panaderia | 52 | Panaderia |
| 42 | </li> | 53 | </li> |
| 43 | <li | 54 | <li |
| 44 | class="list-group-item list-group-item-action my-1 p-2 h6 shadow-sm"> | 55 | [ngClass]="{active: categoria == 6}" |
| 56 | (click)="categoria = 6" | ||
| 57 | class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | ||
| 45 | Golosinas | 58 | Golosinas |
| 46 | </li> | 59 | </li> |
| 47 | <li | 60 | <li |
| 48 | class="list-group-item list-group-item-action my-1 p-2 h6 shadow-sm"> | 61 | [ngClass]="{active: categoria == 7}" |
| 62 | (click)="categoria = 7" | ||
| 63 | class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | ||
| 49 | Tabaqueria | 64 | Tabaqueria |
| 50 | </li> | 65 | </li> |
| 51 | </ul> | 66 | </ul> |
| 52 | </div> | 67 | </div> |
| 53 | 68 | ||
| 54 | <!-- SEARCH INPUT --> | 69 | <!-- SEARCH INPUT --> |
| 55 | <div *ngIf="productos.length > 0" class="fade-in col-sm-10"> | 70 | <div *ngIf="productos.length > 0" class="fade-in col-sm-10"> |
| 56 | 71 | ||
| 57 | <div class="form-group row search"> | 72 | <div class="form-group row search"> |
| 58 | <div class="col-sm-10"> | 73 | <div class="col-sm-10"> |
| 59 | <span class="fa fa-search form-control-lg form-control-search pl-3"></span> | 74 | <span class="fa fa-search form-control-lg form-control-search pl-3"></span> |
| 60 | <input | 75 | <input |
| 61 | type="text" | 76 | type="text" |
| 62 | class="form-control form-control-lg shadow-sm rounded-pill px-5" | 77 | class="form-control form-control-lg shadow-sm rounded-pill px-5" |
| 63 | placeholder="Búsqueda productos" | 78 | placeholder="Búsqueda productos" |
| 64 | [(ngModel)]="searchTerm" | 79 | [(ngModel)]="searchTerm" |
| 65 | (ngModelChange)="filterItems()"> | 80 | (ngModelChange)="filterItems()"> |
| 66 | </div> | 81 | </div> |
| 67 | <!-- BOTON VOLVER --> | 82 | <!-- BOTON VOLVER --> |
| 68 | <div class="col-sm-2"> | 83 | <div class="col-sm-2"> |
| 69 | <button | 84 | <button |
| 70 | type="button" | 85 | type="button" |
| 71 | class="btn btn-light btn-lg shadow-sm" | 86 | class="btn btn-light btn-lg shadow-sm" |
| 72 | [routerLink]="['/inicio']"> | 87 | [routerLink]="['/inicio']"> |
| 73 | <span class="font-weight-normal h6">Volver </span> | 88 | <span class="font-weight-normal h6">Volver </span> |
| 74 | <i class="fa fa-undo text-warning" aria-hidden="true"></i> | 89 | <i class="fa fa-undo text-warning" aria-hidden="true"></i> |
| 75 | </button> | 90 | </button> |
| 76 | </div> | 91 | </div> |
| 77 | </div> | 92 | </div> |
| 78 | 93 | ||
| 79 | <!-- LISTA DE PRODUCTOS --> | 94 | <!-- LISTA DE PRODUCTOS --> |
| 80 | <div class="row align-items-start vh-70 overflow-scroll disable-user-select"> | 95 | <div class="row align-items-start vh-70 overflow-scroll disable-user-select"> |
| 81 | <div | 96 | <div |
| 82 | class="col-4 p-2" | 97 | class="col-4 p-2" |
| 83 | *ngFor="let producto of auxProductos"> | 98 | *ngFor="let producto of auxProductos"> |
| 84 | <div class="card-effect bg-white rounded-sm shadow border-0"> | 99 | <div class="card-effect bg-white rounded-sm shadow border-0"> |
| 85 | <img src="../../../assets/img/descarga.jpg" class="w-75 m-auto"> | 100 | <img src="../../../assets/img/descarga.jpg" class="w-75 m-auto"> |
| 86 | <div class="p-2"> | 101 | <div class="p-2"> |
| 87 | <p class="h6 text-left m-0">{{producto.DetArt}}</p> | 102 | <p class="h6 text-left m-0">{{producto.DetArt}}</p> |
| 88 | <div class="row justify-content-between m-0"> | 103 | <div class="row justify-content-between m-0"> |
| 89 | <div class="col-12 p-0"> | 104 | <div class="col-12 p-0"> |
| 90 | <div class="text-left"> | 105 | <div class="text-left"> |
| 91 | <p class="m-0 h6"><small>{{producto.DetArt}}</small></p> | 106 | <p class="m-0 h6"><small>{{producto.DetArt}}</small></p> |
| 92 | <p class="m-0 h6"><small>COD. {{producto.CodRub}}</small></p> | 107 | <p class="m-0 h6"><small>COD. {{producto.CodRub}}</small></p> |
| 93 | </div> | 108 | </div> |
| 94 | </div> | 109 | </div> |
| 95 | <div class="col-12 my-auto pt-2 pr-2 p-0"> | 110 | <div class="col-12 my-auto pt-2 pr-2 p-0"> |
| 96 | <p class="text-right m-0 h6">{{producto.PreVen | currency}}</p> | 111 | <p class="text-right m-0 h6">{{producto.PreVen | currency}}</p> |
| 97 | </div> | 112 | </div> |
| 98 | </div> | 113 | </div> |
| 99 | </div> | 114 | </div> |
| 100 | </div> | 115 | </div> |
| 101 | </div> | 116 | </div> |
| 102 | </div> | 117 | </div> |
| 103 | </div> | 118 | </div> |
| 104 | 119 | ||
| 105 | <!-- SPINNER --> | 120 | <!-- SPINNER --> |
| 106 | <div *ngIf="productos.length === 0 && showSpinner" class="col-sm-10 align-self-center"> | 121 | <div *ngIf="productos.length === 0 && showSpinner" class="col-sm-10 align-self-center"> |
| 107 | <div class="spinner-border spinner-lg text-secondary" role="status"></div> | 122 | <div class="spinner-border spinner-lg text-secondary" role="status"></div> |
| 108 | <span class="text-secondary m-2 h5">Cargando información.</span> | 123 | <span class="text-secondary m-2 h5">Cargando información.</span> |
| 109 | </div> | 124 | </div> |
| 110 | 125 | ||
| 111 | </div> | 126 | </div> |
| 112 | 127 | ||
| 113 | </div> | 128 | </div> |
| 114 | 129 | ||
| 115 | <!-- SIDEBAR --> | 130 | <!-- SIDEBAR --> |
| 116 | <app-sidebar class="col-3 col-md-2 vh-100 bg-dark text-white"></app-sidebar> | 131 | <app-sidebar class="col-3 col-md-2 vh-100 bg-dark text-white"></app-sidebar> |
| 117 | </div> | 132 | </div> |
| 118 | 133 |
src/app/components/busqueda-productos/busqueda-productos.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { ProductoService } from 'src/app/services/producto.service'; | 2 | import { ProductoService } from 'src/app/services/producto.service'; |
| 3 | import { Producto } from 'src/app/wrappers/producto'; | 3 | import { Producto } from 'src/app/wrappers/producto'; |
| 4 | 4 | ||
| 5 | @Component({ | 5 | @Component({ |
| 6 | selector: 'app-busqueda-productos', | 6 | selector: 'app-busqueda-productos', |
| 7 | templateUrl: './busqueda-productos.component.html', | 7 | templateUrl: './busqueda-productos.component.html', |
| 8 | styleUrls: ['./busqueda-productos.component.scss'] | 8 | styleUrls: ['./busqueda-productos.component.scss'] |
| 9 | }) | 9 | }) |
| 10 | export class BusquedaProductosComponent implements OnInit { | 10 | export class BusquedaProductosComponent implements OnInit { |
| 11 | 11 | ||
| 12 | productos: Producto[] = []; | 12 | productos: Producto[] = []; |
| 13 | auxProductos: Producto[] = []; | 13 | auxProductos: Producto[] = []; |
| 14 | searchTerm: string = ''; | 14 | searchTerm: string = ''; |
| 15 | showSpinner: boolean = true; | 15 | showSpinner: boolean = true; |
| 16 | categoria: Categorias = Categorias.todos; | ||
| 16 | 17 | ||
| 17 | constructor(private productoService: ProductoService) { } | 18 | constructor(private productoService: ProductoService) { } |
| 18 | 19 | ||
| 19 | ngOnInit() { | 20 | ngOnInit() { |
| 20 | 21 | ||
| 21 | this.productoService.getAll() | 22 | this.productoService.getAll() |
| 22 | .subscribe((data: Producto[]) => { | 23 | .subscribe((data: Producto[]) => { |
| 23 | 24 | ||
| 24 | this.auxProductos = this.productos = data; | 25 | this.auxProductos = this.productos = data; |
| 25 | }, (error) => { | 26 | }, (error) => { |
| 26 | this.showSpinner = false; | 27 | this.showSpinner = false; |
| 27 | console.error(error); | 28 | console.error(error); |
| 28 | }); | 29 | }); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | filterItems() { | 32 | filterItems() { |
| 32 | console.log(''); | 33 | console.log(''); |
| 33 | this.auxProductos = this.productos.filter(x => x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase())); | 34 | this.auxProductos = this.productos.filter(x => x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase())); |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | } | 37 | } |
| 38 | |||
| 39 | enum Categorias { | ||
| 40 | promosCombos = 1, | ||
| 41 | todos = 2, | ||
| 42 | bebidas = 3, | ||
| 43 | sandwicheria = 4, | ||
| 44 | panaderia = 5, | ||
| 45 | golosinas = 6, | ||
| 46 | tabaqueria = 7, | ||
| 47 | } | ||
| 37 | 48 |