-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tobias.wright
committed
Jun 9, 2023
1 parent
6f59d8f
commit 948955f
Showing
7 changed files
with
47 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
|
||
<div style="margin-bottom: 20px;" *ngFor ="let item of list"> | ||
<input class="form-control form-control-lg" type="text" placeholder="Search causes" aria-label=".form-control-lg example" [(ngModel)]="filterBy"> | ||
|
||
<div style="margin-bottom: 20px;" *ngFor ="let item of list | filter: filterBy:'cause'"> | ||
<app-swatch [colorData]="item.colorData"></app-swatch> | ||
<app-color-card [cause]="item.cause" [displayName]="item.colorData.displayName"></app-color-card> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { FilterPipe } from './filter.pipe'; | ||
|
||
describe('FilterPipe', () => { | ||
it('create an instance', () => { | ||
const pipe = new FilterPipe(); | ||
expect(pipe).toBeTruthy(); | ||
}); | ||
}); |
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,28 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
@Pipe({ | ||
name: 'filter' | ||
}) | ||
export class FilterPipe implements PipeTransform { | ||
|
||
transform(value: any[], filterString: string, property: string) { | ||
|
||
if (value.length === 0 || !filterString) { | ||
return value; | ||
} | ||
|
||
|
||
|
||
let filteredCause: any[] = []; | ||
for (let item of value) { | ||
if (item[property].toLowerCase().includes(filterString.toLowerCase())) { | ||
filteredCause.push(item); | ||
} | ||
} | ||
|
||
console.log(filteredCause) | ||
return filteredCause; | ||
// return null; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1 +0,0 @@ | ||
<input class="form-control form-control-lg" type="text" placeholder="Search causes" aria-label=".form-control-lg example"> | ||
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