From 5cf0532db71d58bf08d1fe15ad5df490ef9f706f Mon Sep 17 00:00:00 2001 From: jendib Date: Mon, 2 Mar 2015 00:07:42 +0100 Subject: [PATCH] Page size selector --- .../src/app/docs/controller/Document.js | 15 ++++++++++++-- .../src/app/docs/controller/DocumentEdit.js | 4 ++-- .../webapp/src/partial/docs/document.html | 8 +++++++- docs-web/src/main/webapp/src/style/main.less | 20 +++++++++++++++---- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/Document.js index 7a127547..4c15e862 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Document.js @@ -11,7 +11,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.asc = false; $scope.offset = 0; $scope.currentPage = 1; - $scope.limit = 10; + $scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; $scope.search = ''; // A timeout promise is used to slow down search requests to the server @@ -59,7 +59,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, /** * Watch for search scope change. */ - $scope.$watch('search', function(prev, next) { + $scope.$watch('search', function() { if (timeoutPromise) { // Cancel previous timeout $timeout.cancel(timeoutPromise); @@ -83,6 +83,17 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.sortColumn = sortColumn; $scope.loadDocuments(); }; + + /** + * Watch for page size change. + */ + $scope.$watch('limit', function(next, prev) { + localStorage.documentsPageSize = next; + if (next == prev) { + return; + } + $scope.loadDocuments(); + }); /** * Go to add document form. diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js index 42ac85e1..7aff1ac2 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js @@ -3,7 +3,7 @@ /** * Document edition controller. */ -angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $q, $http, $state, $stateParams, Restangular, Tag) { +angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $q, $http, $state, $stateParams, Restangular) { // Alerts $scope.alerts = []; @@ -156,7 +156,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ var then = function() { key++; if ($scope.newFiles[key]) { - sendFile(key).then(then); + sendFile(key).then(then); // TODO Handle upload error } else { $scope.fileIsUploading = false; $scope.fileProgress = 0; diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index 0bd3a628..66647a32 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -47,8 +47,14 @@ -
+
+ +
diff --git a/docs-web/src/main/webapp/src/style/main.less b/docs-web/src/main/webapp/src/style/main.less index bd1b564a..b0f2966b 100644 --- a/docs-web/src/main/webapp/src/style/main.less +++ b/docs-web/src/main/webapp/src/style/main.less @@ -136,10 +136,22 @@ input[readonly].share-link { } // Pagination -.pagination { - ul > li { - cursor: pointer; - } +.pagination > .active > a { + cursor: pointer !important; +} + +// Pagination box +.pagination-box { + pagination { + vertical-align: top; + } + + select { + vertical-align: top; + width: auto; + display: inline-block; + margin: 20px 0; + } } .nav-text-error {