1- import { Component , OnInit } from '@angular/core' ;
1+ import {
2+ Component ,
3+ OnInit ,
4+ ViewChildren ,
5+ QueryList ,
6+ ChangeDetectorRef ,
7+ } from '@angular/core' ;
28import { ymlService } from '../../service/yaml-parser/yaml-parser.service' ;
39import * as d3 from 'd3' ;
410import * as yaml from 'js-yaml' ;
@@ -42,7 +48,11 @@ export class CircularHeatmapComponent implements OnInit {
4248 taskDetails : any ;
4349 showOverlay : boolean ;
4450
45- constructor ( private yaml : ymlService , private router : Router ) {
51+ constructor (
52+ private yaml : ymlService ,
53+ private router : Router ,
54+ private changeDetector : ChangeDetectorRef
55+ ) {
4656 this . showOverlay = false ;
4757 }
4858
@@ -178,30 +188,29 @@ export class CircularHeatmapComponent implements OnInit {
178188
179189 // Team Filter BEGINS
180190
181- toggleTeamSelection ( chip : MatChip ) {
191+ @ViewChildren ( MatChip ) chips ! : QueryList < MatChip > ;
192+
193+ // Define an array to store MatChip components
194+ matChipsArray : MatChip [ ] = [ ] ;
195+ toggleTeamGroupSelection ( chip : MatChip ) {
182196 chip . toggleSelected ( ) ;
183197 let currChipValue = chip . value . replace ( / \s / g, '' ) ;
184- let visibilityUpdated = false ;
198+
185199 if ( chip . selected ) {
186200 this . selectedTeamChips = [ currChipValue ] ;
187201 if ( currChipValue == 'All' ) {
188202 this . teamVisible = this . teamList ;
189- console . log ( 'All' , this . teamList ) ;
190- visibilityUpdated = true ;
191203 } else {
192204 this . teamVisible = [ ] ;
193205
194206 (
195207 Object . keys ( this . teamGroups ) as ( keyof typeof this . teamGroups ) [ ]
196208 ) . forEach ( ( key , index ) => {
197209 if ( key === currChipValue ) {
210+ console . log ( 'group selected' ) ;
198211 this . teamVisible = this . teamGroups [ key ] ;
199- visibilityUpdated = true ;
200212 }
201213 } ) ;
202- if ( ! visibilityUpdated ) {
203- this . teamVisible . push ( currChipValue ) ;
204- }
205214 }
206215 } else {
207216 this . selectedTeamChips = this . selectedTeamChips . filter (
@@ -210,10 +219,41 @@ export class CircularHeatmapComponent implements OnInit {
210219 }
211220 console . log ( 'Selected Chips' , this . selectedTeamChips ) ;
212221 console . log ( 'Team Visible' , this . teamVisible ) ;
222+ console . log ( 'All chips' , this . matChipsArray ) ;
213223
214224 // Update heatmap based on selection
225+ this . updateChips ( true ) ;
215226 this . reColorHeatmap ( ) ;
216227 }
228+
229+ toggleTeamSelection ( chip : MatChip ) {
230+ chip . toggleSelected ( ) ;
231+ let currChipValue = chip . value . replace ( / \s / g, '' ) ;
232+ let visibilityUpdated = false ;
233+ if ( chip . selected ) {
234+ this . teamVisible . push ( currChipValue ) ;
235+ this . selectedTeamChips = [ ] ;
236+ } else {
237+ this . teamVisible = this . teamVisible . filter ( o => o !== currChipValue ) ;
238+ }
239+ console . log ( 'Selected Chips' , this . selectedTeamChips ) ;
240+ console . log ( 'Team Visible' , this . teamVisible ) ;
241+ console . log ( 'All chips' , this . matChipsArray ) ;
242+ // Update heatmap based on selection
243+ this . updateChips ( false ) ;
244+ this . reColorHeatmap ( ) ;
245+ }
246+
247+ ngAfterViewInit ( ) {
248+ // Putting all the chips inside an array
249+
250+ setTimeout ( ( ) => {
251+ this . matChipsArray = this . chips . toArray ( ) ;
252+ } , 100 ) ;
253+ }
254+ updateChips ( fromTeamGroup : boolean ) {
255+ console . log ( 'updating chips' ) ;
256+ }
217257 // Team Filter ENDS
218258
219259 teamCheckbox ( taskIndex : number , teamKey : any ) {
0 commit comments