-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from OpenLMIS-Angola/OAM-205
OAM-205
- Loading branch information
Showing
13 changed files
with
337 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"openlmisFacilityProgramSelect.facility": "Facility", | ||
"openlmisFacilityProgramSelect.facilityType": "Facility Type", | ||
"openlmisFacilityProgramSelect.myFacility": "My Facility", | ||
"openlmisFacilityProgramSelect.program": "Program", | ||
"openlmisFacilityProgramSelect.supervisedFacility": "Supervised Facility", | ||
"openlmisFacilityProgramSelect.selectFacility": "Select Facility", | ||
"openlmisFacilityProgramSelect.selectProgram": "Select Program", | ||
"openlmisFacilityProgramSelect.type": "Type", | ||
"openlmisFacilityProgramSelect.selectWard": "Select Ward", | ||
"openlmisFacilityProgramSelect.ward": "Ward" | ||
} |
54 changes: 54 additions & 0 deletions
54
src/openlmis-facility-program-select/openlmis-facility-program-select.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
||
/** | ||
* @ngdoc service | ||
* @name openlmis-facility-program-select.component:openlmisFacilityProgramSelect | ||
* | ||
* @description | ||
* Component responsible for selecting facility, facility type and program. This component will | ||
* look for supervised, facility and program parameters in the state parameters to set the | ||
* initial values, module parameter is for recognizing module where this component is used. | ||
* @example | ||
* ``` | ||
* <openlmis-facility-program-select | ||
* is-supervised="vm.supervisedFlag" | ||
* program="vm.programObject" | ||
* facility="vm.facilityObject" | ||
* module="'openlmis-some-module-name'"> | ||
* </openlmis-facility-program-select> | ||
* ``` | ||
*/ | ||
angular | ||
.module('openlmis-facility-program-select') | ||
.component('openlmisFacilityProgramSelect', { | ||
bindings: { | ||
isSupervised: '=', | ||
program: '=', | ||
facility: '=', | ||
module: '=?', | ||
selectedWard: '=?' | ||
}, | ||
controller: 'OpenlmisFacilityProgramSelectController', | ||
controllerAs: 'vm', | ||
templateUrl: 'openlmis-facility-program-select/openlmis-facility-program-select.html' | ||
}); | ||
|
||
})(); |
133 changes: 133 additions & 0 deletions
133
src/openlmis-facility-program-select/openlmis-facility-program-select.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* 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 controller | ||
* @name openlmis-facility-program-select.controller:OpenlmisFacilityProgramSelectController | ||
* | ||
* @description | ||
* Controller responsible for facilities and programs for the openlmis-facility-program-select | ||
* component. | ||
*/ | ||
angular | ||
.module('openlmis-facility-program-select') | ||
.controller('OpenlmisFacilityProgramSelectController', controller); | ||
|
||
controller.$inject = ['$q', '$stateParams', '$filter', 'facilityProgramCacheService', 'wardService', | ||
'WARDS_CONSTANTS']; | ||
|
||
function controller($q, $stateParams, $filter, facilityProgramCacheService, wardService, WARDS_CONSTANTS) { | ||
|
||
var vm = this; | ||
|
||
vm.$onInit = onInit; | ||
vm.updateForm = updateForm; | ||
vm.updateFacilities = updateFacilities; | ||
vm.homeFacilityWards = []; | ||
|
||
/** | ||
* @ngdoc method | ||
* @methodOf openlmis-facility-program-select.controller:OpenlmisFacilityProgramSelectController | ||
* @name $onInit | ||
* | ||
* @description | ||
* Initialization method of the controller. | ||
*/ | ||
function onInit() { | ||
facilityProgramCacheService.loadData(vm.module) | ||
.then(function() { | ||
vm.homeFacility = facilityProgramCacheService.getUserHomeFacility(); | ||
vm.supervisedPrograms = facilityProgramCacheService.getUserPrograms(true); | ||
vm.isSupervised = $stateParams.supervised === 'true' || !vm.homeFacility; | ||
vm.programs = facilityProgramCacheService.getUserPrograms(vm.isSupervised); | ||
|
||
if ($stateParams.program) { | ||
vm.program = $filter('filter')(vm.programs, | ||
{ | ||
id: $stateParams.program | ||
})[0]; | ||
} | ||
|
||
vm.updateFacilities(); | ||
|
||
return getHomeFacilityWards(vm.homeFacility).then(function(wards) { | ||
vm.homeFacilityWards = wards ? wards : []; | ||
}); | ||
}); | ||
} | ||
|
||
function getHomeFacilityWards(facility) { | ||
var searchParams = { | ||
zoneId: facility.geographicZone.id, | ||
sort: 'code,asc', | ||
type: WARDS_CONSTANTS.WARD_TYPE_CODE | ||
|
||
}; | ||
|
||
return wardService.getWardsByFacility(searchParams) | ||
.then(function(response) { | ||
return response.content; | ||
}); | ||
} | ||
|
||
/** | ||
* @ngdoc method | ||
* @methodOf openlmis-facility-program-select.controller:OpenlmisFacilityProgramSelectController | ||
* @name updateForm | ||
* | ||
* @description | ||
* Updates the form by clearing program and facility selection and setting appropriate | ||
* lists. | ||
*/ | ||
function updateForm() { | ||
vm.program = undefined; | ||
vm.programs = facilityProgramCacheService.getUserPrograms(vm.isSupervised); | ||
vm.updateFacilities(); | ||
} | ||
|
||
/** | ||
* @ngdoc method | ||
* @methodOf openlmis-facility-program-select.controller:OpenlmisFacilityProgramSelectController | ||
* @name updateFacilities | ||
* | ||
* @description | ||
* Updates the facility list by clearing the facility selection and setting appropriate | ||
* facility list. | ||
*/ | ||
function updateFacilities() { | ||
vm.facility = undefined; | ||
|
||
if (!vm.isSupervised) { | ||
vm.facilities = [vm.homeFacility]; | ||
vm.facility = vm.facilities[0]; | ||
} else if (vm.program) { | ||
vm.facilities = facilityProgramCacheService.getSupervisedFacilities(vm.program.id); | ||
if ($stateParams.facility) { | ||
vm.facility = $filter('filter')(vm.facilities, | ||
{ | ||
id: $stateParams.facility | ||
})[0]; | ||
} | ||
} else { | ||
vm.facilities = []; | ||
} | ||
} | ||
} | ||
|
||
})(); |
65 changes: 65 additions & 0 deletions
65
src/openlmis-facility-program-select/openlmis-facility-program-select.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<fieldset class="form-group"> | ||
|
||
<legend>{{'openlmisFacilityProgramSelect.facilityType' | message}}</legend> | ||
|
||
<label class="radio"> | ||
<input type="radio" | ||
ng-model="vm.isSupervised" | ||
ng-disabled="!vm.homeFacility" | ||
ng-value="false" | ||
ng-change="vm.updateForm()"/> | ||
{{'openlmisFacilityProgramSelect.myFacility' | message}} | ||
</label> | ||
|
||
<label class="radio"> | ||
<input type="radio" | ||
ng-model="vm.isSupervised" | ||
ng-disabled="vm.supervisedPrograms.length == 0" | ||
ng-value="true" | ||
ng-change="vm.updateForm()"/> | ||
{{'openlmisFacilityProgramSelect.supervisedFacility' | message}} | ||
</label> | ||
|
||
</fieldset> | ||
<fieldset class="form-group" ng-if="!vm.isSupervised"> | ||
|
||
<label for="facilityName">{{'openlmisFacilityProgramSelect.facility' | message}}</label> | ||
<select id="facilityName" | ||
ng-model="vm.facility" | ||
ng-options="facility as facility.name for facility in vm.facilities" | ||
placeholder="{{'openlmisFacilityProgramSelect.selectFacility' | message}}" | ||
disabled | ||
required></select> | ||
|
||
<label for="myFacilityWard">{{'openlmisFacilityProgramSelect.ward' | message}}</label> | ||
<select id="myFacilityWard" | ||
ng-model="vm.selectedWard" | ||
ng-options="ward as ward.name for ward in vm.homeFacilityWards track by ward.id" | ||
placeholder="{{'openlmisFacilityProgramSelect.selectWard' | message}}"></select> | ||
|
||
<label for="programListMyFacility">{{'openlmisFacilityProgramSelect.program' | message}}</label> | ||
<select id="programListMyFacility" | ||
ng-model="vm.program" | ||
ng-options="program as program.name for program in vm.programs | orderBy:'name' track by program.id" | ||
placeholder="{{'openlmisFacilityProgramSelect.selectProgram' | message}}" | ||
required></select> | ||
|
||
</fieldset> | ||
<fieldset class="form-group" ng-if="vm.isSupervised"> | ||
|
||
<label for="programListSupervisedFacility">{{'openlmisFacilityProgramSelect.program' | message}}</label> | ||
<select id="programListSupervisedFacility" | ||
ng-model="vm.program" | ||
ng-options="program as program.name for program in vm.programs | orderBy:'name' track by program.id" | ||
ng-change="vm.updateFacilities()" | ||
placeholder="{{'openlmisFacilityProgramSelect.selectProgram' | message}}" | ||
required></select> | ||
|
||
<label for="supervisedFacilityName">{{'openlmisFacilityProgramSelect.facility' | message}}</label> | ||
<select id="supervisedFacilityName" | ||
ng-model="vm.facility" | ||
ng-options="facility as facility.name for facility in vm.facilities | unique:'id' | orderBy:'name' track by facility.id" | ||
placeholder="{{'openlmisFacilityProgramSelect.selectFacility' | message}}" | ||
required></select> | ||
|
||
</fieldset> |
36 changes: 36 additions & 0 deletions
36
src/openlmis-facility-program-select/openlmis-facility-program-select.module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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'; | ||
|
||
/** | ||
* @module openlmis-facility-program-select | ||
* | ||
* @description | ||
* Proved openlmis-facility-program-select component for selecting facility and program. | ||
*/ | ||
angular.module('openlmis-facility-program-select', [ | ||
'referencedata-facility', | ||
'referencedata-program', | ||
'referencedata-user', | ||
'openlmis-auth', | ||
'openlmis-permissions', | ||
'referencedata-user', | ||
'admin-facility-view' | ||
]); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.