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