Skip to content

Commit

Permalink
fix: sorting list
Browse files Browse the repository at this point in the history
  • Loading branch information
69pmb committed Feb 21, 2024
1 parent a5fab13 commit 2d4df13
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/app/list-composition/list-composition.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ export class ListCompositionComponent
)
)
.subscribe(list => {
this.dataList = this.sortList(list);
this.dataList = list;
this.length = list.length;
this.displayedData = Utils.paginate(
this.filter(this.dataList),
this.sortList(this.filter(this.dataList)),
this.page
);
});
Expand Down Expand Up @@ -214,11 +214,6 @@ export class ListCompositionComponent
);
}

override onSort(): void {
super.onSort();
this.displayedData = this.sortList(this.displayedData);
}

sortList(list: Composition[]): Composition[] {
return Utils.sort(list, this.sort?.active, this.sort?.direction);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/list-fichier/list-fichier.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ListFichierComponent
)
)
.subscribe(list => {
this.dataList = this.sortList(list);
this.dataList = list;
this.length = list.length;
this.authors = list
.map(l => [l.author?.trim() ?? ''])
Expand All @@ -150,7 +150,7 @@ export class ListFichierComponent
.sort()
.map(l => new Dropdown(l, l));
this.displayedData = Utils.paginate(
this.filter(this.dataList),
this.sortList(this.filter(this.dataList)),
this.page
);
});
Expand Down
15 changes: 12 additions & 3 deletions src/app/list/list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,26 @@ export abstract class ListDirective<T> implements OnInit {
onSort(): void {
this.page = this.initPagination();
this.expandedElement = undefined;
this.displayedData = Utils.paginate(this.filter(this.dataList), this.page);
this.displayedData = Utils.paginate(
this.sortList(this.filter(this.dataList)),
this.page
);
}

onSearch(): void {
this.initPagination();
this.expandedElement = undefined;
this.displayedData = Utils.paginate(this.filter(this.dataList), this.page);
this.displayedData = Utils.paginate(
this.sortList(this.filter(this.dataList)),
this.page
);
}

onPaginateChange(): void {
this.expandedElement = undefined;
this.displayedData = Utils.paginate(this.filter(this.dataList), this.page);
this.displayedData = Utils.paginate(
this.sortList(this.filter(this.dataList)),
this.page
);
}
}

0 comments on commit 2d4df13

Please sign in to comment.