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..0a2a444 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 @@
+
+
+
+ +
+
@@ -39,7 +45,7 @@ - + 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(); } diff --git a/src/main/webapp/app/shared/pipes/filter.ts b/src/main/webapp/app/shared/pipes/filter.ts new file mode 100644 index 0000000..3743369 --- /dev/null +++ b/src/main/webapp/app/shared/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())); + } +} 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 {}
{{ categoria.id }}