Skip to content

Commit

Permalink
Merge branch 'bpena-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
JLLeitschuh committed Jun 19, 2015
2 parents 47ebfb3 + 7e56d4c commit 1338b6c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
27 changes: 14 additions & 13 deletions src/features/pagination/js/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@

grid.api.registerEventsFromObject(publicApi.events);
grid.api.registerMethodsFromObject(publicApi.methods);

var processPagination = function( renderableRows ){
if (grid.options.useExternalPagination || !grid.options.enablePagination) {
return renderableRows;
}
//client side pagination
var pageSize = parseInt(grid.options.paginationPageSize, 10);
var currentPage = parseInt(grid.options.paginationCurrentPage, 10);

var visibleRows = renderableRows.filter(function (row) { return row.visible; });
grid.options.totalItems = visibleRows.length;

Expand All @@ -150,7 +150,7 @@
}
return visibleRows.slice(firstRow, firstRow + pageSize);
};

grid.registerRowsProcessor(processPagination, 900 );

},
Expand Down Expand Up @@ -214,7 +214,7 @@
if (gridUtil.isNullOrUndefined(gridOptions.paginationPageSize)) {
if (gridOptions.paginationPageSizes.length > 0) {
gridOptions.paginationPageSize = gridOptions.paginationPageSizes[0];
} else {
} else {
gridOptions.paginationPageSize = 0;
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@
}
}
};

return service;
}
]);
Expand Down Expand Up @@ -343,20 +343,21 @@
$scope.paginationApi = uiGridCtrl.grid.api.pagination;
$scope.sizesLabel = i18nService.getSafeText('pagination.sizes');
$scope.totalItemsLabel = i18nService.getSafeText('pagination.totalItems');

$scope.paginationOf = i18nService.getSafeText('pagination.of');

var options = uiGridCtrl.grid.options;

uiGridCtrl.grid.renderContainers.body.registerViewportAdjuster(function (adjustment) {
adjustment.height = adjustment.height - gridUtil.elementHeight($elm);
return adjustment;
});

var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback(function (grid) {
if (!grid.options.useExternalPagination) {
grid.options.totalItems = grid.rows.length;
}
}, [uiGridConstants.dataChange.ROW]);

$scope.$on('$destroy', dataChangeDereg);

var setShowing = function () {
Expand All @@ -367,8 +368,8 @@
var deregT = $scope.$watch('grid.options.totalItems + grid.options.paginationPageSize', setShowing);

var deregP = $scope.$watch('grid.options.paginationCurrentPage + grid.options.paginationPageSize', function (newValues, oldValues) {
if (newValues === oldValues) {
return;
if (newValues === oldValues) {
return;
}

if (!angular.isNumber(options.paginationCurrentPage) || options.paginationCurrentPage < 1) {
Expand Down Expand Up @@ -398,15 +399,15 @@
return options.data.length < 1;
}
};

$scope.cantPageToLast = function () {
if (options.totalItems > 0) {
return $scope.cantPageForward();
} else {
return true;
}
};

$scope.cantPageBackward = function () {
return options.paginationCurrentPage <= 1;
};
Expand Down
2 changes: 1 addition & 1 deletion src/features/pagination/templates/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="ui-grid-pager-count-container">
<div class="ui-grid-pager-count">
<span ng-show="grid.options.totalItems > 0">
{{showingLow}} - {{showingHigh}} of {{grid.options.totalItems}} {{totalItemsLabel}}
{{showingLow}} - {{showingHigh}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
</span>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/js/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
},
pagination: {
sizes: 'items per page',
totalItems: 'items'
totalItems: 'items',
of: 'of'
},
grouping: {
group: 'Group',
Expand Down
15 changes: 15 additions & 0 deletions src/js/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@
invalidCsv: 'No fue posible procesar el archivo, ¿es un CSV válido?',
invalidJson: 'No fue posible procesar el archivo, ¿es un Json válido?',
jsonNotArray: 'El archivo json importado debe contener un array, abortando.'
},
pagination: {
sizes: 'registros por página',
totalItems: 'registros',
of: 'de'
},
grouping: {
group: 'Agrupar',
ungroup: 'Desagrupar',
aggregate_count: 'Agr: Cont',
aggregate_sum: 'Agr: Sum',
aggregate_max: 'Agr: Máx',
aggregate_min: 'Agr: Min',
aggregate_avg: 'Agr: Prom',
aggregate_remove: 'Agr: Quitar'
}
});
return $delegate;
Expand Down

0 comments on commit 1338b6c

Please sign in to comment.