@@ -10,6 +10,7 @@ import * as d3 from 'd3';
1010import * as yaml from 'js-yaml' ;
1111import { Router , NavigationExtras } from '@angular/router' ;
1212import { MatChip } from '@angular/material/chips' ;
13+ import { from , single } from 'rxjs' ;
1314
1415export interface taskSchema {
1516 taskName : string ;
@@ -76,7 +77,7 @@ export class CircularHeatmapComponent implements OnInit {
7677
7778 this . teamList = this . YamlObject [ 'teams' ] ;
7879 this . teamGroups = this . YamlObject [ 'teamGroups' ] ;
79- this . teamVisible = this . teamList ;
80+ this . teamVisible = [ ... this . teamList ] ;
8081 } ) ;
8182 this . yaml . setURI ( './assets/YAML/generated/generated.yaml' ) ;
8283 // Function sets data
@@ -199,7 +200,7 @@ export class CircularHeatmapComponent implements OnInit {
199200 if ( chip . selected ) {
200201 this . selectedTeamChips = [ currChipValue ] ;
201202 if ( currChipValue == 'All' ) {
202- this . teamVisible = this . teamList ;
203+ this . teamVisible = [ ... this . teamList ] ;
203204 } else {
204205 this . teamVisible = [ ] ;
205206
@@ -229,7 +230,7 @@ export class CircularHeatmapComponent implements OnInit {
229230 toggleTeamSelection ( chip : MatChip ) {
230231 chip . toggleSelected ( ) ;
231232 let currChipValue = chip . value . replace ( / \s / g, '' ) ;
232- let visibilityUpdated = false ;
233+ let prevSelectedChip = this . selectedTeamChips ;
233234 if ( chip . selected ) {
234235 this . teamVisible . push ( currChipValue ) ;
235236 this . selectedTeamChips = [ ] ;
@@ -238,9 +239,10 @@ export class CircularHeatmapComponent implements OnInit {
238239 }
239240 console . log ( 'Selected Chips' , this . selectedTeamChips ) ;
240241 console . log ( 'Team Visible' , this . teamVisible ) ;
242+ console . log ( 'Team List' , this . teamList ) ;
241243 console . log ( 'All chips' , this . matChipsArray ) ;
242244 // Update heatmap based on selection
243- this . updateChips ( false ) ;
245+ this . updateChips ( prevSelectedChip ) ;
244246 this . reColorHeatmap ( ) ;
245247 }
246248
@@ -249,10 +251,24 @@ export class CircularHeatmapComponent implements OnInit {
249251
250252 setTimeout ( ( ) => {
251253 this . matChipsArray = this . chips . toArray ( ) ;
254+ this . updateChips ( true ) ;
252255 } , 100 ) ;
253256 }
254- updateChips ( fromTeamGroup : boolean ) {
255- console . log ( 'updating chips' ) ;
257+ updateChips ( fromTeamGroup : any ) {
258+ console . log ( 'updating chips' , fromTeamGroup ) ;
259+ // Re select chips
260+ this . matChipsArray . forEach ( chip => {
261+ let currChipValue = chip . value . replace ( / \s / g, '' ) ;
262+
263+ if ( this . teamVisible . includes ( currChipValue ) ) {
264+ console . log ( currChipValue ) ;
265+ chip . selected = true ;
266+ } else {
267+ if ( ! this . selectedTeamChips . includes ( currChipValue ) ) {
268+ chip . selected = false ;
269+ }
270+ }
271+ } ) ;
256272 }
257273 // Team Filter ENDS
258274
0 commit comments