Skip to content

Commit a138fa5

Browse files
committed
correcao pagination render
1 parent 3478fda commit a138fa5

File tree

6 files changed

+48
-38
lines changed

6 files changed

+48
-38
lines changed

dist/directive.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-rs-datagrid
33
*
4-
* Version: 1.0.56 - 2017-05-10T14:00:00.743Z
4+
* Version: 1.0.56 - 2017-05-20T20:53:54.559Z
55
* License: MIT
66
*/
77

dist/directive.js

Lines changed: 22 additions & 17 deletions
Large diffs are not rendered by default.

dist/directive.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/directive.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directive-template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ <h3 class="popover-title" ng-if="config.popoverRow.titleRender" ng-bind-html="ge
130130
<div style='top:-10px;left:90px;width:14px;height:40px;background:#959b9e;-webkit-transform:rotate(330deg) translate(0,-50px);transform:rotate(330deg) translate(0,-50px);border-radius:10px;position:absolute;'></div>
131131
</div>
132132
<!-- buttons page -->
133-
<ul ng-if="hasPagination && collection.content.length > 0 && !showProgress">
133+
<ul ng-if="hasPagination && collection.content.length > 0">
134134
<li class="prev" ng-class="{'disabled': collection.first}">
135135
<a ng-click="prevPage()">← Anterior</a>
136136
</li>
137-
<li ng-class="{'active' : currentPage == page.index}" ng-repeat="page in avaliablesPages">
137+
<li ng-class="{'active' : currentPage == page.index}" ng-if="page.index >= start && page.index <= end" ng-repeat="page in avaliablesPages">
138138
<a ng-click="goToPage(page.index)">{{page.label}}</a>
139139
</li>
140140
<li class="next" ng-class="{'disabled': collection.last}">

src/directive.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,19 @@ angular.module('rs.datagrid', ['ui.utils.masks', 'ui.select'])
309309
if (dados) {
310310
// console.log('watch collection');
311311
if (scope.hasPagination) {
312-
makePagination();
312+
if(scope.avaliablesPages.length === 0){
313+
makePagination();
314+
}
315+
defineStartEnd();
313316
}
314317
setValuesInternal(dados);
315318
}
316319
});
317320

318-
function makePagination() {
319-
scope.avaliablesPages = [];
320-
var totalPages = scope.collection.totalPages;
321-
var start = angular.copy(scope.currentPage);
321+
function defineStartEnd(){
322+
var start = angular.copy(scope.currentPage);
323+
var totalPages = scope.collection.totalPages;
324+
var newAvaliablePages = angular.copy(scope.avaliablesPages);
322325

323326
if ( (start - 2 ) >= 1) {
324327
start = start - 2;
@@ -338,19 +341,21 @@ angular.module('rs.datagrid', ['ui.utils.masks', 'ui.select'])
338341
if(start < 0){
339342
start = 0;
340343
}
344+
scope.start = start;
345+
scope.end = angular.copy(start+4);
346+
}
341347

342-
var count = 0;
343-
344-
while (count < 5) {
345-
var index = start + count;
346-
var label = start + count + 1;
347-
if (label <= totalPages) {
348+
function makePagination() {
349+
scope.avaliablesPages = [];
350+
var totalPages = scope.collection.totalPages;
351+
var i = 0;
352+
353+
while(i < totalPages){
348354
scope.avaliablesPages.push({
349-
index: index,
350-
label: label
355+
index: i,
356+
label: i + 1
351357
});
352-
}
353-
count++;
358+
i++;
354359
}
355360
}
356361

0 commit comments

Comments
 (0)