Skip to content

Commit 0109cf4

Browse files
committed
changes in chip selection
1 parent 59165ae commit 0109cf4

2 files changed

Lines changed: 53 additions & 13 deletions

File tree

src/app/component/circular-heatmap/circular-heatmap.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,21 @@ <h2>Nothing to show</h2>
193193
<mat-chip-list selectable>
194194
<mat-chip
195195
#c="matChip"
196-
(click)="toggleTeamSelection(c)"
196+
(click)="toggleTeamGroupSelection(c)"
197197
selected>
198198
All
199199
</mat-chip>
200200
<mat-chip
201201
#c="matChip"
202202
*ngFor="let group of teamGroups | keyvalue"
203-
(click)="toggleTeamSelection(c)">
203+
(click)="toggleTeamGroupSelection(c)">
204204
{{ group.key }}
205205
</mat-chip>
206206
</mat-chip-list>
207207
</mat-form-field>
208208
<mat-form-field>
209209
<mat-label>Team Filter</mat-label>
210-
<mat-chip-list selectable>
210+
<mat-chip-list selectable multiple>
211211
<mat-chip
212212
#c="matChip"
213213
*ngFor="let team of teamList"

src/app/component/circular-heatmap/circular-heatmap.component.ts

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import {
2+
Component,
3+
OnInit,
4+
ViewChildren,
5+
QueryList,
6+
ChangeDetectorRef,
7+
} from '@angular/core';
28
import { ymlService } from '../../service/yaml-parser/yaml-parser.service';
39
import * as d3 from 'd3';
410
import * 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

Comments
 (0)