merge: use select control for role filter

This commit is contained in:
bisco
2026-06-03 23:10:17 +02:00
3 changed files with 50 additions and 6 deletions
+4 -6
View File
@@ -39,12 +39,10 @@
</label>
<label>
Role
<input
type="text"
[(ngModel)]="filters.role"
(ngModelChange)="onFilterChange()"
placeholder="3 and D, handler, rim runner"
>
<select [(ngModel)]="filters.role" (ngModelChange)="onFilterChange()">
<option value="">Any</option>
<option *ngFor="let role of roles" [value]="role">{{ role }}</option>
</select>
</label>
<label>
League
+18
View File
@@ -89,6 +89,24 @@ describe('AppComponent', () => {
assert.equal(calls, 1);
});
it('exposes role options and sends the selected role as a filter', () => {
let requestedRole = '';
const api = {
searchPlayers: (filters: { role: string }) => {
requestedRole = filters.role;
return of({ count: 0, results: [] });
},
} as unknown as PlayerApiService;
const component = new AppComponent(api);
assert.ok(component.roles.includes('3 and D wing'));
component.filters.role = '3 and D wing';
component.search();
assert.equal(requestedRole, '3 and D wing');
});
it('shows the loading placeholder only before results exist', () => {
const api = {
searchPlayers: () => of({ count: samplePlayers.length, results: samplePlayers }),
+28
View File
@@ -17,6 +17,34 @@ type SortKey = 'efficiency_rating' | 'points_per_game' | 'assists_per_game' | 'r
export class AppComponent {
readonly positions = ['PG', 'SG', 'SF', 'PF', 'C'];
readonly leagues = ['LBA', 'ACB', 'ABA', 'BBL', 'BSL', 'LNB', 'ISBL', 'NBL', 'NZNBL'];
readonly roles = [
'3 and D wing',
'Change-of-pace guard',
'Connector wing',
'Defensive playmaker',
'Drive and kick guard',
'Face-up forward',
'Glass cleaner',
'Low-post finisher',
'Movement shooter',
'Off-screen scorer',
'Paint anchor',
'Paint touch guard',
'Pick and roll creator',
'Pressure guard',
'Primary ball handler',
'Pull-up shooter',
'Rim protector',
'Roll man',
'Secondary creator',
'Short-roll passer',
'Slashing wing',
'Stretch four',
'Switch defender',
'Tempo guard',
'Transition wing',
'Vertical spacer',
];
readonly sortOptions: Array<{ key: SortKey; label: string }> = [
{ key: 'efficiency_rating', label: 'EFF' },
{ key: 'points_per_game', label: 'PPG' },