-
-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathteam-selector.component.ts
More file actions
57 lines (47 loc) · 1.61 KB
/
team-selector.component.ts
File metadata and controls
57 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { TeamGroups } from '../../model/types';
import { SettingsService } from 'src/app/service/settings/settings.service';
@Component({
selector: 'app-team-selector',
templateUrl: './team-selector.component.html',
styleUrls: ['./team-selector.component.css'],
})
export class TeamSelectorComponent {
@Input() allTeams: string[] = [];
@Input() selectedTeams: string[] = [];
@Input() teamGroups: TeamGroups = {};
@Output() selectedTeamsChange = new EventEmitter<string[]>();
selectedGroupName: string = '';
constructor(public settings: SettingsService) {}
isTeamSelected(team: string): boolean {
return this.selectedTeams.includes(team);
}
toggleTeam(team: string): void {
const idx = this.selectedTeams.indexOf(team);
if (idx >= 0) {
this.selectedTeams.splice(idx, 1);
} else {
this.selectedTeams.push(team);
}
this.selectedGroupName = '';
this.selectedTeamsChange.emit([...this.selectedTeams]);
}
selectAllTeams(): void {
this.selectedTeams = [...this.allTeams];
this.selectedGroupName = '';
this.selectedTeamsChange.emit([...this.selectedTeams]);
}
deselectAllTeams(): void {
this.selectedTeams = [];
this.selectedGroupName = '';
this.selectedTeamsChange.emit([...this.selectedTeams]);
}
get groupNames(): string[] {
return Object.keys(this.teamGroups);
}
selectGroup(group: string): void {
this.selectedTeams = [...(this.teamGroups[group] || [])];
this.selectedGroupName = group;
this.selectedTeamsChange.emit([...this.selectedTeams]);
}
}