update searchbar on supplier and stock
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit, output, signal, viewChild} from '@angular/core';
|
||||
import {Component, computed, inject, OnInit, output, signal, viewChild} from '@angular/core';
|
||||
import {NzTableComponent, NzThMeasureDirective} from "ng-zorro-antd/table";
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
@@ -45,6 +45,22 @@ export class StockTable implements OnInit {
|
||||
selectionChange = output<boolean>()
|
||||
currentPageData: GetProductDto[] = [];
|
||||
|
||||
private searchQuery = signal<string>('');
|
||||
|
||||
filteredProducts = computed(() => {
|
||||
const q = this.searchQuery().toLowerCase().trim();
|
||||
|
||||
if (!q) return this.products();
|
||||
|
||||
return this.products().filter(s => {
|
||||
const name = (s.name ?? '').toLowerCase();
|
||||
return name.includes(q);
|
||||
});
|
||||
});
|
||||
|
||||
applySearch(query: string) {
|
||||
this.searchQuery.set(query);
|
||||
}
|
||||
get hasSelection(): boolean {
|
||||
return this.setOfCheckedId.size > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user