Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 6bfc13b

Browse files
Merge pull request #667 from GSA/HWFilters
HW filters
2 parents 7429209 + 598843f commit 6bfc13b

File tree

9 files changed

+384
-385
lines changed

9 files changed

+384
-385
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"@angularclass/hmr-loader": "~3.0.2",
116116
"@code.gov/api-client": "^0.1.1",
117117
"@code.gov/code-gov-font": "0.6.3",
118-
"@code.gov/code-gov-style": "1.9.2",
118+
"@code.gov/code-gov-style": "1.9.5",
119119
"@ngx-meta/core": "^0.4.0-rc.2",
120120
"@types/jasminewd2": "^2.0.2",
121121
"angulartics2": "1.4.3",

src/app/components/base-filter-page/base-filter-page.component.ts

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class BaseFilterPageComponent {
4444
public languages = [];
4545
public hostElement: ElementRef;
4646
public filterTags = [];
47+
public types = [];
4748

4849
// added by children
4950
public sortOptions: String[];
@@ -53,14 +54,22 @@ export class BaseFilterPageComponent {
5354
* On removal from the DOM, unsubscribe from URL updates.
5455
*/
5556
public ngOnDestroy() {
56-
this.routeSubscription.unsubscribe();
57+
if (this.routeSubscription) {
58+
this.routeSubscription.unsubscribe();
59+
}
5760
}
5861

5962
public getFilterBoxValues(title) {
6063
try {
61-
return this.hostElement.nativeElement.querySelector(`filter-box[title='${title}']`).values;
64+
const element = this.hostElement.nativeElement.querySelector(`filter-box[title='${title}']`);
65+
if (element) {
66+
return element.values;
67+
} else {
68+
return [];
69+
}
6270
} catch (error) {
63-
console.error(`getFilterBoxValues caught the following error with ${title}`, error);
71+
console.warn(`getFilterBoxValues caught the following error with ${title}`, error);
72+
return [];
6473
}
6574
}
6675

@@ -74,6 +83,16 @@ export class BaseFilterPageComponent {
7483
}
7584
}
7685

86+
public filterType(result) {
87+
const selectedTypes = this.getFilterBoxValues('Type');
88+
89+
if (selectedTypes.length === 0) {
90+
return true;
91+
} else {
92+
return selectedTypes.indexOf(result.type) > -1;
93+
}
94+
}
95+
7796
public filterOrgType(result) {
7897
const orgTypes = this.getFilterBoxValues('Organization Type');
7998
if (orgTypes.length === 0) {
@@ -92,6 +111,24 @@ export class BaseFilterPageComponent {
92111
}
93112
}
94113

114+
public filterSkillLevel(result) {
115+
const names = this.getFilterBoxValues('Skill Level');
116+
if (names.length === 0) {
117+
return true;
118+
} else if (names.length > 0) {
119+
return names.indexOf(result.skill) > -1;
120+
}
121+
}
122+
123+
public filterTimeRequired(result) {
124+
const names = this.getFilterBoxValues('Time Required');
125+
if (names.length === 0) {
126+
return true;
127+
} else if (names.length > 0) {
128+
return names.indexOf(result.effort) > -1;
129+
}
130+
}
131+
95132
public filterLanguages(result) {
96133
const selectedLangs = this.getFilterBoxValues('Language');
97134

@@ -130,6 +167,9 @@ export class BaseFilterPageComponent {
130167
.filter(this.filterLicenses.bind(this))
131168
.filter(this.filterUsageType.bind(this))
132169
// .filter(this.filterOrgType.bind(this))
170+
.filter(this.filterType.bind(this))
171+
.filter(this.filterSkillLevel.bind(this))
172+
.filter(this.filterTimeRequired.bind(this))
133173
.filter(this.filterFederalAgency.bind(this));
134174
}
135175

@@ -183,6 +223,16 @@ export class BaseFilterPageComponent {
183223
.sort((a, b) => a.name < b.name ? -1 : 1);
184224
}
185225

226+
public setTypes() {
227+
let types = new Set();
228+
this.results.forEach(result => {
229+
if (result.type) {
230+
types.add(result.type);
231+
}
232+
});
233+
this.types = Array.from(types).sort();
234+
}
235+
186236
public onFilterBoxChange(event) {
187237
this.filterResults();
188238

src/app/components/help-wanted/card/help-wanted-card.template.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
<h3 class="card-title"><a [href]="item.issueURL ? item.issueURL : item.projectURL" target="_blank">{{ item.title }}</a></h3>
33
<p class="card-description">{{ item.description | truncate : 250}}</p>
44

5-
<dl *ngIf="!mobile">
5+
<dl class="show-w-gt-900">
66

77
<!-- <div *ngIf="item.projectURL">
88
<dt>Project Name: </dt>
99
<dd><a [href]="item.projectURL" *ngIf="item.projectURL" target="_blank">project name</a></dd>
1010
</div> -->
1111

12-
<div *ngIf="item?.agency_id">
13-
<dt>Agency:
14-
<dd><a [routerLink]="['/browse-projects']" [queryParams]="{agencies:item?.agency_id}">{{item?.agency_id}}</a></dd>
12+
<div *ngIf="item?.agency?.acronym">
13+
<dt>Agency:
14+
<dd><a [routerLink]="['/browse-projects']" [queryParams]="{agencies:item?.agency?.acronym}">{{item?.agency?.acronym}}</a></dd>
1515
</div>
1616

17-
<div *ngIf="item?.updated">
18-
<dt>Last updated:
19-
<dd>{{item?.updated | date: "MMM d 'at' h':'mm a"}}</dd>
17+
<div *ngIf="item?.date?.lastModified">
18+
<dt>Last updated:
19+
<dd>{{item?.date?.lastModified | date: "MMM d yyyy 'at' h':'mm a"}}</dd>
2020
</div>
2121

2222
<hr>
@@ -27,9 +27,9 @@ <h3 class="card-title"><a [href]="item.issueURL ? item.issueURL : item.projectUR
2727
</div>
2828

2929
<div *ngIf="item.type">
30-
<dt>Type:</dt>
31-
<dd>{{ item.type | capitalize }}</dd>
32-
</div>
30+
<dt>Type:</dt>
31+
<dd>{{ item.type | capitalize }}</dd>
32+
</div>
3333

3434
<div *ngIf="item.skill">
3535
<dt>Skill Level:</dt>

0 commit comments

Comments
 (0)