Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 45cffa1

Browse files
committed
FINERACT-1609: Added Pagination to report
1 parent 3061074 commit 45cffa1

File tree

4 files changed

+91
-7
lines changed

4 files changed

+91
-7
lines changed

.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
</buildSpec>
99
<natures>
1010
</natures>
11-
</projectDescription>
11+
</projectDescription>

app/global-translations/locale-en.json

+4
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,9 @@
20432043
"label.input.dividendperiodenddate": "Dividend Period End Date",
20442044
"label.input.dividendamount": "Dividend Amount",
20452045
"label.input.todaysprice": "Today's Price",
2046+
"label.input.pagination": "Report Pagination",
2047+
"label.input.orderby": "Order By(Column index)",
2048+
"label.input.recordsPerPage": "Records per page",
20462049
"#Buttons": "..",
20472050
"label.button.undo": "Undo",
20482051
"label.button.modifyapplication": "Modify Application",
@@ -2955,6 +2958,7 @@
29552958
"label.tooltip.global.skip-repayment-on-first-day-of-month": "Determines whether a repayment landing on the first day of a month will be skipped.",
29562959
"label.tooltip.global.account-mapping-for-payment-type":"String value: Asset as default for asset, Or use comma seperated values for Liability, Asset and Expense accounts",
29572960
"label.tooltip.global.account-mapping-for-charge":"String value: Income: default for Income, Or use comma seperated values for Asset, Liability and Expense accounts",
2961+
"label.tooltip.global.reports-pagination-number-of-items-per-page":"Describes max content count per page.",
29582962
"#----------------": "------------",
29592963
"#Admin-Products": "....",
29602964
"#Headings": "..",

app/scripts/controllers/reports/RunReportsController.js

