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-64: init of organizations #80

Merged
merged 12 commits into from
May 23, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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-valid-destination-add')
.config(routes);

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

function routes(modalStateProvider, ADMINISTRATION_RIGHTS) {

modalStateProvider.state('openlmis.administration.validDestination.add', {
controller: 'ValidDestinationAddController',
controllerAs: 'vm',
accessRights: [ADMINISTRATION_RIGHTS.STOCK_DESTINATIONS_MANAGE],
templateUrl: 'admin-valid-destination-add/valid-destination-add.html',
url: '/add',
resolve: {
organizations: organizationsResolve,
geoLevels: geoLevelsResolve
},
parentResolves: [
'facilities',
'facilityTypes',
'geographicLevelMap',
'programs'
]
});

geoLevelsResolve.$inject = ['GeoLevelResource'];

function geoLevelsResolve(GeoLevelResource) {
return new GeoLevelResource().query()
.then(function(resource) {
return resource.content;
});
}

organizationsResolve.$inject = ['OrganizationResource'];

function organizationsResolve(OrganizationResource) {
return new OrganizationResource().query()
.then(function(resource) {
return resource.content;
});
}
}
})();
89 changes: 89 additions & 0 deletions src/admin-valid-destination-add/valid-destination-add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<div class="modal" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1>{{:: 'adminValidDestinationAdd.addValidDestination' | message}}</h1>
</div>
<div class="modal-body">
<form id="add-valid-destination-form" ng-submit="vm.submit()">
<label for="program">
{{:: 'adminValidDestinationAdd.selectProgram' | message}}
</label>
<select id="program"
ng-model="vm.program"
ng-options="p.name for p in vm.programs track by p.id" required>
</select>

<label for="facilityType">
{{:: 'adminValidDestinationAdd.facilityType' | message}}
</label>

<select id="facilityType"
ng-model="vm.facilityType"
ng-options="f.name for f in vm.facilityTypes track by f.id" required>
</select>

<label for="facilityUnitType">
<input
id="facilityUnitType"
type="radio"
ng-model="vm.unitType"
value="facility"
required>
{{:: 'adminValidDestinationAdd.isFacility' | message}}
</label>

<label for="organizationUnitType">
<input
id="organizationUnitType"
type="radio"
ng-model="vm.unitType"
value="organization"
required>
{{:: 'adminValidDestinationAdd.isOrganization' | message}}
</label>

<div ng-if="vm.unitType === 'organization'">
<label for="organization">
{{:: 'adminValidDestinationAdd.organization' | message}}
</label>

<select id="organization"
ng-model="vm.organization"
ng-options="(o.disabled ? o.name + ' [DISABLED]' : o.name) for o in vm.organizations track by o.id" required>
</select>
</div>

<div ng-if="vm.unitType === 'facility'">
<label for="facility">
{{:: 'adminValidDestinationAdd.facility' | message}}
</label>

<select id="facility"
ng-model="vm.facility"
ng-options="f.name for f in vm.facilities track by f.id" required>
</select>
</div>

<label for="geoLevelAffinity">
{{:: 'adminValidDestinationAdd.geoLevelAffinity' | message}}
</label>

<select id="geoLevelAffinity"
ng-model="vm.geoLevel"
ng-options="g.code for g in vm.geoLevels track by g.id">
</select>
</form>
</div>
<div class="modal-footer">
<button id="cancel" ng-click="vm.goToPreviousState()">
{{:: 'adminValidDestinationAdd.cancel' | message}}
</button>
<button class="primary" form="add-valid-destination-form">
{{:: 'adminValidDestinationAdd.add' | message}}
</button>
</div>
</div>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
size: params.size,
page: params.page,
programId: params.programId,
facilityId: params.facilityId
facilityId: params.facilityId,
includeDisabled: true
});
});
},
Expand Down
64 changes: 64 additions & 0 deletions src/admin-valid-source-add/admin-valid-source-add.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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-valid-source-add')
.config(routes);

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

