Skip to content

Commit

Permalink
FINERACT-1609: Added Pagination to report
Browse files Browse the repository at this point in the history
  • Loading branch information
logoutdhaval committed May 3, 2022
1 parent 3061074 commit a4ba8f0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/global-translations/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,9 @@
"label.input.dividendperiodenddate": "Dividend Period End Date",
"label.input.dividendamount": "Dividend Amount",
"label.input.todaysprice": "Today's Price",
"label.input.pagination": "Report Pagination",
"label.input.orderby": "Order By(Column index)",
"label.input.recordsPerPage": "Records per page",
"#Buttons": "..",
"label.button.undo": "Undo",
"label.button.modifyapplication": "Modify Application",
Expand Down Expand Up @@ -2955,6 +2958,7 @@
"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.",
"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",
"label.tooltip.global.account-mapping-for-charge":"String value: Income: default for Income, Or use comma seperated values for Asset, Liability and Expense accounts",
"label.tooltip.global.reports-pagination-number-of-items-per-page":"Describes max content count per page.",
"#----------------": "------------",
"#Admin-Products": "....",
"#Headings": "..",
Expand Down
49 changes: 47 additions & 2 deletions app/scripts/controllers/reports/RunReportsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
scope.reportId = routeParams.reportId;
scope.pentahoReportParameters = [];
scope.type = "pie";

scope.reportsPerPage = 10;
scope.formData.isPaginationAllowed = false;
scope.iteratedReportDataSize = 0;
scope.highlight = function (id) {
var i = document.getElementById(id);
if (i.className == 'selected-row') {
Expand Down Expand Up @@ -62,7 +64,6 @@
}
}
});

