Skip to content

Commit 769b63a

Browse files
committed
fix(heatmap): resolve MDC chip selection and styling issues
1 parent b8b39d4 commit 769b63a

3 files changed

Lines changed: 56 additions & 56 deletions

File tree

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

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,31 @@ <h2>Nothing to show</h2>
2929
<div class="heatmapClass">
3030
<div id="chart" class="heatmapChart"></div>
3131
<div class="filter-container">
32-
<button class="filter-toggle" mat-button color="primary" (click)="toggleFilters()">
32+
<button class="filter-toggle" mat-icon-button color="primary" (click)="toggleFilters()">
3333
<mat-icon [class.hidden]="!showFilters">keyboard_arrow_up</mat-icon>
3434
<mat-icon [class.hidden]="showFilters">filter_alt</mat-icon>
3535
</button>
3636
<div class="team-filter" [class.hidden]="!showFilters">
37-
<mat-form-field class="team-chip-list">
38-
<mat-label>Team Group Filter</mat-label>
39-
<mat-chip-listbox selectable>
40-
<mat-chip-option
41-
*ngFor="let group of filtersTeamGroups | keyvalue : unsorted"
42-
(selectionChange)="toggleTeamGroupFilter($event)"
43-
[selected]="filtersTeamGroups[group.key]">
44-
{{ group.key }}
45-
</mat-chip-option>
46-
</mat-chip-listbox>
47-
</mat-form-field>
48-
<mat-form-field>
49-
<mat-label>Team Filter</mat-label>
50-
<mat-chip-listbox selectable multiple>
51-
<mat-chip-option
52-
*ngFor="let team of filtersTeams | keyvalue"
53-
(selectionChange)="toggleTeamFilter($event)"
54-
[value]="team.key"
55-
[selected]="team.value">
56-
{{ team.key }}
57-
</mat-chip-option>
58-
</mat-chip-listbox>
59-
</mat-form-field>
37+
<label class="filter-label">Team Group Filter</label>
38+
<mat-chip-listbox selectable>
39+
<mat-chip-option
40+
*ngFor="let group of filtersTeamGroups | keyvalue : unsorted"
41+
(selectionChange)="toggleTeamGroupFilter($event)"
42+
[selected]="filtersTeamGroups[group.key]">
43+
{{ group.key }}
44+
</mat-chip-option>
45+
</mat-chip-listbox>
46+
47+
<label class="filter-label">Team Filter</label>
48+
<mat-chip-listbox selectable multiple>
49+
<mat-chip-option
50+
*ngFor="let team of filtersTeams | keyvalue"
51+
(selectionChange)="toggleTeamFilter($event)"
52+
[value]="team.key"
53+
[selected]="team.value">
54+
{{ team.key }}
55+
</mat-chip-option>
56+
</mat-chip-listbox>
6057
</div>
6158
</div>
6259
<mat-card appearance="outlined" class="activity-card" *ngIf="showActivityCard">

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

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -219,49 +219,48 @@ export class CircularHeatmapComponent implements OnInit, OnDestroy {
219219
}
220220

221221
toggleTeamGroupFilter(event: MatChipSelectionChange) {
222-
let chip = event.source;
223-
let teamGroup = chip.value.trim();
224-
if (!chip.selected) {
225-
chip.toggleSelected();
226-
console.log(`${perfNow()}: Heat: Chip flip Group '${teamGroup}: ${chip.selected}`);
227-
228-
// Update the team selections based on the team group selection
229-
let selectedTeams: TeamName[] = [];
222+
if (!event?.source || event.source.value == null) return;
223+
if (!event.selected) return;
224+
225+
const teamGroup = event.source.value.trim();
226+
227+
setTimeout(() => {
228+
console.log(`${perfNow()}: Heat: Chip flip Group '${teamGroup}`);
229+
const selectedTeams: TeamName[] = [];
230230
Object.keys(this.filtersTeams).forEach(key => {
231231
this.filtersTeams[key] = this.teamGroups[teamGroup]?.includes(key) || false;
232-
if (this.filtersTeams[key]) {
233-
selectedTeams.push(key);
234-
}
235-
this.sectorService.setVisibleTeams(selectedTeams);
232+
if (this.filtersTeams[key]) selectedTeams.push(key);
236233
});
234+
this.sectorService.setVisibleTeams(selectedTeams);
237235
this.hasTeamsFilter = Object.values(this.filtersTeams).some(v => v === true);
238236
this.reColorHeatmap();
239-
} else {
240-
console.log(`${perfNow()}: Heat: Chip flip Group '${teamGroup}: already on`);
241-
}
237+
});
242238
}
243239

244240
toggleTeamFilter(event: MatChipSelectionChange) {
245-
let chip = event.source;
246-
chip.toggleSelected();
247-
this.filtersTeams[chip.value.trim()] = chip.selected;
248-
console.log(`${perfNow()}: Heat: Chip flip Team '${chip.value}: ${chip.selected}`);
241+
if (!event?.source || event.source.value == null) return;
249242

250-
this.hasTeamsFilter = Object.values(this.filtersTeams).some(v => v === true);
243+
const value = event.source.value.trim();
244+
const selected = event.selected;
251245

252-
let selectedTeams: string[] = Object.keys(this.filtersTeams).filter(
253-
key => this.filtersTeams[key]
254-
);
255-
this.sectorService.setVisibleTeams(selectedTeams);
246+
setTimeout(() => {
247+
this.filtersTeams[value] = selected;
248+
console.log(`${perfNow()}: Heat: Chip flip Team '${value}: ${selected}`);
256249

257-
// Update team group filter, if one matches selection
258-
Object.keys(this.teamGroups || {}).forEach(group => {
259-
let match: boolean = equalArray(selectedTeams, this.teamGroups[group]);
260-
this.filtersTeamGroups[group] = match;
261-
});
262-
this.filtersTeamGroups = this.filtersTeamGroups;
250+
this.hasTeamsFilter = Object.values(this.filtersTeams).some(v => v === true);
263251

264-
this.reColorHeatmap();
252+
const selectedTeams: string[] = Object.keys(this.filtersTeams).filter(
253+
key => this.filtersTeams[key]
254+
);
255+
this.sectorService.setVisibleTeams(selectedTeams);
256+
257+
Object.keys(this.teamGroups || {}).forEach(group => {
258+
this.filtersTeamGroups[group] = equalArray(selectedTeams, this.teamGroups[group]);
259+
});
260+
this.filtersTeamGroups = { ...this.filtersTeamGroups };
261+
262+
this.reColorHeatmap();
263+
});
265264
}
266265

267266
getTeamProgressState(activityUuid: string, teamName: string): string {

src/custom-theme.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ body.dark-theme {
309309
}
310310
}
311311

312-
312+
.mat-mdc-chip.mat-mdc-standard-chip.mat-mdc-chip-selected,
313+
.mat-mdc-chip.mat-mdc-standard-chip.mdc-evolution-chip--selected {
314+
background-color: var(--primary-color) !important;
315+
}
316+
313317
// Form fields and inputs
314318
.mat-mdc-form-field .mdc-notched-outline__leading,
315319
.mat-mdc-form-field .mdc-notched-outline__notch,

0 commit comments

Comments
 (0)