1- import { Component , OnInit , ViewChild } from '@angular/core' ;
1+ import { Component , OnDestroy , OnInit , ViewChild } from '@angular/core' ;
2+ import { Subject } from 'rxjs' ;
3+ import { debounceTime } from 'rxjs/operators' ;
24import { ApplicationPages } from 'src/app/common/enums' ;
35import { CommonDictionaryModel } from 'src/app/common/models/common' ;
46import { TemplateDto } from 'src/app/common/models/dto' ;
@@ -12,7 +14,7 @@ import {EFormService, EFormTagService} from 'src/app/common/services/eform';
1214 templateUrl : './eforms-page.component.html' ,
1315 styleUrls : [ './eforms-page.component.scss' ]
1416} )
15- export class EformsPageComponent implements OnInit {
17+ export class EformsPageComponent implements OnInit , OnDestroy {
1618
1719 @ViewChild ( 'modalNewEform' ) newEformModal ;
1820 @ViewChild ( 'modalCasesColumns' ) modalCasesColumnsModal ;
@@ -21,6 +23,8 @@ export class EformsPageComponent implements OnInit {
2123 @ViewChild ( 'modalRemoveEform' ) modalRemoveEform ;
2224 @ViewChild ( 'modalUploadZip' ) modalUploadZip ;
2325
26+ searchSubject = new Subject ( ) ;
27+
2428 spinnerStatus = false ;
2529 localPageSettings : PageSettingsModel = new PageSettingsModel ( ) ;
2630 templateRequestModel : TemplateRequestModel = new TemplateRequestModel ;
@@ -38,12 +42,22 @@ export class EformsPageComponent implements OnInit {
3842 private userSettingsService : UserSettingsService ,
3943 private eFormTagService : EFormTagService
4044 ) {
45+ this . searchSubject . pipe (
46+ debounceTime ( 500 )
47+ ) . subscribe ( val => {
48+ this . templateRequestModel . nameFilter = val . toString ( ) ;
49+ this . loadAllTemplates ( ) ;
50+ } ) ;
4151 }
4252
4353 ngOnInit ( ) {
4454 this . getLocalPageSettings ( ) ;
4555 }
4656
57+ ngOnDestroy ( ) {
58+ this . searchSubject . unsubscribe ( ) ;
59+ }
60+
4761 getLocalPageSettings ( ) {
4862 this . localPageSettings = this . userSettingsService . getLocalPageSettings
4963 ( 'pagesSettings' , ApplicationPages [ ApplicationPages . Eforms ] )
@@ -121,8 +135,7 @@ export class EformsPageComponent implements OnInit {
121135 }
122136
123137 onLabelInputChanged ( label : string ) {
124- this . templateRequestModel . nameFilter = label ;
125- this . loadAllTemplates ( ) ;
138+ this . searchSubject . next ( label ) ;
126139 }
127140
128141 sortTable ( sort : string ) {
0 commit comments