if (scope.reportType == 'Pentaho') {
resourceFactory.reportsResource.get({id: scope.reportId, fields: 'reportParameters'}, function (data) {
scope.pentahoReportParameters = data.reportParameters || [];
Expand Down Expand Up @@ -286,6 +287,39 @@
}
return false;
};
scope.getResultsPage = function (pageNumber) {
if(scope.searchText){
var startPosition = (pageNumber - 1) * scope.reportsPerPage;
scope.clients = scope.actualReports.slice(startPosition, startPosition + scope.reportsPerPage);
return;
}
scope.formData.reportSource = scope.reportName;
scope.searchText = "";
scope.formData.pageNo = (pageNumber - 1);
resourceFactory.runReportsResource.getReport(scope.formData, function (data) {
scope.csvData = [];
scope.reportData.columnHeaders = data.columnHeaders;
scope.reportData.data = data.data;
scope.totalItems = data.totalItems;

// scope.iteratedReportDataSize = pageNumber*data.recordsPerPage;
if(pageNumber*data.recordsPerPage < scope.totalItems){
scope.iteratedReportDataSize = pageNumber*data.recordsPerPage;
}
else{
scope.lastPageReportDiff = pageNumber*data.recordsPerPage - scope.totalItems;
scope.iteratedReportDataSize = (pageNumber*data.recordsPerPage)-scope.lastPageReportDiff;
}
for (var i in data.columnHeaders) {
scope.row.push(data.columnHeaders[i].columnName);
}
scope.csvData.push(scope.row);
for (var k in data.data) {
scope.csvData.push(data.data[k].row);
}
});
}

scope.runReport = function () {
//clear the previous errors
scope.errorDetails = [];
Expand All @@ -310,11 +344,22 @@
scope.hidePentahoReport = true;
scope.hideChart = true;
scope.formData.reportSource = scope.reportName;
scope.searchText = "";
scope.formData.pageNo = 0;
resourceFactory.runReportsResource.getReport(scope.formData, function (data) {
//clear the csvData array for each request
scope.csvData = [];
scope.reportData.columnHeaders = data.columnHeaders;
scope.reportData.data = data.data;
scope.totalItems = data.totalItems;
scope.reportDataSize = scope.reportData.data.length;
if(scope.formData.isPaginationAllowed){
scope.reportsPerPage = data.recordsPerPage;
scope.iteratedReportDataSize = data.recordsPerPage;
}else{
scope.reportsPerPage = data.totalItems;
}

for (var i in data.columnHeaders) {
scope.row.push(data.columnHeaders[i].columnName);
}
Expand Down
43 changes: 39 additions & 4 deletions app/views/reports/run_reports.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@
</select>
</div>
</div>
<div class="form-group info" ng-show = "reportType == 'Table'">
<label class="control-label col-sm-2" for="isPaginationAllowed">{{ 'label.input.pagination' | translate }}</label>

<div class="col-sm-1">
<input id="isPaginationAllowed" class="form-check-input" type="checkbox" ng-true-value="true"
ng-false-value="false" ng-model="formData.isPaginationAllowed" />
</div>
</div>
<div class="form-group info" ng-show="formData.isPaginationAllowed">
<label class="control-label col-sm-2" for="paginationOrderBy">{{ 'label.input.orderby' | translate }}</label>

<div class="col-sm-3">
<input style="width: 257px" id="paginationOrderBy" class="form-control" type="number" ng-model="formData.paginationOrderBy" />
</div>
</div>

<span class="col-md-offset-3 paddedleft52px"><a id="run" ng-click="runReport()" class="btn btn-primary control"></i>
&nbsp;&nbsp;{{ 'label.button.runreport' | translate }}</a></span>
Expand Down Expand Up @@ -143,17 +158,37 @@
<th ng-repeat="columnHeader in reportData.columnHeaders">{{columnHeader.columnName}}</th>
</tr>
</thead>
<tbody>
<tbody *ngIf="false; else isPaginationNotAllowed" >
<!-- http://www.anujgakhar.com/2013/06/15/duplicates-in-a-repeater-are-not-allowed-in-angularjs/ -->
<tr id="{{$index}}" data-ng-click="highlight($index)" ng-repeat="row in reportData.data track by $index">
<td ng-repeat="col in row.row track by $index">
<!-- dir-paginate="row in reportData.data track by $index | itemsPerPage: reportsPerPage" -->
<!-- <tr id="{{$index}}" data-ng-click="highlight($index)" ng-repeat="row in reportData.data track by $index"> -->
<tr pagination-id="reportData" data-ng-click="highlight($index)" total-items="totalItems" dir-paginate='row in reportData.data | itemsPerPage : reportsPerPage' class="pointer-main">
<td class="pointer" data-ng-click="routeTo(row.id)" ng-repeat="col in row.row track by $index">
<span ng-show="isDecimal($index)">{{col | FormatNumber:decimalsChoice}}</span>
<span ng-hide="isDecimal($index)">{{col}}</span>
</td>
</tr>
</tbody>
<ng-template #isPaginationNotAllowed>
<tbody>
<tr id="{{$index}}" data-ng-click="highlight($index)" ng-repeat="row in reportData.data track by $index"></tr>
<td class="pointer" data-ng-click="routeTo(row.id)" ng-repeat="col in row.row track by $index">
<span ng-show="isDecimal($index)">{{col | FormatNumber:decimalsChoice}}</span>
<span ng-hide="isDecimal($index)">{{col}}</span>
</td>
</tr>
</tbody>
</ng-template>
</table>
</div>
<dir-pagination-controls align="center" boundary-links="true"
template-url="bower_components/angular-utils-pagination/dirPagination.tpl.html"
on-page-change="getResultsPage(newPageNumber)" pagination-id="reportData">
</dir-pagination-controls>
<div ng-show="formData.isPaginationAllowed">
<i><span> {{iteratedReportDataSize}} </span><span class="text-muted"> of </span><span> {{totalItems}} </span></i>
</div>

</div>
</div>
<div uib-collapse="hidePentahoReport" class="row alert-block span tab-content">
<br>
Expand Down

0 comments on commit a4ba8f0

Please sign in to comment.