-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WATcher's default view displays issues and pull requests based solely on their assignees. Grouping issues and pull requests based on their associated milestones may provide another useful view for the user. Let's implement the "Group by Milestone" feature.
- Loading branch information
1 parent
b226977
commit cd4614f
Showing
7 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/app/core/services/grouping/milestone-grouping-strategy.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { Issue } from '../../models/issue.model'; | ||
import { Milestone } from '../../models/milestone.model'; | ||
import { MilestoneService } from '../milestone.service'; | ||
import { GroupingStrategy } from './grouping-strategy.interface'; | ||
|
||
/** | ||
* A GroupingStrategy that groups issues/prs based on their milestones. | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class MilestoneGroupingStrategy implements GroupingStrategy { | ||
constructor(private milestoneService: MilestoneService) {} | ||
|
||
/** | ||
* Retrieves data for a milestone. | ||
*/ | ||
getDataForGroup(issues: Issue[], key: Milestone): Issue[] { | ||
return issues.filter((issue) => issue.milestone.equals(key)); | ||
} | ||
|
||
/** | ||
* Retrieves an Observable emitting milestones available for grouping issues. | ||
*/ | ||
getGroups(): Observable<Milestone[]> { | ||
return this.milestoneService.fetchMilestones().pipe( | ||
map((milestones) => { | ||
return this.milestoneService.parseMilestoneData(milestones); | ||
}) | ||
); | ||
} | ||
|
||
/** | ||
* Groups other than Default Milestone need to be shown on the | ||
* hidden group list if empty. | ||
*/ | ||
isInHiddenList(group: Milestone): boolean { | ||
return group !== Milestone.DefaultMilestone; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters