>From 14a54e5b27f8f452109cee9439050e2f4741abef Mon Sep 17 00:00:00 2001
From: Andrew Wnuk <awnuk@redhat.com>
Date: Mon, 16 Jan 2012 13:35:27 -0800
Subject: [PATCH] List paging on CA and DRM

This patch resolves multiple issues related to paging on request, certificate, and key lists.
It also provides consistent behavior across all lists.

Bug: 768138
---
 .../shared/webapps/ca/agent/ca/queryCert.template  |   11 ++++++-----
 .../shared/webapps/ca/agent/ca/queryReq.template   |   13 ++++++++-----
 .../shared/webapps/ca/ee/ca/queryCert.template     |   10 ++++++----
 .../shared/webapps/kra/agent/kra/queryReq.template |   13 ++++++++-----
 4 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryCert.template b/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryCert.template
index 4b2ff8e028f45908769b293d78ea17851626b1a0..32f30d22610f54f969f8524ddaeeaa0da8b55417 100644
--- a/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryCert.template
+++ b/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryCert.template
@@ -463,12 +463,13 @@ if (result.header.revokeAll != null) {
 if (result.header.queryFilterHash != null) {
     document.write(renderHidden("queryFilterHash"));
 }
-
-var disabled = (result.header.querySentinelDown == null) ? "disabled='true'" : "";
+var disabledDown = ((result.header.querySentinelDown == null) ||
+                    (result.fixed.maxCount+1 >= result.header.currentRecordCount)) ? "disabled='true'" : "";
+var disabledUp = (result.header.querySentinelUp != null && result.header.querySentinelUp <= 1) ? "disabled='true'" : "";
 
 document.write(
 "<button NAME=begin onClick='doNext(this)' VALUE='|<<' width='72'>|&lt;&lt;</button>\n"+
-"<button NAME=up onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
+"<button "+disabledUp+" NAME=up onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
 "<INPUT TYPE=hidden NAME=totalRecordCount VALUE='"+
 result.header.totalRecordCount+ "'>\n"+
 "<INPUT TYPE=hidden NAME=queryCertFilter VALUE='"+
@@ -484,8 +485,8 @@ result.header.direction+ "'>\n"+
 "<INPUT style='padding-left: 2px;' TYPE=text SIZE=16 NAME=maxCount VALUE='"+
 result.header.maxCount+ "'>\n"+
 
-"<button "+disabled+" NAME=down onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
-"<button "+disabled+" NAME=end onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
+"<button "+disabledDown+" NAME=down onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
+"<button NAME=end onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
 "</FORM>\n");
 }
 
diff --git a/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryReq.template b/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryReq.template
index 2a4279551af6b0c01438df1b1f82f2798a40105e..9fb63a1097a11124ea9cb02f3ea63fd767a583d3 100644
--- a/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryReq.template
+++ b/pki/dogtag/ca-ui/shared/webapps/ca/agent/ca/queryReq.template
@@ -397,12 +397,15 @@ var seqNum=parseInt(result.recordSet[result.recordSet.length-1].seqNum) + 1;
 //"<div align=center> \n"+
 "<FORM NAME='nextForm' METHOD='POST' ACTION=''>\n"+ renderHidden("op"));
 
-var disabled = "";
-//(result.header.seqNumFromDown== null) ? "disabled='true'" : "";
+var disabledDown = ((result.fixed.maxCount > result.header.currentRecordCount) ||
+                    (result.header.currentRecordCount == result.header.totalRecordCount)) ?
+                    "disabled='true'" : "";
+var disabledUp = (result.header.firstEntryOnPage != null &&
+                  result.header.firstEntryOnPage <= 1) ? "disabled='true'" : "";
 
 document.write(
 "<button NAME='begin' onClick='doNext(this)' VALUE='|<<' width='72'>|&lt;&lt;</button>\n"+
-"<button NAME='previous' onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
+"<button "+disabledUp+" NAME='previous' onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
 "<INPUT TYPE='hidden' NAME='totalRecordCount' VALUE='"+
 result.header.totalRecordCount+ "'>\n"+
 "<INPUT TYPE='hidden' NAME='op' VALUE='"+ "queryReq"+ "'>\n"+
@@ -429,8 +432,8 @@ result.header.totalRecordCount+ "'>\n"+
 
     document.write("<INPUT style='padding-left: 2px;' TYPE=text SIZE=16 NAME=maxCount VALUE='"+
 result.fixed.maxCount+ "'>\n"+
-"<button "+disabled+" NAME='next' onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
-"<button "+disabled+" NAME='end' onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
+"<button "+disabledDown+" NAME='next' onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
+"<button NAME='end' onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
 "</FORM>\n");
 }
 }
