Skip to content

Commit

Permalink
Fix issue with full-page navigation when show total is disabled
Browse files Browse the repository at this point in the history
and resolve page count on the last page issue
  • Loading branch information
KinyaElGrande committed Sep 1, 2023
1 parent 075dd78 commit 3b4c76b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Expand Up @@ -996,7 +996,7 @@ export default {
selectedRecordsDisplayText () {
const count = this.selectedAllRecords ? (this.options.showTotalCount ? this.pagination.count : undefined) : this.selected.length
const total = this.items.length
const total = this.filter.total
const key = this.selectedAllRecords ? 'selectedFromAllPages' : 'selected'
return this.$t(`recordList.${key}`, { count, total })
Expand Down
33 changes: 19 additions & 14 deletions server/compose/dalutils/records.go
Expand Up @@ -235,24 +235,29 @@ func generatePageNavigation(ctx context.Context, iter dal.Iterator, mod *types.M
}

// prep page
if (total % p.Limit) == 0 {
if total != 0 && (total%p.Limit) == 0 {
pageNavigation[lastNavPageNo].Count = p.Limit
page = filter.Page{
Page: uint(len(pageNavigation) + 1),
Count: 0,
Count: p.Limit,
Cursor: nextPage,
}
} else {
page.Count += 1
}

// push page when limit is matched with page item size
if p.Limit == 1 || pageNavigation[lastNavPageNo].Count == p.Limit {
pageNavigation = append(pageNavigation, &filter.Page{
Page: page.Page,
Count: page.Count,
Cursor: page.Cursor,
})
itemsCountUpToPage := uint(lastNavPageNo+1) * p.Limit
if p.Limit == 1 {
itemsCountUpToPage = uint(lastNavPageNo) * p.Limit
}

if itemsCountUpToPage != total {
// push page when limit is matched with page item size
if pageNavigation[lastNavPageNo].Count == p.Limit {
pageNavigation = append(pageNavigation, &filter.Page{
Page: page.Page,
Count: total % p.Limit,
Cursor: page.Cursor,
})
}
}

return
Expand All @@ -261,11 +266,11 @@ func generatePageNavigation(ctx context.Context, iter dal.Iterator, mod *types.M

if setLen == 0 {
return
} else {
first = set[0]
last = set[setLen-1]
}

first = set[0]
last = set[setLen-1]

// Limit
out.Limit = p.Limit

Expand Down

0 comments on commit 3b4c76b

Please sign in to comment.