Skip to content

Commit

Permalink
Merge pull request #105 from OpenLMIS-Angola/OAM-185
Browse files Browse the repository at this point in the history
OAM-185: Merge with OAM-45
  • Loading branch information
DominikNoga authored Jun 3, 2024
2 parents fe34e22 + b378562 commit 7e584ac
Show file tree
Hide file tree
Showing 24 changed files with 915 additions and 39 deletions.
8 changes: 5 additions & 3 deletions src/admin-facility-view/admin-facility-view.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

angular.module('admin-facility-view').config(routes);

routes.$inject = ['$stateProvider', 'ADMINISTRATION_RIGHTS'];
routes.$inject = ['$stateProvider', 'ADMINISTRATION_RIGHTS', 'WARDS_CONSTANTS'];

function routes($stateProvider, ADMINISTRATION_RIGHTS) {
function routes($stateProvider, ADMINISTRATION_RIGHTS, WARDS_CONSTANTS) {

$stateProvider.state('openlmis.administration.facilities.edit', {
label: 'adminFacilityView.editFacility',
Expand Down Expand Up @@ -64,7 +64,9 @@
wards: function(wardService, facility) {
var searchParams = {
zoneId: facility.geographicZone.id,
sort: 'code,asc'
sort: 'code,asc',
type: WARDS_CONSTANTS.WARD_TYPE_CODE

};

return wardService.getWardsByFacility(searchParams).then(function(response) {
Expand Down
29 changes: 21 additions & 8 deletions src/admin-facility-view/facility-view.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
controller.$inject = [
'$q', '$state', 'facility', 'facilityTypes', 'geographicZones', 'facilityOperators',
'programs', 'FacilityRepository', 'loadingModalService', 'notificationService',
'tzPeriodService', 'messageService', 'confirmService', 'wards', 'wardService'
'tzPeriodService', 'messageService', 'confirmService', 'wards', 'wardService',
'WARDS_CONSTANTS'
];

function controller($q, $state, facility, facilityTypes, geographicZones, facilityOperators,
programs, FacilityRepository, loadingModalService, notificationService,
tzPeriodService, messageService, confirmService, wards, wardService) {
tzPeriodService, messageService, confirmService, wards, wardService,
WARDS_CONSTANTS) {

var vm = this;

Expand All @@ -48,6 +50,7 @@
vm.addProgram = addProgram;
vm.addWard = addWard;
vm.deleteProgramAssociate = deleteProgramAssociate;
vm.generateWardCode = generateWardCode;

/**
* @ngdoc property
Expand Down Expand Up @@ -160,6 +163,17 @@
*/
vm.initialWards = [];

/**
* @ngdoc property
* @propertyOf admin-facility-view.controller:FacilityViewController
* @name wardFacilityType
* @type {Object}
*
* @description
* Contains type passed to ward/service
*/
vm.wardFacilityType = undefined;

/**
* @ngdoc method
* @propertyOf admin-facility-view.controller:FacilityViewController
Expand All @@ -180,7 +194,9 @@
vm.initialWards = angular.copy(wards);
vm.selectedTab = 0;
vm.managedExternally = facility.isManagedExternally();
vm.generateWardCode = generateWardCode;
vm.wardFacilityType = facilityTypes.find(function(type) {
return type.code === WARDS_CONSTANTS.WARD_TYPE_CODE;
});
vm.newWard = getInitialNewWardValue();

if (!vm.facilityWithPrograms.supportedPrograms) {
Expand Down Expand Up @@ -312,6 +328,7 @@
var newWard = angular.copy(vm.newWard);

newWard.code = vm.generateWardCode(vm.facility.code);
console.log(newWard.type.code);

vm.addedWards.push(newWard);

Expand All @@ -321,14 +338,10 @@
}

function getInitialNewWardValue() {
var facilityType = facilityTypes.find(function(type) {
return type.code === 'Wards&Services';
});

return {
active: false,
enabled: true,
type: facilityType,
type: vm.wardFacilityType,
geographicZone: vm.facility.geographicZone
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/admin-facility-view/services-and-wards.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
ng-submit="vm.saveFacilityWards()"
>
<table>
<caption ng-if="!vm.wards || vm.wards.length === 0">
<caption ng-if="(!vm.wards || vm.wards.length === 0) && vm.addedWards.length === 0">
{{'adminFacilityView.noAssociatedWards' | message: {facility:
vm.facility.name} }}
</caption>
Expand Down
35 changes: 35 additions & 0 deletions src/admin-facility-view/ward.constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {
'use strict';

/**
* @ngdoc object
* @name openlmis-table.TABLE_CONSTANTS
*
* @description
* Contains constants used in openlmis-table component group.
*/
angular
.module('admin-facility-view')
.constant('WARDS_CONSTANTS', wardsConstants());

function wardsConstants() {
return {
WARD_TYPE_CODE: 'WS'
};
}
})();
8 changes: 5 additions & 3 deletions src/admin-lot-list/admin-lot-list.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
$stateProvider.state('openlmis.administration.lots', {
showInNavigation: true,
label: 'adminLotList.lots',
// ANGOLASUP-715: Filtering by lot code
url: '/lots?orderableId&expirationDateFrom&expirationDateTo&lotCode&page&size&sort',
// ANGOLASUP-715: Ends here
url: '/lots?orderableId&includeQuarantined&expirationDateFrom&expirationDateTo&lotCode&page&size&sort',
controller: 'LotListController',
templateUrl: 'admin-lot-list/lot-list.html',
controllerAs: 'vm',
accessRights: [ADMINISTRATION_RIGHTS.LOTS_MANAGE],
resolve: {
paginatedLots: function($q, $stateParams, paginationService, lotService) {
if (!$stateParams.includeQuarantined && $stateParams.includeQuarantined !== 'false') {
$stateParams.includeQuarantined = 'true';
}

return paginationService.registerUrl($stateParams, function(stateParams) {
var params = angular.copy(stateParams);

Expand Down
6 changes: 4 additions & 2 deletions src/admin-lot-list/admin-lot-list.routes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ describe('openlmis.administration.lot state', function() {
page: 0,
size: 10,
tradeItemIdIgnored: true,
expirationDateFrom: '1970-01-01'
expirationDateFrom: '1970-01-01',
includeQuarantined: 'true'
});

expect(paginatedLots.length).toEqual(1);
Expand All @@ -139,7 +140,8 @@ describe('openlmis.administration.lot state', function() {
page: 0,
size: 10,
tradeItemIdIgnored: true,
expirationDateTo: '1970-01-01'
expirationDateTo: '1970-01-01',
includeQuarantined: 'true'
});

expect(paginatedLots.length).toEqual(1);
Expand Down
12 changes: 12 additions & 0 deletions src/admin-lot-list/lot-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
*/
vm.orderables = [];

/**
* @ngdoc property
* @propertyOf admin-lot-list.controller:LotListController
* @name includeQuarantined
*
* @description
* Include quarantined lots in the list. By default, quarantined lots are included.
*/
vm.includeQuarantined = undefined;

/**
* @ngdoc property
* @propertyOf admin-lot-list.controller:LotListController
Expand Down Expand Up @@ -116,6 +126,7 @@
vm.search = function() {
var stateParams = angular.copy($stateParams);

stateParams.includeQuarantined = vm.includeQuarantined;
stateParams.orderableId = vm.orderableId;
stateParams.expirationDateFrom = vm.expirationDateFrom;
stateParams.expirationDateTo = vm.expirationDateTo;
Expand All @@ -140,6 +151,7 @@
vm.lots = lots;
vm.orderables = orderables;

vm.includeQuarantined = $stateParams.includeQuarantined;
vm.orderableId = $stateParams.orderableId;
vm.expirationDateFrom = $stateParams.expirationDateFrom;
vm.expirationDateTo = $stateParams.expirationDateTo;
Expand Down
12 changes: 12 additions & 0 deletions src/admin-lot-list/lot-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ <h2>{{'adminLotList.lots' | message}}</h2>
<input type="text" id="lotCode" ng-model="vm.lotCode"/>
</fieldset>
<!-- ANGOLASUP-715: Ends here -->
<fieldset class="form-group">
<label for="includeQuarantined" class="checkbox">
<input
type="checkbox"
id="includeQuarantined"
ng-model="vm.includeQuarantined"
ng-true-value="'true'"
ng-false-value="'false'"
/>
{{:: 'adminLotList.includeQuarantined' | message}}
</label>
</fieldset>
<input type="submit" value="{{'adminLotList.search' | message}}"/>
</form>
<openlmis-table table-config="vm.tableConfig"></openlmis-table>
Expand Down
2 changes: 1 addition & 1 deletion src/admin-lot-list/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"adminLotList.manufacturedDate": "Manufacture Date",
"adminLotList.actions": "Actions",
"adminLotList.edit": "Edit",
"adminLotList.showQuarantined": "Show Quarantined",
"adminLotList.includeQuarantined": "Include Quarantined Lots",
"adminLotList.isQuarantined": "Quarantined"
}
10 changes: 7 additions & 3 deletions src/admin-orderable-list/admin-orderable-list.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$stateProvider.state('openlmis.administration.orderables', {
showInNavigation: true,
label: 'adminOrderableList.products',
url: '/orderables?code&name&description&program&page&size&sort',
url: '/orderables?code&includeQuarantined&name&description&program&page&size&sort',
controller: 'OrderableListController',
templateUrl: 'admin-orderable-list/orderable-list.html',
controllerAs: 'vm',
Expand All @@ -40,8 +40,12 @@
return new ProgramResource().query();
},
orderables: function(paginationService, OrderableResource, $stateParams) {
return paginationService.registerUrl($stateParams, function(stateParams) {
return new OrderableResource().query(stateParams);
return paginationService.registerUrl($stateParams, function() {
if (!$stateParams.includeQuarantined && $stateParams.includeQuarantined !== 'false') {
$stateParams.includeQuarantined = 'true';
}

return new OrderableResource().query($stateParams);
});
},
canAdd: function(authorizationService, permissionService, ADMINISTRATION_RIGHTS) {
Expand Down
2 changes: 1 addition & 1 deletion src/admin-orderable-list/messages_en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"adminOrderableList.export": "Export",
"adminOrderableList.showQuarantined": "Show Quarantined",
"adminOrderableList.includeQuarantined": "Include Quarantined Products",
"adminOrderableList.isQuarantined": "Quarantined"
}
12 changes: 12 additions & 0 deletions src/admin-orderable-list/orderable-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
*/
vm.programs = undefined;

/**
* @ngdoc property
* @propertyOf admin-orderable-list.controller:OrderableListController
* @name includeQuarantined
*
* @description
* Contains flag for including quarantined orderables. By default, quarantined products are listed.
*/
vm.includeQuarantined = undefined;

/**
* @ngdoc property
* @propertyOf admin-orderable-list.controller:OrderableListController
Expand Down Expand Up @@ -118,6 +128,7 @@
vm.code = $stateParams.code;
vm.name = $stateParams.name;
vm.program = $stateParams.program;
vm.includeQuarantined = $stateParams.includeQuarantined;

vm.canAdd = canAdd;
vm.tableConfig = getTableConfig();
Expand All @@ -137,6 +148,7 @@
stateParams.code = vm.code;
stateParams.name = vm.name;
stateParams.program = vm.program;
stateParams.includeQuarantined = vm.includeQuarantined;

$state.go('openlmis.administration.orderables', stateParams, {
reload: true
Expand Down
6 changes: 6 additions & 0 deletions src/admin-orderable-list/orderable-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ <h2>{{'adminOrderableList.products' | message}}</h2>
ng-model="vm.program">
</select>
</fieldset>
<fieldset class="form-group">
<label for="includeQuarantined" class="checkbox">
<input type="checkbox" id="includeQuarantined" ng-model="vm.includeQuarantined" ng-true-value="'true'" ng-false-value="'false'" />
{{:: 'adminOrderableList.includeQuarantined' | message}}
</label>
</fieldset>
<input type="submit" value="{{'adminOrderableList.search' | message}}"/>
</form>
<openlmis-table table-config="vm.tableConfig"></openlmis-table>
Expand Down
54 changes: 54 additions & 0 deletions src/admin-user-form/admin-user-form.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {

'use strict';

angular.module('admin-user-form').config(routes);

routes.$inject = ['$stateProvider', 'ADMINISTRATION_RIGHTS'];

function routes($stateProvider, ADMINISTRATION_RIGHTS) {

$stateProvider.state('openlmis.administration.users.form', {
label: 'adminUserForm.addEditUser',
url: '/form/:id',
accessRights: [ADMINISTRATION_RIGHTS.USERS_MANAGE],
resolve: {
facilities: function(facilityService) {
return facilityService.getFacilitiesWithoutWards();
},
user: function(UserService, $stateParams) {
return new UserService().get($stateParams.id);
},
pendingVerificationEmail: function(user, authUserService) {
if (user.id) {
return authUserService.getVerificationEmail(user.id);
}

return undefined;
}
},
views: {
'@openlmis': {
controller: 'UserFormController',
templateUrl: 'admin-user-form/user-form.html',
controllerAs: 'vm'
}
}
});
}
})();
Loading

0 comments on commit 7e584ac

Please sign in to comment.