+47-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
scope.reportId = routeParams.reportId;
2525
scope.pentahoReportParameters = [];
2626
scope.type = "pie";
27-
27+
scope.reportsPerPage = 10;
28+
scope.formData.isPaginationAllowed = false;
29+
scope.iteratedReportDataSize = 0;
2830
scope.highlight = function (id) {
2931
var i = document.getElementById(id);
3032
if (i.className == 'selected-row') {
@@ -62,7 +64,6 @@
6264
}
6365
}
6466
});
65-
6667
if (scope.reportType == 'Pentaho') {
6768
resourceFactory.reportsResource.get({id: scope.reportId, fields: 'reportParameters'}, function (data) {
6869
scope.pentahoReportParameters = data.reportParameters || [];
@@ -286,6 +287,39 @@
286287
}
287288
return false;
288289
};
290+
scope.getResultsPage = function (pageNumber) {
291+
if(scope.searchText){
292+
var startPosition = (pageNumber - 1) * scope.reportsPerPage;
293+
scope.clients = scope.actualReports.slice(startPosition, startPosition + scope.reportsPerPage);
294+
return;
295+
}
296+
scope.formData.reportSource = scope.reportName;
297+
scope.searchText = "";
298+
scope.formData.pageNo = (pageNumber - 1);
299+
resourceFactory.runReportsResource.getReport(scope.formData, function (data) {
300+
scope.csvData = [];
301+
scope.reportData.columnHeaders = data.columnHeaders;
302+
scope.reportData.data = data.data;
303+
scope.totalItems = data.totalItems;
304+
305+
// scope.iteratedReportDataSize = pageNumber*data.recordsPerPage;
306+
if(pageNumber*data.recordsPerPage < scope.totalItems){
307+
scope.iteratedReportDataSize = pageNumber*data.recordsPerPage;
308+
}
309+
else{
310+
scope.lastPageReportDiff = pageNumber*data.recordsPerPage - scope.totalItems;
311+
scope.iteratedReportDataSize = (pageNumber*data.recordsPerPage)-scope.lastPageReportDiff;
312+
}
313+
for (var i in data.columnHeaders) {
314+
scope.row.push(data.columnHeaders[i].columnName);
315+
}
316+
scope.csvData.push(scope.row);
317+
for (var k in data.data) {
318+
scope.csvData.push(data.data[k].row);
319+
}
320+
});
321+
}
322+
289323
scope.runReport = function () {
290324
//clear the previous errors
291325
scope.errorDetails = [];
@@ -310,11 +344,22 @@
310344
scope.hidePentahoReport = true;
311345
scope.hideChart = true;
312346
scope.formData.reportSource = scope.reportName;
347+
scope.searchText = "";
348+
scope.formData.pageNo = 0;
313349
resourceFactory.runReportsResource.getReport(scope.formData, function (data) {
314350
//clear the csvData array for each request
315351
scope.csvData = [];
316352
scope.reportData.columnHeaders = data.columnHeaders;
317353
scope.reportData.data = data.data;
354+
scope.totalItems = data.totalItems;
355+
scope.reportDataSize = scope.reportData.data.length;
356+
if(scope.formData.isPaginationAllowed){
357+
scope.reportsPerPage = data.recordsPerPage;
358+
scope.iteratedReportDataSize = data.recordsPerPage;
359+
}else{
360+
scope.reportsPerPage = data.totalItems;
361+
}
362+
318363
for (var i in data.columnHeaders) {
319364
scope.row.push(data.columnHeaders[i].columnName);
320365
}

app/views/reports/run_reports.html

+39-4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@
7979
</select>
8080
</div>
8181
</div>
82+
<div class="form-group info" ng-show = "reportType == 'Table'">
83+
<label class="control-label col-sm-2" for="isPaginationAllowed">{{ 'label.input.pagination' | translate }}</label>
84+
85+
<div class="col-sm-1">
86+
<input id="isPaginationAllowed" class="form-check-input" type="checkbox" ng-true-value="true"
87+
ng-false-value="false" ng-model="formData.isPaginationAllowed" />
88+
</div>
89+
</div>
90+
<div class="form-group info" ng-show="formData.isPaginationAllowed">
91+
<label class="control-label col-sm-2" for="paginationOrderBy">{{ 'label.input.orderby' | translate }}</label>
92+
93+
<div class="col-sm-3">
94+
<input style="width: 257px" id="paginationOrderBy" class="form-control" type="number" ng-model="formData.paginationOrderBy" />
95+
</div>
96+
</div>
8297

8398
<span class="col-md-offset-3 paddedleft52px"><a id="run" ng-click="runReport()" class="btn btn-primary control"></i>
8499
&nbsp;&nbsp;{{ 'label.button.runreport' | translate }}</a></span>
@@ -143,17 +158,37 @@
143158
<th ng-repeat="columnHeader in reportData.columnHeaders">{{columnHeader.columnName}}</th>
144159
</tr>
145160
</thead>
146-
<tbody>
161+
<tbody *ngIf="false; else isPaginationNotAllowed" >
147162
<!-- http://www.anujgakhar.com/2013/06/15/duplicates-in-a-repeater-are-not-allowed-in-angularjs/ -->
148-
<tr id="{{$index}}" data-ng-click="highlight($index)" ng-repeat="row in reportData.data track by $index">
149-
<td ng-repeat="col in row.row track by $index">
163+
<!-- dir-paginate="row in reportData.data track by $index | itemsPerPage: reportsPerPage" -->
164+
<!-- <tr id="{{$index}}" data-ng-click="highlight($index)" ng-repeat="row in reportData.data track by $index"> -->
165+
<tr pagination-id="reportData" data-ng-click="highlight($index)" total-items="totalItems" dir-paginate='row in reportData.data | itemsPerPage : reportsPerPage' class="pointer-main">
166+
<td class="pointer" data-ng-click="routeTo(row.id)" ng-repeat="col in row.row track by $index">
150167
<span ng-show="isDecimal($index)">{{col | FormatNumber:decimalsChoice}}</span>
151168
<span ng-hide="isDecimal($index)">{{col}}</span>
152169
</td>
153170
</tr>
154171
</tbody>
172+
<ng-template #isPaginationNotAllowed>
173+
<tbody>
174+
<tr id="{{$index}}" data-ng-click="highlight($index)" ng-repeat="row in reportData.data track by $index"></tr>
175+
<td class="pointer" data-ng-click="routeTo(row.id)" ng-repeat="col in row.row track by $index">
176+
<span ng-show="isDecimal($index)">{{col | FormatNumber:decimalsChoice}}</span>
177+
<span ng-hide="isDecimal($index)">{{col}}</span>
178+
</td>
179+
</tr>
180+
</tbody>
181+
</ng-template>
155182
</table>
156-
</div>
183+
<dir-pagination-controls align="center" boundary-links="true"
184+
template-url="bower_components/angular-utils-pagination/dirPagination.tpl.html"
185+
on-page-change="getResultsPage(newPageNumber)" pagination-id="reportData">
186+
</dir-pagination-controls>
187+
<div ng-show="formData.isPaginationAllowed">
188+
<i><span> {{iteratedReportDataSize}} </span><span class="text-muted"> of </span><span> {{totalItems}} </span></i>
189+
</div>
190+
191+
</div>
157192
</div>
158193
<div uib-collapse="hidePentahoReport" class="row alert-block span tab-content">
159194
<br>

0 commit comments

Comments
 (0)