Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAM-187: Hide input when no wards #131

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@
zoneId: facility.geographicZone.id,
sort: 'code,asc',
type: WARDS_CONSTANTS.WARD_TYPE_CODE

};

return wardService.getWardsByFacility(searchParams)
.then(function(response) {
return response.content;
return response.content.filter(function(ward) {
return ward.enabled;
});
});
}

Expand Down
67 changes: 44 additions & 23 deletions src/stock-adjustment-creation/adjustment-creation.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// AO-805: Allow users with proper rights to edit product prices
'OrderableResource', 'permissionService', 'ADMINISTRATION_RIGHTS', 'authorizationService',
// AO-805: Ends here
'unitOfOrderableService', 'wardService', 'orderableGroupsByWard'
'unitOfOrderableService', 'wardService', 'orderableGroupsByWard', 'WARDS_CONSTANTS'
];

function controller($scope, $state, $stateParams, $filter, confirmDiscardService, program,
Expand All @@ -54,7 +54,7 @@
// AO-805: Allow users with proper rights to edit product prices
accessTokenFactory, $window, stockmanagementUrlFactory, OrderableResource, permissionService,
ADMINISTRATION_RIGHTS, authorizationService, unitOfOrderableService, wardService,
orderableGroupsByWard) {
orderableGroupsByWard, WARDS_CONSTANTS) {
// ANGOLASUP-717: ends here
// AO-805: Ends here
var vm = this;
Expand Down Expand Up @@ -1019,33 +1019,54 @@
});
// OAM-5: ends here

vm.displayWardSelect = adjustmentType.state === ADJUSTMENT_TYPE.RECEIVE.state;
if (vm.displayWardSelect) {
wardService.getWardsByFacility({
zoneId: vm.facility.geographicZone.id
}).then(function(response) {
vm.homeFacilityWards = response.content.filter(function(responseFacility) {
return responseFacility.id !== vm.facility.id;
});
if (vm.homeFacilityWards.length > 0) {
var wardNames = vm.homeFacilityWards.map(function(ward) {
return ward.name;
});
wardNames.push(vm.facility.name);
vm.wardsValidSources = vm.srcDstAssignments
.filter(function(assignment) {
return wardNames.includes(assignment.name);
});
}
});
}

setUpWards();
vm.showVVMStatusColumn = orderableGroupService.areOrderablesUseVvm(vm.orderableGroups);
vm.hasPermissionToAddNewLot = hasPermissionToAddNewLot;
vm.canAddNewLot = false;
initiateNewLotObject();
}

function setUpWards() {
if (!vm.facility.geographicZone) {
return;
}

wardService.getWardsByFacility({
zoneId: vm.facility.geographicZone.id,
sort: 'code,asc',
type: WARDS_CONSTANTS.WARD_TYPE_CODE
}).then(function(response) {
var wards = response.content;
var disabledWardsNames = [];

vm.homeFacilityWards = wards.filter(function(ward) {
if (ward.enabled) {
return true;
}
disabledWardsNames.push(ward.name);
return false;
});

vm.displayWardSelect = vm.homeFacilityWards.length > 0;

if (vm.displayWardSelect) {
var wardNames = vm.homeFacilityWards.map(function(ward) {
return ward.name;
});

vm.srcDstAssignments = vm.srcDstAssignments.filter(function(assignment) {
return !disabledWardsNames.includes(assignment.name);
});

wardNames.push(vm.facility.name);
vm.wardsValidSources = vm.srcDstAssignments
.filter(function(assignment) {
return wardNames.includes(assignment.name);
});
}
});
}

function initiateNewLotObject() {
vm.newLot = {
active: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ describe('StockCardSummaryListController', function() {
this.vm.$onInit();

this.vm.facility = {
id: 'facility'
id: 'facility',
geographicZone: {
id: '123'
}
};
this.vm.program = {
id: 'program'
Expand Down
Loading