From 4a0e6a2c813188ca2bb32b06f22d01e855269dea Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 10 Jul 2021 19:34:08 -0600 Subject: [PATCH 1/6] crear pipe para filtrado --- src/main/webapp/app/entities/pipes/filter.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/webapp/app/entities/pipes/filter.ts diff --git a/src/main/webapp/app/entities/pipes/filter.ts b/src/main/webapp/app/entities/pipes/filter.ts new file mode 100644 index 0000000..3743369 --- /dev/null +++ b/src/main/webapp/app/entities/pipes/filter.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform, Injectable } from '@angular/core'; + +@Pipe({ + name: 'filter', +}) +@Injectable() +export class FilterPipe implements PipeTransform { + transform(items: any[], field: string, value: string): any[] { + if (!items) { + return []; + } + if (!field || !value) { + return items; + } + + return items.filter(singleItem => singleItem[field].toLowerCase().includes(value.toLowerCase())); + } +} From 680ad90f7ccc02ef783416ec912b95c3fac06657 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 10 Jul 2021 19:40:41 -0600 Subject: [PATCH 2/6] colocar biblioteca de filtrar en directorio correcto --- src/main/webapp/app/{entities => shared}/pipes/filter.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/webapp/app/{entities => shared}/pipes/filter.ts (100%) diff --git a/src/main/webapp/app/entities/pipes/filter.ts b/src/main/webapp/app/shared/pipes/filter.ts similarity index 100% rename from src/main/webapp/app/entities/pipes/filter.ts rename to src/main/webapp/app/shared/pipes/filter.ts From 4ceff2b1f4ffc8f68f3ad5ca4f5939415a48e7f0 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 10 Jul 2021 20:19:28 -0600 Subject: [PATCH 3/6] importar filtro --- src/main/webapp/app/shared/shared.module.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/webapp/app/shared/shared.module.ts b/src/main/webapp/app/shared/shared.module.ts index 2262892..a433735 100644 --- a/src/main/webapp/app/shared/shared.module.ts +++ b/src/main/webapp/app/shared/shared.module.ts @@ -12,6 +12,7 @@ import { FormatMediumDatePipe } from './date/format-medium-date.pipe'; import { SortByDirective } from './sort/sort-by.directive'; import { SortDirective } from './sort/sort.directive'; import { ItemCountComponent } from './pagination/item-count.component'; +import { FilterPipe } from './pipes/filter'; @NgModule({ imports: [SharedLibsModule], @@ -27,6 +28,7 @@ import { ItemCountComponent } from './pagination/item-count.component'; SortByDirective, SortDirective, ItemCountComponent, + FilterPipe, ], exports: [ SharedLibsModule, @@ -41,6 +43,7 @@ import { ItemCountComponent } from './pagination/item-count.component'; SortByDirective, SortDirective, ItemCountComponent, + FilterPipe, ], }) export class SharedModule {} From 73fece59a2a45712a0c18dc57ae6f7a3abe91f01 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 10 Jul 2021 20:20:13 -0600 Subject: [PATCH 4/6] inicializar search string en listado de categorias --- .../app/entities/categoria/list/categoria.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.ts b/src/main/webapp/app/entities/categoria/list/categoria.component.ts index cb48c91..d0a9206 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.ts +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.ts @@ -13,8 +13,11 @@ import { CategoriaDeleteDialogComponent } from '../delete/categoria-delete-dialo export class CategoriaComponent implements OnInit { categorias?: ICategoria[]; isLoading = false; + public searchString: string; - constructor(protected categoriaService: CategoriaService, protected modalService: NgbModal) {} + constructor(protected categoriaService: CategoriaService, protected modalService: NgbModal) { + this.searchString = ''; + } loadAll(): void { this.isLoading = true; @@ -31,6 +34,7 @@ export class CategoriaComponent implements OnInit { } ngOnInit(): void { + this.searchString = ''; this.loadAll(); } From ecd96d6d0799ed6afb4442676769f2838154f83e Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 10 Jul 2021 20:22:54 -0600 Subject: [PATCH 5/6] agregar formulario para input de busqueda --- .../app/entities/categoria/list/categoria.component.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.html b/src/main/webapp/app/entities/categoria/list/categoria.component.html index a6ef61e..aca7319 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.html +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.html @@ -29,6 +29,12 @@
+
+
+
+ +
+
From 3fa3146b5deb15b63fc8e37024a05f1a59ab713e Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 10 Jul 2021 20:23:22 -0600 Subject: [PATCH 6/6] agregar pipe para filtrado de la tabla --- .../webapp/app/entities/categoria/list/categoria.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.html b/src/main/webapp/app/entities/categoria/list/categoria.component.html index aca7319..0a2a444 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.html +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.html @@ -45,7 +45,7 @@ - +
{{ categoria.id }}