From d15a64243eb3137c484bc0414683d45210751b07 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Sat, 18 May 2019 10:39:29 -0700 Subject: [PATCH] pagination: remove empty models --- cateditor/src/pagination.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cateditor/src/pagination.js b/cateditor/src/pagination.js index 89f6c8d..933563f 100644 --- a/cateditor/src/pagination.js +++ b/cateditor/src/pagination.js @@ -9,13 +9,15 @@ export function paginateModels(models) { let currentSize = 0 let currentPage = [] for (let model of models) { - currentSize += model.size - if (currentSize > 3) { - pages.push(currentPage) - currentPage = [model] - currentSize = model.size - } else { - currentPage.push(model) + if (model.size > 0) { // skip empty models + currentSize += model.size + if (currentSize > 3) { + pages.push(currentPage) + currentPage = [model] + currentSize = model.size + } else { + currentPage.push(model) + } } } if (currentPage.length > 0) {