>From a98784d76f22e751f839c6bfbc2d32c62a06305d Mon Sep 17 00:00:00 2001
From: Andrew Wnuk <awnuk@redhat.com>
Date: Fri, 13 Jan 2012 16:23:38 -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  |   12 +++++++-----
 .../shared/webapps/ca/agent/ca/queryReq.template   |    8 +++++---
 .../shared/webapps/ca/ee/ca/queryCert.template     |   11 +++++++----
 .../shared/webapps/kra/agent/kra/queryReq.template |    8 +++++---
 4 files changed, 24 insertions(+), 15 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..8b7225dea2c95423e8c221bcca1ec2366c6bd7e1 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,14 @@ 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 > result.header.currentRecordCount) ||
+                    (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 +486,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..5fd602be7969540423d7881bc0d6525ad785d9dd 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
@@ -399,10 +399,12 @@ var seqNum=parseInt(result.recordSet[result.recordSet.length-1].seqNum) + 1;
 
 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 +431,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..92c7a5c17ac84bd371d59c1212289341aea061ed 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,14 @@ 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 > result.header.currentRecordCount) ||
+                    (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 +457,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..61685c667663ac904a86241b1995cc965f34757a 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
@@ -332,10 +332,12 @@ var seqNum=parseInt(result.recordSet[result.recordSet.length-1].seqNum) + 1;
 
 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 +364,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


