Commit 788185d75f32d33f1c9b943a6ba4a4d006c1cbcb
1 parent
a4cb3a157e
Exists in
master
and in
1 other branch
Arreglo identacion.
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
src/app/components/busqueda-productos/busqueda-productos.component.ts
1 | import { Component, OnInit, Input, ViewChild, AfterViewInit } from '@angular/core'; | 1 | import { Component, OnInit, Input, ViewChild, AfterViewInit } 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 { SidebarComponent } from '../sidebar/sidebar.component'; | 5 | import { SidebarComponent } from '../sidebar/sidebar.component'; |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'app-busqueda-productos', | 8 | selector: 'app-busqueda-productos', |
9 | templateUrl: './busqueda-productos.component.html', | 9 | templateUrl: './busqueda-productos.component.html', |
10 | styleUrls: ['./busqueda-productos.component.scss'] | 10 | styleUrls: ['./busqueda-productos.component.scss'] |
11 | }) | 11 | }) |
12 | export class BusquedaProductosComponent implements OnInit { | 12 | export class BusquedaProductosComponent implements OnInit { |
13 | 13 | ||
14 | private productos: Producto[] = []; | 14 | private productos: Producto[] = []; |
15 | private auxProductos: Producto[] = []; | 15 | private auxProductos: Producto[] = []; |
16 | private searchTerm: string = ''; | 16 | private searchTerm: string = ''; |
17 | private showSpinner: boolean = true; | 17 | private showSpinner: boolean = true; |
18 | private categoria: Categorias = Categorias.todos; | 18 | private categoria: Categorias = Categorias.todos; |
19 | private apiUrl: string = appSettings.apiUrl; | 19 | private apiUrl: string = appSettings.apiUrl; |
20 | 20 | ||
21 | productosParaCarrito : Producto[] = []; | 21 | productosParaCarrito : Producto[] = []; |
22 | 22 | ||
23 | constructor(private productoService: ProductoService) { } | 23 | constructor(private productoService: ProductoService) { } |
24 | 24 | ||
25 | // ngAfterViewInit() { | 25 | // ngAfterViewInit() { |
26 | // this.sideBar.productos = []; | 26 | // this.sideBar.productos = []; |
27 | // } | 27 | // } |
28 | 28 | ||
29 | ngOnInit() { | 29 | ngOnInit() { |
30 | 30 | ||
31 | this.productoService.getAll() | 31 | this.productoService.getAll() |
32 | .subscribe((data: Producto[]) => { | 32 | .subscribe((data: Producto[]) => { |
33 | 33 | ||
34 | this.auxProductos = this.productos = data; | 34 | this.auxProductos = this.productos = data; |
35 | }, (error) => { | 35 | }, (error) => { |
36 | this.showSpinner = false; | 36 | this.showSpinner = false; |
37 | console.error(error); | 37 | console.error(error); |
38 | }); | 38 | }); |
39 | } | 39 | } |
40 | 40 | ||
41 | filterItems() { | 41 | filterItems() { |
42 | console.log(''); | 42 | this.auxProductos = this.productos.filter(x => { |
43 | this.auxProductos = this.productos.filter(x => x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase())); | 43 | return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) |
44 | }); | ||
44 | } | 45 | } |
45 | 46 | ||
46 | agregarAlCarrito(producto : Producto){ | 47 | agregarAlCarrito(producto: Producto) { |
47 | producto.cantidad = 1; | 48 | producto.cantidad = 1; |
48 | this.productosParaCarrito.push(producto); | 49 | this.productosParaCarrito.push(producto); |
49 | } | 50 | } |
50 | 51 | ||
51 | } | 52 | } |
52 | 53 | ||
53 | enum Categorias { | 54 | enum Categorias { |
54 | promosCombos = 1, | 55 | promosCombos = 1, |
55 | todos = 2, | 56 | todos = 2, |
56 | bebidas = 3, | 57 | bebidas = 3, |
57 | sandwicheria = 4, | 58 | sandwicheria = 4, |
58 | panaderia = 5, | 59 | panaderia = 5, |
59 | golosinas = 6, | 60 | golosinas = 6, |
60 | tabaqueria = 7, | 61 | tabaqueria = 7, |
61 | } | 62 | } |
62 | 63 |