From a4ba8f0d836f6732d092918fa9952604b443b910 Mon Sep 17 00:00:00 2001 From: logoutdhaval Date: Tue, 3 May 2022 00:09:02 +0530 Subject: [PATCH] FINERACT-1609: Added Pagination to report --- app/global-translations/locale-en.json | 4 ++ .../reports/RunReportsController.js | 49 ++++++++++++++++++- app/views/reports/run_reports.html | 43 ++++++++++++++-- 3 files changed, 90 insertions(+), 6 deletions(-) diff --git a/app/global-translations/locale-en.json b/app/global-translations/locale-en.json index 7a95bcf8be..61945c2499 100644 --- a/app/global-translations/locale-en.json +++ b/app/global-translations/locale-en.json @@ -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", @@ -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": "..", diff --git a/app/scripts/controllers/reports/RunReportsController.js b/app/scripts/controllers/reports/RunReportsController.js index ab1680b0ac..51843857f1 100644 --- a/app/scripts/controllers/reports/RunReportsController.js +++ b/app/scripts/controllers/reports/RunReportsController.js @@ -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') { @@ -62,7 +64,6 @@ } } }); - if (scope.reportType == 'Pentaho') { resourceFactory.reportsResource.get({id: scope.reportId, fields: 'reportParameters'}, function (data) { scope.pentahoReportParameters = data.reportParameters || []; @@ -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 = []; @@ -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); } diff --git a/app/views/reports/run_reports.html b/app/views/reports/run_reports.html index b7bf958fb7..8beb095424 100644 --- a/app/views/reports/run_reports.html +++ b/app/views/reports/run_reports.html @@ -79,6 +79,21 @@ +
+ + +
+ +
+
+
+ + +
+ +
+
  {{ 'label.button.runreport' | translate }} @@ -143,17 +158,37 @@ {{columnHeader.columnName}} - + - - + + + + {{col | FormatNumber:decimalsChoice}} {{col}} + + + + + {{col | FormatNumber:decimalsChoice}} + {{col}} + + + + - + + +
+ {{iteratedReportDataSize}} of {{totalItems}} +
+ +