Skip to content

Commit

Permalink
Added ward select to SOH page
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikNoga committed Jun 17, 2024
1 parent 104ce21 commit 1cc7ef0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/referencedata-facility/facility.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/stock-card-summary-list/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -154,6 +157,7 @@ describe('StockCardSummaryListController', function() {
program: 'program',
supervised: true,
includeInactive: false,
ward: undefined,
// ANGOLASUP-685: Starts here
page: 0,
size: 10
Expand Down
5 changes: 4 additions & 1 deletion src/stock-card-summary-list/stock-card-summary-list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<h2 ng-if="vm.facility && vm.program">
<h2 ng-if="vm.facility && vm.program && !vm.currentlySelectedWardName">
{{'stockCardSummaryList.title' | message: { 'facility': vm.facility.name, 'program': vm.program.name} }}
</h2>
<h2 ng-if="vm.facility && vm.program && vm.currentlySelectedWardName">
{{'stockCardSummaryList.titleWithWard' | message: { 'facility': vm.facility.name, 'ward': vm.currentlySelectedWardName, 'program': vm.program.name} }}
</h2>
<h2 ng-hide="vm.facility && vm.program">{{'stockCardSummaryList.stockOnHand' | message}}</h2>
<p class="alert is-offline" ng-if="vm.offline()">
{{ 'stockCardSummaryList.offline1' | message}}
Expand Down
10 changes: 9 additions & 1 deletion src/stock-card-summary-list/stock-card-summary-list.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1cc7ef0

Please sign in to comment.