@@ -38,7 +38,7 @@ export class MappingComponent implements OnInit {
3838 separatorKeysCodes : number [ ] = [ ENTER , COMMA ] ;
3939 chipCtrl = new FormControl ( '' ) ;
4040 filteredChips : Observable < string [ ] > ;
41- currentChip : string [ ] = [ 'Performed Activities' , 'Planned Activities' ] ;
41+ currentChip : string [ ] = [ ] ;
4242 allChips : string [ ] = [ 'Performed Activities' , 'Planned Activities' ] ;
4343
4444 @ViewChild ( 'chipInput' ) chipInput ! : ElementRef < HTMLInputElement > ;
@@ -97,10 +97,21 @@ export class MappingComponent implements OnInit {
9797 if ( index >= 0 ) {
9898 this . currentChip . splice ( index , 1 ) ;
9999 }
100+ this . changeTableBasedOnCurrentFilter ( )
100101 }
101102
102103 selected ( event : MatAutocompleteSelectedEvent ) : void {
103104 this . currentChip . push ( event . option . viewValue ) ;
105+ this . changeTableBasedOnCurrentFilter ( )
106+ }
107+
108+ private _filter ( value : string ) : string [ ] {
109+ const filterValue = value . toLowerCase ( ) ;
110+
111+ return this . allChips . filter ( chip => chip . toLowerCase ( ) . includes ( filterValue ) ) ;
112+ }
113+
114+ changeTableBasedOnCurrentFilter ( ) {
104115 if ( ( this . currentChip . length > 1 ) || ( this . currentChip . length == 0 ) ) { // both planned and performed actvities are selected
105116 this . dataSource . _data . next ( this . allMappingData ) ;
106117 }
@@ -118,10 +129,4 @@ export class MappingComponent implements OnInit {
118129 this . chipInput . nativeElement . value = '' ;
119130 this . chipCtrl . setValue ( null ) ;
120131 }
121-
122- private _filter ( value : string ) : string [ ] {
123- const filterValue = value . toLowerCase ( ) ;
124-
125- return this . allChips . filter ( chip => chip . toLowerCase ( ) . includes ( filterValue ) ) ;
126- }
127132}
0 commit comments