From e2b9bfa74f274afa7a6f8c000856663fed4b62a4 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 2 May 2016 08:46:30 +0200 Subject: [PATCH] Submissions pagination improvements --- .../Plugin/js/controllers/editor.data.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/Umbraco/Plugin/js/controllers/editor.data.js b/Source/Umbraco/Plugin/js/controllers/editor.data.js index de46008..542e2bc 100644 --- a/Source/Umbraco/Plugin/js/controllers/editor.data.js +++ b/Source/Umbraco/Plugin/js/controllers/editor.data.js @@ -96,8 +96,26 @@ row._createdDateLong = $filter("date")(row._createdDate, "yyyy-MM-dd HH:mm:ss"); }); + // make sure we don't end up with a gazillion pagination links if we have lots of submissions + var start, end; + var maxPages = 10; + if (data.totalPages > maxPages) { + start = page - maxPages / 2; + if (start < 1) { + start = 1; + } + end = start + maxPages; + if (end > data.totalPages) { + end = data.totalPages; + start = end - maxPages; + } + } + else { + start = 1; + end = data.totalPages; + } data.pages = []; - for (var i = 1; i <= data.totalPages; i++) { + for (var i = start; i <= end; i++) { data.pages.push(i); }