function routes(modalStateProvider, ADMINISTRATION_RIGHTS) {

modalStateProvider.state('openlmis.administration.validSource.add', {
controller: 'ValidSourceAddController',
controllerAs: 'vm',
accessRights: [ADMINISTRATION_RIGHTS.STOCK_SOURCES_MANAGE],
templateUrl: 'admin-valid-source-add/valid-source-add.html',
url: '/add',
resolve: {
organizations: organizationsResolve,
geoLevels: geoLevelsResolve
},
parentResolves: [
'facilities',
'facilityTypes',
'geographicLevelMap',
'programs'
]
});

geoLevelsResolve.$inject = ['GeoLevelResource'];

function geoLevelsResolve(GeoLevelResource) {
return new GeoLevelResource().query()
.then(function(resource) {
return resource.content;
});
}

organizationsResolve.$inject = ['OrganizationResource'];

function organizationsResolve(OrganizationResource) {
return new OrganizationResource().query()
.then(function(resource) {
return resource.content;
});
}
}
})();
89 changes: 89 additions & 0 deletions src/admin-valid-source-add/valid-source-add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<div class="modal" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1>{{:: 'adminValidSourceAdd.addValidSource' | message}}</h1>
</div>
<div class="modal-body">
<form id="add-valid-source-form" ng-submit="vm.submit()">
<label for="program">
{{:: 'adminValidSourceAdd.selectProgram' | message}}
</label>
<select id="program"
ng-model="vm.program"
ng-options="p.name for p in vm.programs track by p.id" required>
</select>

<label for="facilityType">
{{:: 'adminValidSourceAdd.facilityType' | message}}
</label>

<select id="facilityType"
ng-model="vm.facilityType"
ng-options="f.name for f in vm.facilityTypes track by f.id" required>
</select>

<label for="facilityUnitType">
<input
id="facilityUnitType"
type="radio"
ng-model="vm.unitType"
value="facility"
required>
{{:: 'adminValidSourceAdd.isFacility' | message}}
</label>

<label for="organizationUnitType">
<input
id="organizationUnitType"
type="radio"
ng-model="vm.unitType"
value="organization"
required>
{{:: 'adminValidSourceAdd.isOrganization' | message}}
</label>

<div ng-if="vm.unitType === 'organization'">
<label for="organization">
{{'adminValidSourceAdd.organization' | message}}
</label>

<select id="organization"
ng-model="vm.organization"
ng-options="(o.disabled ? o.name + ' [DISABLED]' : o.name) for o in vm.organizations track by o.id" required>
</select>
</div>

<div ng-if="vm.unitType === 'facility'">
<label for="facility">
{{:: 'adminValidSourceAdd.facility' | message}}
</label>

<select id="facility"
ng-model="vm.facility"
ng-options="f.name for f in vm.facilities track by f.id" required>
</select>
</div>

<label for="geoLevelAffinity">
{{:: 'adminValidSourceAdd.geoLevelAffinity' | message}}
</label>

<select id="geoLevelAffinity"
ng-model="vm.geoLevel"
ng-options="g.code for g in vm.geoLevels track by g.id">
</select>
</form>
</div>
<div class="modal-footer">
<button id="cancel" ng-click="vm.goToPreviousState()">
{{:: 'adminValidSourceAdd.cancel' | message}}
</button>
<button class="primary" form="add-valid-source-form">
{{:: 'adminValidSourceAdd.add' | message}}
</button>
</div>
</div>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
size: params.size,
page: params.page,
programId: params.programId,
facilityId: params.facilityId
facilityId: params.facilityId,
includeDisabled: true
});
});
},
Expand Down
1 change: 1 addition & 0 deletions src/openlmis-rights/administration-rights.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
ORDER_CREATE: 'ORDER_CREATE',
DATA_EXPORT: 'DATA_EXPORT',
DATA_IMPORT: 'DATA_IMPORT',
STOCK_ORGANIZATIONS_MANAGE: 'STOCK_ORGANIZATIONS_MANAGE',
// AO-805: Allow users with proper rights to edit product prices
EDIT_PRODUCT_PRICE_STOCK_MANAGEMENT: 'EDIT_PRODUCT_PRICE_STOCK_MANAGEMENT'
// AO-805: Ends here
Expand Down
11 changes: 11 additions & 0 deletions src/organization-add/messages_en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"organizationAdd.addOrganization": "Add Organization",
"organizationAdd.cancel": "Cancel",
"organizationAdd.save": "Save",
"organizationAdd.create": "Create",
"organizationAdd.organizationName": "Organization Name",
"organizationAdd.disabled": "Disabled",
"organizationAdd.confirmationPrompt": "Are you sure you want to create organization?",
"organizationAdd.organizationCreated": "Organization created successfully.",
"organizationAdd.organizationCreateError": "Error while creating organization."
}
Loading
Loading