From 5dae57732b18f677a3403fc9ccfd36c24ba27abd Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Wed, 7 Aug 2019 11:25:56 +0300 Subject: [PATCH] feature(identity): add debounce event modifier to search input --- .../lib/components/roles/roles.component.html | 2 +- .../lib/components/roles/roles.component.ts | 30 ++++++++----------- .../lib/components/users/users.component.html | 2 +- .../lib/components/users/users.component.ts | 18 +++++------ 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html index af162133da..546a768006 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html @@ -18,7 +18,7 @@ type="search" class="form-control form-control-sm" [placeholder]="'AbpUi::PagerSearch' | abpLocalization" - (input)="search$.next($event.target.value)" + (input.debounce)="onSearch($event.target.value)" /> ; @@ -42,18 +42,14 @@ export class RolesComponent implements OnInit { loading: boolean = false; - search$ = new Subject(); - @ViewChild('modalContent', { static: false }) modalContent: TemplateRef; constructor(private confirmationService: ConfirmationService, private fb: FormBuilder, private store: Store) {} - ngOnInit() { - this.search$.pipe(debounceTime(300)).subscribe(value => { - this.pageQuery.filter = value; - this.get(); - }); + onSearch(value) { + this.pageQuery.filter = value; + this.get(); } createForm() { diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html index 9d5aa0a9f0..03f5dcb605 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html @@ -24,7 +24,7 @@ type="search" class="form-control form-control-sm" [placeholder]="'AbpUi::PagerSearch' | abpLocalization" - (input)="search$.next($event.target.value)" + (input.debounce)="onSearch($event.target.value)" /> ; @@ -50,8 +50,6 @@ export class UsersComponent implements OnInit { loading: boolean = false; - search$ = new Subject(); - trackByFn: TrackByFunction = (index, item) => Object.keys(item)[0] || index; get roleGroups(): FormGroup[] { @@ -60,11 +58,9 @@ export class UsersComponent implements OnInit { constructor(private confirmationService: ConfirmationService, private fb: FormBuilder, private store: Store) {} - ngOnInit() { - this.search$.pipe(debounceTime(300)).subscribe(value => { - this.pageQuery.filter = value; - this.get(); - }); + onSearch(value) { + this.pageQuery.filter = value; + this.get(); } buildForm() {