Commit cd84daae1920b98850d92afb75f992099b95524c
1 parent
0a9a4e91bf
Exists in
master
and in
1 other branch
Agregada logica para manejar el paginador
Showing
1 changed file
with
18 additions
and
7 deletions
Show diff stats
src/app/components/amb-imagenes/amb-imagenes.component.ts
| ... | ... | @@ -16,18 +16,17 @@ export class AmbImagenesComponent implements OnInit { |
| 16 | 16 | articulos: Producto[] = []; |
| 17 | 17 | private auxProductos: Producto[] = []; |
| 18 | 18 | private searchTerm: string = ''; |
| 19 | + private paginationData: any; | |
| 19 | 20 | |
| 20 | 21 | constructor(private productoService: ProductoService, private http: HttpClient) { } |
| 21 | 22 | |
| 22 | 23 | ngOnInit() { |
| 23 | 24 | |
| 24 | - this.productoService.getAll().subscribe((productos: Producto[]) => { | |
| 25 | - this.articulos = productos; | |
| 26 | - this.filterItems(); | |
| 27 | - }); | |
| 28 | - } | |
| 25 | + this.productoService.getAllWithPaginator() | |
| 26 | + .subscribe((res) => { | |
| 29 | 27 | |
| 30 | - this.articulos = productos; | |
| 28 | + this.articulos = res.data; | |
| 29 | + this.paginationData = res.pagination; | |
| 31 | 30 | this.filterItems(); |
| 32 | 31 | }, error => console.error(error)); |
| 33 | 32 | } |
| ... | ... | @@ -60,7 +59,9 @@ export class AmbImagenesComponent implements OnInit { |
| 60 | 59 | filterItems() { |
| 61 | 60 | |
| 62 | 61 | this.auxProductos = this.articulos.filter(x => { |
| 63 | - return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) | |
| 62 | + return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) || | |
| 63 | + x.CodArt.toString().includes(this.searchTerm.toLowerCase()) || | |
| 64 | + x.CodSec.toString().includes(this.searchTerm.toLowerCase()); | |
| 64 | 65 | }); |
| 65 | 66 | } |
| 66 | 67 | |
| ... | ... | @@ -104,4 +105,14 @@ export class AmbImagenesComponent implements OnInit { |
| 104 | 105 | }, error => console.error(error)); |
| 105 | 106 | } |
| 106 | 107 | |
| 108 | + pageChanged(event: any): void { | |
| 109 | + this.productoService.getAllWithPaginator(event.page) | |
| 110 | + .subscribe((res) => { | |
| 111 | + | |
| 112 | + this.articulos = res.data; | |
| 113 | + this.paginationData = res.pagination; | |
| 114 | + this.filterItems(); | |
| 115 | + }, error => console.error(error)); | |
| 116 | + } | |
| 117 | + | |
| 107 | 118 | } |