-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a filter to the team building dialog
- Loading branch information
Showing
12 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
frontend/src/app/services/pipes/not-in-list-filter.pipe.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,18 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
@Pipe({ | ||
name: 'notInListFilter' | ||
}) | ||
export class NotInListFilterPipe implements PipeTransform { | ||
|
||
transform(list: any[], filter: any): any[] { | ||
if(!list){ | ||
return []; | ||
} | ||
if(!filter){ | ||
return list; | ||
} | ||
return list.filter(it => it != filter); | ||
} | ||
|
||
} |
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
16 changes: 16 additions & 0 deletions
16
frontend/src/app/shared/search-box/search-box.component.html
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,16 @@ | ||
<button *ngIf="!searchBoxActive" type="button" mat-icon-button | ||
aria-label="Search" | ||
matTooltip="Search" | ||
(click)="searchBoxActive = true"> | ||
<mat-icon>search</mat-icon> | ||
</button> | ||
<mat-form-field *ngIf="searchBoxActive" style="display: flex; flex-direction: row; justify-content: space-between; align-items: center;"> | ||
<mat-icon matIconPrefix>search</mat-icon> | ||
<input matInput type="text" placeholder="Search" [(ngModel)]="filter" (ngModelChange)="onTextChanged()" /> | ||
<button type="button" matSuffix mat-icon-button | ||
aria-label="Clear and close." | ||
matTooltip="Clear and close." | ||
(click)="onFilterClear()"> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
</mat-form-field> |
Empty file.
27 changes: 27 additions & 0 deletions
27
frontend/src/app/shared/search-box/search-box.component.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,27 @@ | ||
import { Component, EventEmitter, OnInit, Output } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: 'app-search-box', | ||
templateUrl: './search-box.component.html', | ||
styleUrls: ['./search-box.component.scss'] | ||
}) | ||
export class SearchBoxComponent{ | ||
// Source: https://angular-htpgvx.stackblitz.io | ||
@Output() filterChanged = new EventEmitter<string>(); | ||
public searchBoxActive = false; | ||
filter: string; | ||
|
||
onFilterClear(){ | ||
this.filter = ''; | ||
this.searchBoxActive = false; | ||
this.filterChanged.emit(this.filter); | ||
} | ||
|
||
onTextChanged(){ | ||
this.filterChanged.emit(this.filter); | ||
} | ||
|
||
public clear(){ | ||
this.onFilterClear(); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
...src/app/template/template-builder/components/team-builder-dialog/user-list-filter.pipe.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,27 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { ApiUser } from "../../../../../../openapi"; | ||
|
||
/** | ||
* A pipe enabling the filtering of a list of [ApiUser]s based on their username. | ||
*/ | ||
@Pipe({ | ||
name: 'userListFilter' | ||
}) | ||
export class UserListFilterPipe implements PipeTransform { | ||
|
||
transform(list: ApiUser[], filter: string): ApiUser[] { | ||
if(!list){ | ||
// Catch no / empty list; | ||
return []; | ||
} | ||
if(!filter){ | ||
// Catch no / empty filter provided | ||
return list; | ||
}else{ | ||
return list.filter(user => { | ||
return user.username.toLowerCase().includes(filter.toLowerCase()) | ||
}); | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...emplate/template-builder/components/team-builder-dialog/user-list-in-other-filter.pipe.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,22 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { ApiUser } from "../../../../../../openapi"; | ||
|
||
/** | ||
* Simple filter which filters a list of [ApiUser]s based on whether they are present in another list. | ||
*/ | ||
@Pipe({ | ||
name: 'userListInOtherFilter' | ||
}) | ||
export class UserListInOtherFilterPipe implements PipeTransform { | ||
|
||
transform(list: ApiUser[], other: ApiUser[]): ApiUser[] { | ||
if(!list){ | ||
return []; | ||
} | ||
if(!other){ | ||
return list; | ||
} | ||
return list.filter(it => !other.includes(it)) | ||
} | ||
|
||
} |
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