Skip to content

Commit

Permalink
Merge pull request #76 from villagereach/SELV3-775
Browse files Browse the repository at this point in the history
SELV3-775: Added translations to home page alerts
  • Loading branch information
olewandowski1 authored Nov 18, 2024
2 parents 190006d + 2549180 commit e7b0510
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/openlmis-home-alerts-panel/messages_en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"alerts.panel.title": "My Facility data",
"label.requisitionsToBeCreated": "Number of Requisitions to be created this month",
"label.messagesIssuedBySystem": "Number of Messages or issued by by the system",
"label.lateCreationOfInventories": "Late creation of inventories",
"label.updatesOfRequisitions": "Updates on requisitions",
"label.updatesOfOrdersAndPod": "Updates on orders and POD",
"requisition.status.APPROVED": "Approved",
"requisition.status.AUTHORIZED": "Authorized",
"requisition.status.INITIATED": "Initiated",
"requisition.status.IN_APPROVAL": "In Approval",
"requisition.status.REJECTED": "Rejected",
"requisition.status.RELEASED": "Released",
"requisition.status.RELEASED_WITHOUT_ORDER": "Released Without Order",
"requisition.status.SKIPPED": "Skipped",
"requisition.status.SUBMITTED": "Submitted",
"orders.status.CREATING": "Creating",
"orders.status.FULFILLING": "Fulfilling",
"orders.status.IN_ROUTE": "In Route",
"orders.status.ORDERED": "Ordered",
"orders.status.READY_TO_PACK": "Ready To Pack",
"orders.status.RECEIVED": "Received",
"orders.status.SHIPPED": "Shipped",
"orders.status.TRANSFER_FAILED": "Transfer Failed"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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('openlmis-home-alerts-panel')
.controller('openlmisHomeAlertsPanelController', controller);

controller.$inject = ['openlmisHomeAlertsPanelService'];

function controller(openlmisHomeAlertsPanelService) {
var $ctrl = this;
$ctrl.requisitionsStatusesStats = undefined;
$ctrl.ordersStatusesStats = undefined;
$ctrl.requisitionsToBeCreated = undefined;
var requisitionsImportantData = ['SUBMITTED', 'AUTHORIZED', 'IN_APPROVAL'];
var ordersImportantData = ['ORDERED', 'FULFILLING', 'SHIPPED', 'IN_ROUTE'];
var REQUISITION_PREFIX = 'requisition';
var ORDERS_PREFIX = 'orders';

$ctrl.$onInit = onInit;

function onInit() {
openlmisHomeAlertsPanelService.getRequisitionsStatusesData()
.then(function(requisitionsData) {
$ctrl.requisitionsStatusesStats =
openlmisHomeAlertsPanelService.
getMappedStatussesStats(
REQUISITION_PREFIX,
requisitionsData.statusesStats,
requisitionsImportantData
);

$ctrl.requisitionsToBeCreated = requisitionsData.requisitionsToBeCreated;
});

openlmisHomeAlertsPanelService.getOrdersStatusesData()
.then(function(ordersData) {
$ctrl.ordersStatusesStats =
openlmisHomeAlertsPanelService.
getMappedStatussesStats(ORDERS_PREFIX, ordersData.statusesStats, ordersImportantData);
});
}
}
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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('openlmis-home-alerts-panel')
.service('openlmisHomeAlertsPanelService', openlmisHomeAlertsPanelService);

openlmisHomeAlertsPanelService.$inject = ['$resource', 'openlmisUrlFactory', 'messageService'];

function openlmisHomeAlertsPanelService($resource, openlmisUrlFactory, messageService) {
var STATUS_PREFIX = 'status';
var requisitionStatusesResource = $resource(
openlmisUrlFactory('/api'), {}, {
get: {
method: 'GET',
url: openlmisUrlFactory('/api/requisitions/statusesStatsData')
}
}
);

var orderStatusesResource = $resource(
openlmisUrlFactory('/api/orders/statusesStatsData'), {}, {
get: {
method: 'GET',
url: openlmisUrlFactory('/api/orders/statusesStatsData')
}
}
);

return {
getRequisitionsStatusesData: getRequisitionsStatusesData,
getOrdersStatusesData: getOrdersStatusesData,
getMappedStatussesStats: getMappedStatussesStats
};

function getRequisitionsStatusesData() {
return requisitionStatusesResource.get().$promise;
}

function getOrdersStatusesData() {
return orderStatusesResource.get().$promise;
}

function getMappedStatussesStats(tableName, statusesStats, importantData) {
var mappedStatussesStats = [];

for (var statName in statusesStats) {
mappedStatussesStats.push({
key: getTranslatedKey(tableName, statName),
value: statusesStats[statName],
isImportant: importantData.indexOf(statName) !== -1
});
}

return mappedStatussesStats;
}

function getTranslatedKey(tableName, statName) {
var key = tableName + '.' + STATUS_PREFIX + '.' + statName;
return messageService.get(key);
}
}
})();

0 comments on commit e7b0510

Please sign in to comment.