Repository: archiva
Updated Branches:
  refs/heads/master 4e331298e -> 951b9f8ef


MRM-1811 add alternative pagination for simplegrid

Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/951b9f8e
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/951b9f8e
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/951b9f8e

Branch: refs/heads/master
Commit: 951b9f8ef15abed0fabba2ac38f1cbfd6a52d597
Parents: 4e33129
Author: Eric Barboni <[email protected]>
Authored: Tue Oct 14 02:56:36 2014 +0200
Committer: Eric Barboni <[email protected]>
Committed: Tue Oct 14 02:56:36 2014 +0200

----------------------------------------------------------------------
 .../org/apache/archiva/i18n/default.properties  |  5 ++
 .../src/main/webapp/js/knockout.simpleGrid.js   | 10 ++--
 .../src/main/webapp/js/redback/users.js         |  2 +-
 .../webapp/js/templates/archiva/generics.html   | 53 ++++++++++++++++++++
 4 files changed, 66 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/951b9f8e/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
 
b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
index fd6a5b9..75cbd77 100644
--- 
a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
+++ 
b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
@@ -711,4 +711,9 @@ version.delete.missing.repoId=You must select a Repository
 
 
 
+# navigation
+navigation.previous=Previous
+navigation.next=Next
+navigation.first=First
+navigation.last=Last
 

http://git-wip-us.apache.org/repos/asf/archiva/blob/951b9f8e/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/knockout.simpleGrid.js
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/knockout.simpleGrid.js
 
b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/knockout.simpleGrid.js
index 90a0ff5..99f0c6e 100644
--- 
a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/knockout.simpleGrid.js
+++ 
b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/knockout.simpleGrid.js
@@ -29,7 +29,9 @@
       this.currentPageIndex = ko.observable(0);
       this.pageSize = configuration.pageSize || 5;
       this.columns = configuration.columns;
-
+      // true for prev next nav
+      this.innerNavigation = configuration.innerNavigation;
+      this.navsize = configuration.navsize || 10; 
       this.itemsOnCurrentPage = ko.computed(function () {
           var startIndex = this.pageSize * this.currentPageIndex();
           var items = this.data.slice(startIndex, startIndex + this.pageSize);
@@ -67,14 +69,16 @@
         // Allow the default templates to be overridden
         var gridTemplateName      = allBindings.simpleGridTemplate || 
"ko_usersGrid_grid",
             pageLinksTemplateName = allBindings.simpleGridPagerTemplate || 
"ko_simpleGrid_pageLinks";
-
+//ko_simpleGrid_pageLinksinnernav
+        if (viewModel.innerNavigation) {
+            pageLinksTemplateName = "ko_simpleGrid_pageLinksinnernav";
+        }
         // Render the main grid
         var gridContainer = element.appendChild(document.createElement("DIV"));
         ko.renderTemplate(gridTemplateName, viewModel, { templateEngine: 
templateEngine }, gridContainer, "replaceNode")
             
.subscribe(viewModel.gridUpdateCallBack?viewModel.gridUpdateCallBack:function(){});
 
         if (viewModel.gridUpdateCallBack) viewModel.gridUpdateCallBack();
-
         // Render the page links
         var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
         var renderedTemplate = ko.renderTemplate(pageLinksTemplateName, 
viewModel, { templateEngine: templateEngine }, pageLinksContainer, 
"replaceNode");

http://git-wip-us.apache.org/repos/asf/archiva/blob/951b9f8e/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
 
b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
index d9cc59d..9510fee 100644
--- 
a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
+++ 
b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
@@ -48,7 +48,7 @@ 
function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) {
           filter: true
         }
       ],
-      pageSize: 10,
+      pageSize: 10,innerNavigation : true,
       gridUpdateCallBack: function(){
         $.log("gridUpdateCallBack users result");
         applyAutocompleteOnUsersHeaders(self);

http://git-wip-us.apache.org/repos/asf/archiva/blob/951b9f8e/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/generics.html
----------------------------------------------------------------------
diff --git 
a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/generics.html
 
b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/generics.html
index 118265d..0fd1753 100644
--- 
a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/generics.html
+++ 
b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/generics.html
@@ -65,6 +65,59 @@
   </div>
 </script>
 
+<script id="ko_simpleGrid_pageLinksinnernav" type="text/html">
+  <div class="pagination">
+    <ul>
+      <li data-bind="css: { active: 0 == currentPageIndex() }">
+        <a href="#" data-bind="click: function() { currentPageIndex(0) }">
+          ${$.i18n.prop('navigation.first')}
+        </a>
+      </li>
+      <li data-bind="css: { active: 0 == currentPageIndex() }">
+        <a href="#" data-bind="click: function() { 
currentPageIndex(currentPageIndex()-1) }">
+          ${$.i18n.prop('navigation.previous')}
+        </a>
+      </li>
+      {{if currentPageIndex() < navsize }}
+      {{each(i) ko.utils.range(1, Math.min( navsize, maxPageIndex()-1))}}
+       <li data-bind="css: {active: i == currentPageIndex() }">
+        <a href="#" data-bind="click: function() { currentPageIndex( i + 1 ) 
}">         
+          ${ 1 + i }
+        </a>
+      </li>
+      {{/each}}
+      {{else currentPageIndex() > maxPageIndex() - navsize  }}
+      {{each(i) ko.utils.range(1,navsize)}}
+      <li data-bind="css: {active: currentPageIndex() ==  maxPageIndex() - 
navsize + i }">
+        <a href="#" data-bind="click: function() { currentPageIndex( 
maxPageIndex() - navsize + i  ) }">         
+         ${ maxPageIndex() - navsize + i + 1 }
+        </a>
+      </li>
+      {{/each}}
+      {{else}}
+       {{each(i) ko.utils.range(currentPageIndex(), Math.min( 
currentPageIndex() + navsize, maxPageIndex()-1))}}
+      <li data-bind="css: {active: i == 0 }">
+        <a href="#" data-bind="click: function() { currentPageIndex( i + 
currentPageIndex()  ) }">         
+        ${ currentPageIndex() + 1 + i}
+        </a>
+      </li>
+      {{/each}}
+      {{/if}}
+      
+      <li data-bind="css: { active: maxPageIndex()-1 == currentPageIndex() }">
+        <a href="#" data-bind="click: function() { 
currentPageIndex(currentPageIndex()+1) }">
+          ${$.i18n.prop('navigation.next')}
+        </a>
+      </li>
+      <li data-bind="css: { active: maxPageIndex()-1 == currentPageIndex() }">
+        <a href="#" data-bind="click: function() { 
currentPageIndex(maxPageIndex()-1) }">
+          ${$.i18n.prop('navigation.last')}
+        </a>
+      </li>
+    </ul>
+  </div>
+</script>
+
 <script id="welcome" type="text/html">
   <div class="row-fluid">
     <div class="row">

Reply via email to