diff --git a/src/openlmis-facility-program-select/facility-program-cache.service.js b/src/openlmis-facility-program-select/facility-program-cache.service.js index e3b3e49..955229f 100644 --- a/src/openlmis-facility-program-select/facility-program-cache.service.js +++ b/src/openlmis-facility-program-select/facility-program-cache.service.js @@ -164,7 +164,7 @@ var userId = authorizationService.getUser().user_id; return $q.all([ - facilityService.getAll(), + facilityService.getFacilitiesWithoutWards(), programService.getUserPrograms(userId), permissionService.load(userId), currentUserService.getUserInfo() diff --git a/src/openlmis-facility-program-select/facility-program-cache.service.spec.js b/src/openlmis-facility-program-select/facility-program-cache.service.spec.js index 7218269..10fc8f4 100644 --- a/src/openlmis-facility-program-select/facility-program-cache.service.spec.js +++ b/src/openlmis-facility-program-select/facility-program-cache.service.spec.js @@ -75,7 +75,7 @@ describe('facilityProgramCacheService', function() { spyOn(this.authorizationService, 'getUser').andReturn(this.user); spyOn(this.programService, 'getUserPrograms').andReturn(this.$q.when(this.programs)); - spyOn(this.facilityService, 'getAllMinimalWithoutWards').andReturn(this.$q.when(this.facilities)); + spyOn(this.facilityService, 'getFacilitiesWithoutWards').andReturn(this.$q.when(this.facilities)); spyOn(this.permissionService, 'load').andReturn(this.$q.when(permissions)); spyOn(this.currentUserService, 'getUserInfo').andReturn(this.$q.when(this.referencedataUser)); @@ -91,7 +91,7 @@ describe('facilityProgramCacheService', function() { }); it('should call facilityService', function() { - expect(this.facilityService.getAllMinimalWithoutWards).toHaveBeenCalled(); + expect(this.facilityService.getFacilitiesWithoutWards).toHaveBeenCalled(); }); it('should call authorizationService', function() { diff --git a/src/referencedata-facility/facility.service.js b/src/referencedata-facility/facility.service.js index e330192..e0e9178 100644 --- a/src/referencedata-facility/facility.service.js +++ b/src/referencedata-facility/facility.service.js @@ -279,7 +279,7 @@ * @ngdoc method * @methodOf referencedata-facility.facilityService * @name getAllMinimalWithoutWards - * + * * @description * Retrieves all facilities with id and name fields that are not wards. */ diff --git a/src/stock-card-summary-list/messages_en.json b/src/stock-card-summary-list/messages_en.json index 03042dc..098481f 100644 --- a/src/stock-card-summary-list/messages_en.json +++ b/src/stock-card-summary-list/messages_en.json @@ -7,5 +7,6 @@ "stockCardSummaryList.packs": "Packs", "stockCardSummaryList.doses": "Doses", "stockCardSummaryList.unit": "Unit", - "stockCardSummaryList.packsQuantity": "Packs quantity" + "stockCardSummaryList.packsQuantity": "Packs quantity", + "stockCardSummaryList.titleWithWard": "Stock on Hand - ${facility} - ${ward} - ${program}" } \ No newline at end of file diff --git a/src/stock-card-summary-list/stock-card-summary-list.controller.js b/src/stock-card-summary-list/stock-card-summary-list.controller.js index 7fd6d87..c556adb 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.controller.js +++ b/src/stock-card-summary-list/stock-card-summary-list.controller.js @@ -30,12 +30,13 @@ controller.$inject = [ 'loadingModalService', '$state', '$stateParams', 'StockCardSummaryRepositoryImpl', 'stockCardSummaries', - 'offlineService', '$scope', 'STOCKCARD_STATUS', 'messageService', 'paginationService', 'unitOfOrderableService' + 'offlineService', '$scope', 'STOCKCARD_STATUS', 'messageService', 'paginationService', 'unitOfOrderableService', + 'selectedWard' ]; function controller(loadingModalService, $state, $stateParams, StockCardSummaryRepositoryImpl, stockCardSummaries, offlineService, $scope, STOCKCARD_STATUS, messageService, paginationService, - unitOfOrderableService) { + unitOfOrderableService, selectedWard) { var vm = this; vm.$onInit = onInit; @@ -47,6 +48,7 @@ vm.goToPendingOfflineEventsPage = goToPendingOfflineEventsPage; vm.setActiveDisplayType = setActiveDisplayType; vm.selectedWard = undefined; + vm.currentlySelectedWardName = undefined; vm.PACKS_DISPLAY_TYPE = 'packs'; vm.DOSES_DISPLAY_TYPE = 'doses'; vm.activeDisplayType = vm.DOSES_DISPLAY_TYPE; @@ -144,6 +146,10 @@ * Initialization method for StockCardSummaryListController. */ function onInit() { + vm.selectedWard = selectedWard; + if (selectedWard) { + vm.currentlySelectedWardName = selectedWard.name; + } // AO-816: Add prices to the Stock On Hand view stockCardSummaries.forEach(function(stockCardSummary) { stockCardSummary.orderable.unitPrice = getProductPrice(stockCardSummary); @@ -231,6 +237,7 @@ stateParams.productName = vm.productName; stateParams.productCode = vm.productCode; stateParams.lotCode = vm.lotCode; + stateParams.ward = vm.selectedWard ? vm.selectedWard.id : undefined; $state.go('openlmis.stockmanagement.stockCardSummaries', stateParams, { reload: true diff --git a/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js b/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js index 7d6438e..91a26fe 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js +++ b/src/stock-card-summary-list/stock-card-summary-list.controller.spec.js @@ -62,13 +62,16 @@ describe('StockCardSummaryListController', function() { }); // AO-816: Ends here + this.selectedWard = undefined; + spyOn(this.offlineService, 'isOffline').andReturn(true); this.vm = this.$controller('StockCardSummaryListController', { stockCardSummaries: this.stockCardSummaries, displayStockCardSummaries: this.stockCardSummaries, $stateParams: this.stateParams, - $scope: this.scope + $scope: this.scope, + selectedWard: this.selectedWard }); this.vm.$onInit(); @@ -154,6 +157,7 @@ describe('StockCardSummaryListController', function() { program: 'program', supervised: true, includeInactive: false, + ward: undefined, // ANGOLASUP-685: Starts here page: 0, size: 10 diff --git a/src/stock-card-summary-list/stock-card-summary-list.html b/src/stock-card-summary-list/stock-card-summary-list.html index ea63a80..2743436 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.html +++ b/src/stock-card-summary-list/stock-card-summary-list.html @@ -1,6 +1,9 @@ -

+

{{'stockCardSummaryList.title' | message: { 'facility': vm.facility.name, 'program': vm.program.name} }}

+

+ {{'stockCardSummaryList.titleWithWard' | message: { 'facility': vm.facility.name, 'ward': vm.currentlySelectedWardName, 'program': vm.program.name} }} +

{{'stockCardSummaryList.stockOnHand' | message}}

{{ 'stockCardSummaryList.offline1' | message}} diff --git a/src/stock-card-summary-list/stock-card-summary-list.routes.js b/src/stock-card-summary-list/stock-card-summary-list.routes.js index c831973..7656c4b 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.routes.js +++ b/src/stock-card-summary-list/stock-card-summary-list.routes.js @@ -28,7 +28,7 @@ isOffline: true, url: '/stockCardSummaries' + '?facility&program&supervised&page&size&includeInactive' - + '&productCode&productName&lotCode', + + '&productCode&productName&lotCode&ward', label: 'stockCardSummaryList.stockOnHand', priority: 1, showInNavigation: true, @@ -68,6 +68,14 @@ return paramsCopy; }, + selectedWard: function($stateParams, facilityService) { + if ($stateParams.ward) { + return facilityService.get($stateParams.ward).then(function(ward) { + return ward; + }); + } + return undefined; + }, // ANGOLASUP-685: Starts here stockCardSummaries: function(paginationService, StockCardSummaryRepository, StockCardSummaryRepositoryImpl, $stateParams, offlineService, params) {