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