@@ -62,6 +62,21 @@ angular.module('patternfly.navigation', ['ui.bootstrap']);
6262 *
6363 */
6464angular.module('patternfly.notification', ['patternfly.utils', 'ui.bootstrap']);
65+ ;/**
66+ * @name patternfly pagination
67+ *
68+ * @description
69+ * Pagination module for patternfly.
70+ *
71+ */
72+ angular.module('patternfly.pagination', ['ui.bootstrap'])
73+ .filter('startFrom', function () {
74+ 'use strict';
75+ return function (input, start) {
76+ start = parseInt(start, 10);
77+ return input.slice(start);
78+ };
79+ });
6580;/**
6681 * @name patternfly
6782 *
@@ -76,6 +91,7 @@ angular.module('patternfly', [
7691 'patternfly.modals',
7792 'patternfly.navigation',
7893 'patternfly.notification',
94+ 'patternfly.pagination',
7995 'patternfly.select',
8096 'patternfly.sort',
8197 'patternfly.toolbars',
@@ -10765,6 +10781,153 @@ angular.module( 'patternfly.notification' ).component('pfToastNotification', {
1076510781 };
1076610782 }
1076710783});
10784+ ;/**
10785+ * @ngdoc directive
10786+ * @name patternfly.pagination.component:pfPagination
10787+ * @restrict E
10788+ *
10789+ * @param {number} pageNumber The current page number
10790+ * @param {number} numTotalItems The total number of items in the data set. When a filter is applied, update the <code>numTotalItems</code>
10791+ * accordingly.
10792+ * @param {Array<Number>} pageSizeIncrements (optional) Page size increments for the 'per page' dropdown. If not
10793+ * specified, the default values are: [5, 10, 20, 40, 80, 100]
10794+ * @param {number} pageSize (optional) The initial page size to use. If not specified, the default will be
10795+ * the first increment in the <code>pageSizeIncrements</code> array.
10796+ * @description
10797+ * Component for pagination controls used in various views (list, card, table)
10798+ *
10799+ * @example
10800+ <example module="patternfly.pagination">
10801+
10802+ <file name="index.html">
10803+ <div ng-controller="PageCtrl">
10804+ <div class="col-md-12">
10805+ <div ng-repeat="item in items | startFrom:(pageNumber - 1)*pageSize | limitTo:pageSize" class="col-md-12">
10806+ <div class="row">
10807+ <div class="col-md-3">
10808+ <span>{{item.id}}</span>
10809+ </div>
10810+ <div class="col-md-7">
10811+ <span>{{item.status}}</span>
10812+ </div>
10813+ <div class="col-md-2">
10814+ <span>{{item.value}}</span>
10815+ </div>
10816+ </div>
10817+ </div>
10818+ </div>
10819+ <pf-pagination
10820+ page-size="pageSize",
10821+ page-number="pageNumber"
10822+ num-total-items="numTotalItems">
10823+ </pf-pagination>
10824+ </div>
10825+ </file>
10826+ <file name="script.js">
10827+ angular.module( 'patternfly.pagination').controller( 'PageCtrl', function( $scope ) {
10828+ $scope.pageSize = 10;
10829+ $scope.pageNumber = 1;
10830+
10831+ $scope.items = [];
10832+ for(i = 1; i <= 126; i++) {
10833+ $scope.items.push({id: i, status: 'Ok', value: Math.floor(Math.random() * (1000 - 1 + 1)) + 1});
10834+ }
10835+
10836+ $scope.numTotalItems = $scope.items.length;
10837+ });
10838+ </file>
10839+ </example>
10840+ */
10841+ angular.module('patternfly.pagination').component('pfPagination', {
10842+ transclude: true,
10843+ templateUrl: 'pagination/pagination.html',
10844+ bindings: {
10845+ pageNumber: '=',
10846+ numTotalItems: "<",
10847+ pageSizeIncrements: '<?',
10848+ pageSize: "=?"
10849+ },
10850+ controller: ["$scope", "$log", function ($scope, $log) {
10851+ 'use strict';
10852+ var ctrl = this;
10853+
10854+ var defaultPageSizeIncrements = [5, 10, 20, 40, 80, 100];
10855+
10856+ ctrl.$onInit = function () {
10857+ if (angular.isUndefined(ctrl.pageSizeIncrements)) {
10858+ ctrl.pageSizeIncrements = defaultPageSizeIncrements;
10859+ }
10860+ if (angular.isUndefined(ctrl.pageSize)) {
10861+ ctrl.pageSize = ctrl.pageSizeIncrements[0];
10862+ }
10863+ ctrl.lastPageNumber = getLastPageNumber();
10864+ };
10865+
10866+ ctrl.$onChanges = function (changesObj) {
10867+ if (changesObj.numTotalItems && !changesObj.numTotalItems.isFirstChange()) {
10868+ ctrl.lastPageNumber = getLastPageNumber();
10869+ }
10870+ };
10871+
10872+ ctrl.onPageSizeChange = function (newPageSize) {
10873+ ctrl.pageSize = newPageSize;
10874+ ctrl.lastPageNumber = getLastPageNumber();
10875+ ctrl.gotoFirstPage();
10876+ };
10877+
10878+ ctrl.onPageNumberChange = function () {
10879+ ctrl.pageNumber = parseInt(ctrl.pageNumber, 10);
10880+ if (ctrl.pageNumber > ctrl.lastPageNumber) {
10881+ ctrl.pageNumber = ctrl.lastPageNumber;
10882+ } else if (ctrl.pageNumber < 1 || isNaN(ctrl.pageNumber)) {
10883+ ctrl.pageNumber = 1;
10884+ }
10885+ };
10886+
10887+ ctrl.gotoFirstPage = function () {
10888+ if (ctrl.pageNumber !== 1) {
10889+ ctrl.pageNumber = 1;
10890+ }
10891+ };
10892+
10893+ ctrl.gotoPreviousPage = function () {
10894+ if (ctrl.pageNumber !== 1) {
10895+ ctrl.pageNumber--;
10896+ }
10897+ };
10898+
10899+ ctrl.gotoNextPage = function () {
10900+ if (ctrl.pageNumber < ctrl.lastPageNumber) {
10901+ ctrl.pageNumber++;
10902+ }
10903+ };
10904+
10905+ ctrl.gotoLastPage = function () {
10906+ if (ctrl.pageNumber < ctrl.lastPageNumber) {
10907+ ctrl.pageNumber = ctrl.lastPageNumber;
10908+ }
10909+ };
10910+
10911+ ctrl.getStartIndex = function () {
10912+ return ctrl.pageSize * (ctrl.pageNumber - 1) + 1;
10913+ };
10914+
10915+ ctrl.getEndIndex = function () {
10916+ var numFullPages = Math.floor(ctrl.numTotalItems / ctrl.pageSize);
10917+ var numItemsOnLastPage = ctrl.numTotalItems - (numFullPages * ctrl.pageSize);
10918+ var numItemsOnPage = isLastPage() ? numItemsOnLastPage : ctrl.pageSize;
10919+ return ctrl.getStartIndex() + numItemsOnPage - 1;
10920+ };
10921+
10922+ function getLastPageNumber () {
10923+ return Math.ceil(ctrl.numTotalItems / ctrl.pageSize);
10924+ }
10925+
10926+ function isLastPage () {
10927+ return ctrl.pageNumber === ctrl.lastPageNumber;
10928+ }
10929+ }]
10930+ });
1076810931;/**
1076910932 * @ngdoc directive
1077010933 * @name patternfly.select.component:pfSelect
@@ -16439,6 +16602,14 @@ angular.module('patternfly.wizard').component('pfWizard', {
1643916602 "<div class=\"toast-pf alert alert-{{$ctrl.notificationType}}\" ng-class=\"{'alert-dismissable': $ctrl.showCloseButton}\" ng-mouseenter=$ctrl.handleEnter() ng-mouseleave=$ctrl.handleLeave()><div uib-dropdown class=\"pull-right dropdown-kebab-pf\" ng-if=\"$ctrl.menuActions && $ctrl.menuActions.length > 0\"><button uib-dropdown-toggle class=\"btn btn-link\" type=button id=dropdownKebabRight><span class=\"fa fa-ellipsis-v\"></span></button><ul uib-dropdown-menu class=dropdown-menu-right aria-labelledby=dropdownKebabRight><li ng-repeat=\"menuAction in $ctrl.menuActions\" role=\"{{menuAction.isSeparator === true ? 'separator' : 'menuitem'}}\" ng-class=\"{'divider': menuAction.isSeparator === true, 'disabled': menuAction.isDisabled === true}\"><a ng-if=\"menuAction.isSeparator !== true\" class=secondary-action title={{menuAction.title}} ng-click=$ctrl.handleMenuAction(menuAction)>{{menuAction.name}}</a></li></ul></div><button ng-if=$ctrl.showCloseButton type=button class=close aria-hidden=true ng-click=$ctrl.handleClose()><span class=\"pficon pficon-close\"></span></button><div class=\"pull-right toast-pf-action\" ng-if=$ctrl.actionTitle><a ng-click=$ctrl.handleAction()>{{$ctrl.actionTitle}}</a></div><span class=\"pficon pficon-ok\" ng-if=\"$ctrl.notificationType === 'success'\"></span> <span class=\"pficon pficon-info\" ng-if=\"$ctrl.notificationType === 'info'\"></span> <span class=\"pficon pficon-error-circle-o\" ng-if=\"$ctrl.notificationType === 'danger'\"></span> <span class=\"pficon pficon-warning-triangle-o\" ng-if=\"$ctrl.notificationType === 'warning'\"></span> <span ng-if=$ctrl.header><strong>{{$ctrl.header}}</strong> {{$ctrl.message}}</span> <span ng-if=!$ctrl.header>{{$ctrl.message}}</span></div>"
1644016603 );
1644116604
16605+ }]);
16606+ ;angular.module('patternfly.pagination').run(['$templateCache', function($templateCache) {
16607+ 'use strict';
16608+
16609+ $templateCache.put('pagination/pagination.html',
16610+ "<form class=\"content-view-pf-pagination list-view-pf-pagination clearfix\" id=form1><div class=form-group><div uib-dropdown class=btn-group><button uib-dropdown-toggle type=button class=\"btn btn-default\">{{$ctrl.pageSize}} <span class=caret></span></button><ul uib-dropdown-menu class=dropdown-menu><li ng-repeat=\"increment in $ctrl.pageSizeIncrements track by $index\" ng-class=\"{'selected': increment === $ctrl.pageSize}\" class=display-length-increment><a role=menuitem ng-click=$ctrl.onPageSizeChange(increment)>{{increment}}</a></li></ul></div><span class=per-page-label>per page</span></div><div class=form-group><span><span class=pagination-pf-items-current>{{$ctrl.getStartIndex()}}-{{$ctrl.getEndIndex()}}</span> of <span class=pagination-pf-items-total>{{$ctrl.numTotalItems}}</span></span><ul class=\"pagination pagination-pf-back\"><li ng-class=\"{'disabled': $ctrl.pageNumber === 1}\"><a title=\"First Page\" ng-click=$ctrl.gotoFirstPage() class=goto-first-page><span class=\"i fa fa-angle-double-left\"></span></a></li><li ng-class=\"{'disabled': $ctrl.pageNumber === 1}\"><a title=\"Previous Page\" ng-click=$ctrl.gotoPreviousPage() class=goto-prev-page><span class=\"i fa fa-angle-left\"></span></a></li></ul><input class=pagination-pf-page ng-model=$ctrl.pageNumber ng-model-options=\"{ updateOn: 'blur' }\" ng-change=\"$ctrl.onPageNumberChange()\"> <span>of <span class=pagination-pf-pages>{{$ctrl.lastPageNumber}}</span></span><ul class=\"pagination pagination-pf-forward\"><li ng-class=\"{'disabled': $ctrl.pageNumber === $ctrl.lastPageNumber}\"><a title=\"Next Page\" ng-click=$ctrl.gotoNextPage() class=goto-next-page><span class=\"i fa fa-angle-right\"></span></a></li><li ng-class=\"{'disabled': $ctrl.pageNumber === $ctrl.lastPageNumber}\"><a title=\"Last Page\" ng-click=$ctrl.gotoLastPage() class=goto-last-page><span class=\"i fa fa-angle-double-right\"></span></a></li></ul></div></form>"
16611+ );
16612+
1644216613}]);
1644316614;angular.module('patternfly.select').run(['$templateCache', function($templateCache) {
1644416615 'use strict';
0 commit comments