Skip to content

Commit

Permalink
Work on jump to page control
Browse files Browse the repository at this point in the history
  • Loading branch information
ianibo committed Jun 16, 2016
1 parent 8833011 commit 8198479
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 55 deletions.
8 changes: 4 additions & 4 deletions server/gokb/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#Grails Metadata file
#Thu Jun 16 11:43:32 BST 2016
#Thu Jun 16 16:17:24 BST 2016
app.buildDate=Jun 16, 2016
app.buildNumber=2647
app.buildProfile=production
app.buildNumber=2656
app.buildProfile=development
app.grails.version=2.4.5
app.name=gokb
app.servlet.version=2.5
app.version=7.0.4
extension.build.date=1466073811838
extension.build.date=1466090243620
extension.build.tag=TEST_CLIENT_5.1-beta7
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class SearchController {

result.max = params.max ? Integer.parseInt(params.max) : ( user.defaultPageSize ?: 10 );
result.offset = params.offset ? Integer.parseInt(params.offset) : 0;

if ( params.jumpToPage ) {
result.offset = ( ( params.int('jumpToPage') - 1 ) * result.max )
}

result.hide = params.list("hide") ?: []

Expand Down Expand Up @@ -143,6 +147,9 @@ class SearchController {
}
}

result.withoutJump = params.clone()
result.withoutJump.remove('jumpToPage');

// log.debug("leaving SearchController::index...");
log.debug("Search completed after ${System.currentTimeMillis() - start_time}");

Expand Down
91 changes: 46 additions & 45 deletions server/gokb/grails-app/views/search/_pagination.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,51 @@
<g:set var="s_controller" value="${s_controller?:'search'}"/>

<g:set var="custom_offset" value="${offset_param?:'offset'}"/>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<span class="navbar-brand">
Showing records ${offset.toInteger() +1} to ${lasthit.toInteger() as int} of
${reccount.toInteger() as int}
</span>
</div>
<ul class="nav navbar-nav navbar-right">
<g:if test="${ !request.isAjax() }">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<span class="navbar-text">
Showing records ${offset.toInteger() +1} to ${lasthit.toInteger() as int} of
${reccount.toInteger() as int}
</span>
</div>
<ul class="nav navbar-nav navbar-right">
<g:if test="${ !request.isAjax() }">

<!-- see grails-app/assets/javascripts/gokb/action-forms.js for code relating to bulk actions -->
<g:if test="${!hideActions}">
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown">Actions <b class="caret"></b></a>
<ul class="dropdown-menu actions"></ul>
</li>
<li class="divider-vertical"></li>
</g:if>
<li> Page ${page} of ${page_max} </li>
</g:if>
<g:if test="${ page == 1 }">
<li class='disabled'><a class='disabled' href='#'><i
class="glyphicon glyphicon-chevron-left"></i></a></li>
</g:if>
<g:else>
<li><g:link title="Previous Page" controller="${s_controller}"
action="${s_action}"
params="${params+["${custom_offset}":(offset.toInteger() - max.toInteger()),det:null]}">
<i class="glyphicon glyphicon-chevron-left"></i>
</g:link></li>
</g:else>
<g:if test="${ page == page_max }">
<li class='disabled'><a href='#'><i
class="glyphicon glyphicon-chevron-right"></i></a></li>
</g:if>
<g:else>
<li><g:link title="Next Page" controller="${s_controller}"
action="${s_action}"
params="${params+["${custom_offset}":(offset.toInteger() + max.toInteger()),det:null]}">
<i class="glyphicon glyphicon-chevron-right"></i>
</g:link></li>
</g:else>
</ul>
</div>
</nav>
<!-- see grails-app/assets/javascripts/gokb/action-forms.js for code relating to bulk actions -->
<g:if test="${!hideActions}">
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Actions <b class="caret"></b></a>
<ul class="dropdown-menu actions"></ul>
</li>
<li class="divider-vertical"></li>
</g:if>

<li><span class="navbar-text" style="white-space: nowrap; display:inline-block;"><g:form controller="${s_controller}" action="${s_action}" params="${withoutJump}" method="post">Page <input type="text" name="jumpToPage" size="5" value="${page}" style="color:#000000;" /> of ${page_max}</g:form></span></li>
</g:if>

<g:if test="${ page == 1 }">
<li class='disabled'><a class='disabled' href='#'><i
class="glyphicon glyphicon-chevron-left"></i></a></li>
</g:if>
<g:else>
<li><g:link title="Previous Page" controller="${s_controller}"
action="${s_action}"
params="${params+["${custom_offset}":(offset.toInteger() - max.toInteger()),det:null]}">
<i class="glyphicon glyphicon-chevron-left"></i>
</g:link></li>
</g:else>
<g:if test="${ page == page_max }">
<li class='disabled'><a href='#'><i
class="glyphicon glyphicon-chevron-right"></i></a></li>
</g:if>
<g:else>
<li><g:link title="Next Page" controller="${s_controller}"
action="${s_action}"
params="${params+["${custom_offset}":(offset.toInteger() + max.toInteger()),det:null]}">
<i class="glyphicon glyphicon-chevron-right"></i>
</g:link></li>
</g:else>
</ul>
</div>
</nav>
</g:if>
22 changes: 16 additions & 6 deletions server/gokb/grails-app/views/search/_qberesult.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<g:set var="counter" value="${offset}" />

<g:if test="${ request.isAjax() }">

<g:render template="pagination" contextPath="." model="${params}" />

<table class="table table-striped table-condensed table-bordered">
<thead>
<tr class="inline-nav">
Expand Down Expand Up @@ -61,10 +63,12 @@
</table>
</g:if>
<g:else>
<g:form controller="workflow" action="action" method="post" params="${params}"
class='action-form' >
<div class="batch-all-info" style="display:none;"></div>
<g:render template="pagination" contextPath="." model="${params}" />
<div class="batch-all-info" style="display:none;"></div>

<g:render template="pagination" contextPath="." model="${params}" />

<g:form controller="workflow" action="action" method="post" params="${params}" class='action-form' >

<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -143,6 +147,12 @@
</g:each>
</tbody>
</table>
<g:render template="pagination" contextPath="." model="${params + [dropup : true]}" />
</g:form>
</g:form>
<g:render template="pagination" contextPath="." model="${params + [dropup : true]}" />
</g:else>

<script language="JavaScript">
function jumpToPage() {
alert("jump to page");
}
</script>

0 comments on commit 8198479

Please sign in to comment.