Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter for 'Merged' #182

Merged
merged 9 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app/shared/filter-bar/filter-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
<div class="dropdown-filters">
<mat-form-field appearance="standard">
<mat-label>Status</mat-label>
<mat-select [(value)]="this.dropdownFilter.status" (selectionChange)="applyDropdownFilter()">
<mat-select [(value)]="this.dropdownFilter.status" (selectionChange)="updateTypePairing(); applyDropdownFilter()">
<mat-option value="all">All</mat-option>
<mat-option value="open">Open</mat-option>
<mat-option value="closed">Closed</mat-option>
<mat-option value="merged" *ngIf="isNotFilterIssue()">Merged</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="standard">
<mat-label>Type</mat-label>
<mat-select [(value)]="this.dropdownFilter.type" (selectionChange)="applyDropdownFilter()">
<mat-select [(value)]="this.dropdownFilter.type" (selectionChange)="updateStatusPairing(); applyDropdownFilter()">
<mat-option value="all">All</mat-option>
<mat-option value="issue">Issue</mat-option>
<mat-option value="pullrequest">Pull Request</mat-option>
Expand Down
25 changes: 25 additions & 0 deletions src/app/shared/filter-bar/filter-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,38 @@ export class FilterBarComponent implements OnInit, AfterViewInit, OnDestroy {
this.views$?.value?.forEach((v) => (v.retrieveFilterable().filter = filterValue));
}

/**
* Changes type to a valid, default value when an incompatible combination of type and status is encountered.
*/
updateTypePairing() {
if (this.dropdownFilter.status === 'merged') {
this.dropdownFilter.type = 'pullrequest';
}
}

/**
* Changes status to a valid, default value when an incompatible combination of type and status is encountered.
*/
updateStatusPairing() {
if (this.dropdownFilter.status === 'merged' && this.dropdownFilter.type === 'issue') {
this.dropdownFilter.status = 'all';
}
}

/**
* Signals to IssuesDataTable that a change has occurred in dropdown filter.
*/
applyDropdownFilter() {
this.views$?.value?.forEach((v) => (v.retrieveFilterable().dropdownFilter = this.dropdownFilter));
}

/**
* Checks if program is filtering by type issue.
*/
isNotFilterIssue() {
return this.dropdownFilter.type !== 'issue';
}

/**
* Fetch and initialize all information from repository to populate Issue Dashboard.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/issue-tables/dropdownfilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export function applyDropdownFilter(dropdownFilter: DropdownFilter): (a: Issue)
} else if (dropdownFilter.status === 'closed') {
// there is apparently also a status called 'all' based on github api
ret = ret && issue.state === 'CLOSED';
} else if (dropdownFilter.status === 'merged') {
ret = ret && issue.state === 'MERGED';
}

if (dropdownFilter.type === 'issue') {
Expand Down
Loading