Skip to content

Commit

Permalink
feat: select filter on fichier authors
Browse files Browse the repository at this point in the history
  • Loading branch information
69pmb committed Feb 4, 2024
1 parent 980f7c8 commit aa89027
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/app/list-fichier/list-fichier.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<div class="parent-filter filters">
<div>
<div class="filters">
<app-filter-input
<app-filter-select
placeholder="Chercher un auteur"
[control]="filters.controls.author"
></app-filter-input>
[options]="authors"
></app-filter-select>
<app-filter-input
placeholder="Chercher un nom"
[control]="filters.controls.name"
Expand Down
13 changes: 12 additions & 1 deletion src/app/list-fichier/list-fichier.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {catchError, skipWhile} from 'rxjs/operators';
import {MatPaginator, PageEvent} from '@angular/material/paginator';

import {ListDirective} from '../list/list.component';
import {Fichier, Composition, Sort, Field} from '@utils/model';
import {Fichier, Composition, Sort, Field, Dropdown} from '@utils/model';
import {DataService} from '@services/data.service';
import {UtilsService} from '@services/utils.service';
import {DexieService} from '@services/dexie.service';
Expand Down Expand Up @@ -64,6 +64,7 @@ export class ListFichierComponent
sortComposition?: Sort<Composition>;
expandedElement?: Fichier;
expandedColumn = 'compositions';
authors!: Dropdown[];
// Filters
filters = new FormGroup<{
author: FormControl<string>;
Expand Down Expand Up @@ -126,6 +127,16 @@ export class ListFichierComponent
.subscribe(list => {
this.dataList = this.sortList(list);
this.length = list.length;
this.authors = list
.map(l => [l.author ?? ''])
.reduce((acc, curr) => {
if (acc.every(a => !curr.includes(a))) {
acc.push(...curr);
}
return acc;
})
.sort()
.map(l => new Dropdown(l, l));
this.displayedData = Utils.paginate(
this.filter(this.dataList),
this.page
Expand Down

0 comments on commit aa89027

Please sign in to comment.