Skip to content

Commit f2587c9

Browse files
committed
Team filter chip selection automated
1 parent 0109cf4 commit f2587c9

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as d3 from 'd3';
1010
import * as yaml from 'js-yaml';
1111
import { Router, NavigationExtras } from '@angular/router';
1212
import { MatChip } from '@angular/material/chips';
13+
import { from, single } from 'rxjs';
1314

1415
export 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

Comments
 (0)