pagination: remove empty models
This commit is contained in:
@ -9,13 +9,15 @@ export function paginateModels(models) {
|
|||||||
let currentSize = 0
|
let currentSize = 0
|
||||||
let currentPage = []
|
let currentPage = []
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
currentSize += model.size
|
if (model.size > 0) { // skip empty models
|
||||||
if (currentSize > 3) {
|
currentSize += model.size
|
||||||
pages.push(currentPage)
|
if (currentSize > 3) {
|
||||||
currentPage = [model]
|
pages.push(currentPage)
|
||||||
currentSize = model.size
|
currentPage = [model]
|
||||||
} else {
|
currentSize = model.size
|
||||||
currentPage.push(model)
|
} else {
|
||||||
|
currentPage.push(model)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentPage.length > 0) {
|
if (currentPage.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user