Skip to content

Commit

Permalink
Merge pull request #16 from OpenLMIS/SELV3-783
Browse files Browse the repository at this point in the history
SELV3-783: Added corrections to create state for dashboards
  • Loading branch information
DominikNoga authored Jan 10, 2025
2 parents d59dc6d + ca201dd commit aa9b0e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 51 deletions.
30 changes: 0 additions & 30 deletions src/report/dashboard-report.routes.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/report/dashboard-reports.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
dashboardReports.$inject = ['reportDashboardService', 'REPORT_TYPES'];

function dashboardReports(reportDashboardService, REPORT_TYPES) {
var reports = getReports();
var reports = undefined;

return {
getReports: getReports,
Expand Down Expand Up @@ -83,7 +83,7 @@
function createResolve(report) {
var resolve = {
reportUrl: function($sce) {
return $sce.trustAsResourceUrl(report.url);
return $sce.trustAsResourceUrl(report.url + '?standalone=true');
},
reportName: function() {
return report.name;
Expand Down
7 changes: 5 additions & 2 deletions src/report/report-list.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
jasperReports: function(reportFactory) {
return reportFactory.getAllReports();
},
dashboardReportsList: function(dashboardReports) {
return dashboardReports.getReports();
dashboardReportsList: function(dashboardReports, reportDashboardService) {
return reportDashboardService.getAllForUser().then(function(response) {
dashboardReports.addReporingPages($stateProvider);
return response.content;
});
}
}
});
Expand Down
38 changes: 21 additions & 17 deletions src/report/report-list.routes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('openlmis.reports.list state', function() {
this.$q = $injector.get('$q');
this.reportFactory = $injector.get('reportFactory');
this.reportCategoryService = $injector.get('reportCategoryService');
this.reportDashboardService = $injector.get('reportDashboardService');
this.dashboardReports = $injector.get('dashboardReports');
this.$location = $injector.get('$location');
this.REPORT_RIGHTS = $injector.get('REPORT_RIGHTS');
Expand Down Expand Up @@ -53,26 +54,29 @@ describe('openlmis.reports.list state', function() {
]
};

this.dashboardReportsList = [
{
id: 'id-three',
name: 'Report 3',
category: {
name: 'Administartion'
}
},
{
id: 'id-four',
name: 'Report 4',
category: {
name: 'Orders'
this.dashboardReportsList = {
content: [
{
id: 'id-three',
name: 'Report 3',
category: {
name: 'Administartion'
}
},
{
id: 'id-four',
name: 'Report 4',
category: {
name: 'Orders'
}
}
}
];
]
};

spyOn(this.reportFactory, 'getAllReports').andReturn(this.$q.resolve(this.jasperReports));
spyOn(this.reportCategoryService, 'getAll').andReturn(this.$q.resolve(this.reportCategories));
spyOn(this.dashboardReports, 'getReports').andReturn(this.$q.resolve(this.dashboardReportsList));
spyOn(this.reportDashboardService, 'getAllForUser').andReturn(this.$q.resolve(this.dashboardReportsList));
spyOn(this.dashboardReports, 'addReporingPages').andReturn(true);

this.goToUrl = goToUrl;
this.getResolvedValue = getResolvedValue;
Expand All @@ -93,7 +97,7 @@ describe('openlmis.reports.list state', function() {

expect(this.getResolvedValue('jasperReports')).toEqual(this.jasperReports);
expect(this.getResolvedValue('reportCategories')).toEqual(this.reportCategories.content);
expect(this.getResolvedValue('dashboardReportsList')).toEqual(this.dashboardReportsList);
expect(this.getResolvedValue('dashboardReportsList')).toEqual(this.dashboardReportsList.content);
});

function goToUrl(url) {
Expand Down

0 comments on commit aa9b0e2

Please sign in to comment.