diff --git a/pki/dogtag/ca-ui/shared/webapps/ca/ee/ca/queryCert.template b/pki/dogtag/ca-ui/shared/webapps/ca/ee/ca/queryCert.template
index d115a1e1fa0dfcca563373bfe31758d9ae71bda6..a6dcf31f378f2b886c6b6d86c9789ba9cca46764 100644
--- a/pki/dogtag/ca-ui/shared/webapps/ca/ee/ca/queryCert.template
+++ b/pki/dogtag/ca-ui/shared/webapps/ca/ee/ca/queryCert.template
@@ -434,11 +434,13 @@ if (result.header.queryFilterHash != null) {
     document.write(renderHidden("queryFilterHash"));
 }
 
-var disabled = (result.header.querySentinelDown == null) ? "disabled='true'" : "";
+var disabledDown = ((result.header.querySentinelDown == null) ||
+                    (result.fixed.maxCount+1 >= result.header.currentRecordCount)) ? "disabled='true'" : "";
+var disabledUp = (result.header.querySentinelUp != null && result.header.querySentinelUp <= 1) ? "disabled='true'" : "";
 
 document.write(
 "<button NAME=begin onClick='doNext(this)' VALUE='|<<' width='72'>|&lt;&lt;</button>\n"+
-"<button NAME=up onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
+"<button "+disabledUp+" NAME=up onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
 "<INPUT TYPE=hidden NAME=totalRecordCount VALUE='"+
 result.header.totalRecordCount+ "'>\n"+
 "<INPUT TYPE=hidden NAME=queryCertFilter VALUE='"+
@@ -454,8 +456,8 @@ result.header.direction+ "'>\n"+
 "<INPUT style='padding-left: 2px;' TYPE=text SIZE=16 NAME=maxCount VALUE='"+
 result.header.maxCount+ "'>\n"+
 
-"<button "+disabled+" NAME=down onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
-"<button "+disabled+" NAME=end onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
+"<button "+disabledDown+" NAME=down onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
+"<button NAME=end onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
 "</FORM>\n");
 }
 
diff --git a/pki/dogtag/kra-ui/shared/webapps/kra/agent/kra/queryReq.template b/pki/dogtag/kra-ui/shared/webapps/kra/agent/kra/queryReq.template
index 2a7072346b972522a2a6495fe37578ed6c033363..47db884fae685812ae6f648ffb15ad485024f17a 100644
--- a/pki/dogtag/kra-ui/shared/webapps/kra/agent/kra/queryReq.template
+++ b/pki/dogtag/kra-ui/shared/webapps/kra/agent/kra/queryReq.template
@@ -330,12 +330,15 @@ var seqNum=parseInt(result.recordSet[result.recordSet.length-1].seqNum) + 1;
 //"<div align=center> \n"+
 "<FORM NAME='nextForm' METHOD='POST' ACTION=''>\n"+ renderHidden("op"));
 
-var disabled = "";
-//(result.header.seqNumFromDown== null) ? "disabled='true'" : "";
+var disabledDown = ((result.fixed.maxCount > result.header.currentRecordCount) ||
+                   (result.header.currentRecordCount == result.header.totalRecordCount)) ?
+                   "disabled='true'" : "";
+var disabledUp = (result.header.firstEntryOnPage != null &&
+                  result.header.firstEntryOnPage <= 1) ? "disabled='true'" : "";
 
 document.write(
 "<button NAME='begin' onClick='doNext(this)' VALUE='|<<' width='72'>|&lt;&lt;</button>\n"+
-"<button NAME='previous' onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
+"<button "+disabledUp+" NAME='previous' onClick='doNext(this)' VALUE='<' width='72'>&lt;</button>\n"+
 "<INPUT TYPE='hidden' NAME='totalRecordCount' VALUE='"+
 result.header.totalRecordCount+ "'>\n"+
 "<INPUT TYPE='hidden' NAME='op' VALUE='"+ "queryReq"+ "'>\n"+
@@ -362,8 +365,8 @@ result.header.totalRecordCount+ "'>\n"+
 
     document.write("<INPUT style='padding-left: 2px;' TYPE=text SIZE=16 NAME=maxCount VALUE='"+
 result.fixed.maxCount+ "'>\n"+
-"<button "+disabled+" NAME='next' onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
-"<button "+disabled+" NAME='end' onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
+"<button "+disabledDown+" NAME='next' onClick='doNext(this)' VALUE='>' width='72'>&gt;</button>\n"+
+"<button NAME='end' onClick='doNext(this)' VALUE='>>|' width='72'>&gt;&gt;|</button>\n"+
 "</FORM>\n");
 }
 
-- 
1.7.7.5

