Skip to content

Commit

Permalink
fix: pagination of static system provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Tethik committed Oct 18, 2023
1 parent 18dbbdf commit 83d709d
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions config/providers/static/StaticSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,36 @@ export class StaticSystemProvider implements SystemProvider {
switch (input.filter) {
// Filters by team
case SystemListFilter.Team:
result.systems = this.systems
.filter((s) => s.owners.map((o) => o.id).includes(input.opts.teamId))
.slice(
pagination.page * pagination.pageSize,
(pagination.page + 1) * pagination.pageSize
);
result.total = result.systems.length;
result.systems = this.systems.filter((s) =>
s.owners.map((o) => o.id).includes(input.opts.teamId)
);
break;

// Filters by a list of system ids
case SystemListFilter.Batch:
result.systems = input.opts.ids
.map((id) => this.systemMap.get(id))
.filter((s) => !!s) as System[];
result.total = result.systems.length;
break;

// Filter by system name
case SystemListFilter.Search:
const searchText = input.opts.search.toLowerCase();
result.systems = this.systems
.filter(
(s) =>
s.shortName.toLowerCase().includes(searchText) ||
s.displayName.toLowerCase().includes(searchText) ||
s.id.toLowerCase().includes(searchText)
)
.slice(
pagination.page * pagination.pageSize,
(pagination.page + 1) * pagination.pageSize
);
result.total = result.systems.length;
result.systems = this.systems.filter(
(s) =>
s.shortName.toLowerCase().includes(searchText) ||
s.displayName.toLowerCase().includes(searchText) ||
s.id.toLowerCase().includes(searchText)
);
break;
}

result.total = result.systems.length;
result.systems = result.systems.slice(
pagination.page * pagination.pageSize,
(pagination.page + 1) * pagination.pageSize
);

return result;
}
}

0 comments on commit 83d709d

Please sign in to comment.