Skip to content

Commit c775085

Browse files
committed
A-1208424039194249 | Translate Program attributes in active tab
1 parent 443c1ea commit c775085

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
angular.module('bahmni.common.uicontrols.programmanagment')
4-
.controller('ManageProgramController', ['$scope', 'retrospectiveEntryService', '$window', 'programService',
4+
.controller('ManageProgramController', ['$scope', 'retrospectiveEntryService', '$window', 'programService', '$translate',
55
'spinner', 'messagingService', '$stateParams', '$q', 'confirmBox', '$state',
6-
function ($scope, retrospectiveEntryService, $window, programService,
6+
function ($scope, retrospectiveEntryService, $window, programService, $translate,
77
spinner, messagingService, $stateParams, $q, confirmBox, $state) {
88
var DateUtil = Bahmni.Common.Util.DateUtil;
99
$scope.programSelected = {};
@@ -221,12 +221,12 @@ angular.module('bahmni.common.uicontrols.programmanagment')
221221

222222
$scope.confirmDeletion = function (patientProgram) {
223223
var scope = {};
224-
scope.message = 'Are you sure, you want to delete ' + patientProgram.display + '?';
224+
scope.message = $translate.instant('PROGRAM_DELETE_POPUP_MESSAGE_KEY', {programName: patientProgram.display});
225225
scope.cancel = _.partial(unVoidPatientProgram, patientProgram, _);
226226
scope.delete = _.partial(voidPatientProgram, patientProgram, _);
227227
confirmBox({
228228
scope: scope,
229-
actions: [{ name: 'cancel', display: 'cancel' }, { name: 'delete', display: 'delete' }],
229+
actions: [{ name: 'cancel', display: $translate.instant('PROGRAM_DELETE_POPUP_CANCEL_KEY') }, { name: 'delete', display: $translate.instant('PROGRAM_DELETE_POPUP_DELETE_KEY') }],
230230
className: "ngdialog-theme-default delete-program-popup"
231231
});
232232
};

ui/app/common/uicontrols/programmanagement/directive/programAttributes.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('bahmni.common.uicontrols.programmanagment')
4-
.controller('ProgramAttributesController', ['$scope', function ($scope) {
4+
.controller('ProgramAttributesController', ['$scope', '$translate', function ($scope, $translate) {
55
var program = $scope.patientProgram.program;
66
$scope.getProgramAttributesMap = function () {
77
var programAttributesMap = {};
@@ -23,6 +23,11 @@ angular.module('bahmni.common.uicontrols.programmanagment')
2323
return programAttributesMap;
2424
};
2525

26+
$scope.getTranslatedAttributeTypes = function (attribute) {
27+
var translatedName = Bahmni.Common.Util.TranslationUtil.translateAttribute(attribute, Bahmni.Common.Constants.patientAttribute, $translate);
28+
return translatedName;
29+
};
30+
2631
$scope.getValueForAttributeType = function (attributeType) {
2732
var programAttributesMap = $scope.patientProgram.patientProgramAttributes;
2833

ui/app/common/uicontrols/programmanagement/views/programAttributes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="form-field" ng-repeat="attributeType in programAttributeTypes" ng-show="!patientProgram.editing" ng-if="isIncluded(attributeType)">
22
<div class="field-attribute">
3-
<label>{{attributeType.description}} : </label>
3+
<label>{{::getTranslatedAttributeTypes(attributeType.description) | translate}} : </label>
44
</div>
55
<div class="field-value">
66
<span>

ui/app/i18n/clinical/locale_en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
"ENTER_DIAGNOSIS_ERROR": "Primary diagnosis has not been captured. Prescription cannot be created",
175175
"PATIENT_WEIGHT_AND_DIAGNOSIS_ERROR": "Patient weight has not been captured recently & no primary diagnosis is found. Prescription cannot be created",
176176

177+
"PROGRAM_DELETE_POPUP_MESSAGE_KEY": "Are you sure, you want to delete {{ programName }} ?",
178+
"PROGRAM_DELETE_POPUP_CANCEL_KEY": "Cancel",
179+
"PROGRAM_DELETE_POPUP_DELETE_KEY": "Delete",
177180
"DRUG_DETAILS_DRUG_NAME": "Drug",
178181
"DRUG_DETAILS_DOSE_INFO": "Dose",
179182
"DRUG_DETAILS_ROUTE": "Route",

ui/app/i18n/clinical/locale_fr.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,5 +362,8 @@
362362
"SIGN_SYMPTOM_DURATION_KEY": "Durée des signes/symptômes",
363363
"CHIEF_COMPLAINT_DURATION_UNIT_KEY": "Durée de la plainte principale",
364364
"IPD_BUTTON": "IPD",
365-
"OPD_BUTTON": "OPD"
365+
"OPD_BUTTON": "OPD",
366+
"PROGRAM_DELETE_POPUP_MESSAGE_KEY": "Êtes-vous sûr de vouloir supprimer {{ programName }} ?",
367+
"PROGRAM_DELETE_POPUP_CANCEL_KEY": "Annuler",
368+
"PROGRAM_DELETE_POPUP_DELETE_KEY": "Supprimer"
366369
}

ui/test/unit/common/uicontrols/programmanagement/controllers/manageProgramController.spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ describe("ManageProgramController", function () {
44

55
var scope, messageService, i = 0, programService, _provide, deferred, q, _spinner,
66
retrospectiveEntryService, listOfPatientPrograms, programAttributeTypes, allPrograms,
7-
controller, rootScope, confirmBox, state;
7+
controller, rootScope, confirmBox, state, translate;
88

99
var setUp = function () {
1010
return controller('ManageProgramController', {
1111
$state: state,
1212
$scope: scope,
1313
$rootScope: rootScope,
1414
q: q,
15-
confirmBox: confirmBox
15+
confirmBox: confirmBox,
16+
$translate: translate
1617
});
1718
};
1819

@@ -30,6 +31,11 @@ describe("ManageProgramController", function () {
3031
return deferred.promise;
3132
});
3233

34+
translate = jasmine.createSpyObj('$translate', ['instant']);
35+
translate.instant.and.callFake(function (key) {
36+
return key;
37+
});
38+
3339
programService.getPatientPrograms.and.callFake(function () {
3440
deferred = q.defer();
3541
deferred.resolve(listOfPatientPrograms);
@@ -71,6 +77,7 @@ describe("ManageProgramController", function () {
7177
$provide.value('messagingService', messageService);
7278
$provide.value('retrospectiveEntryService', retrospectiveEntryService);
7379
$provide.value('$stateParams', { configName: "default" });
80+
$provide.value('$translate', translate);
7481
}));
7582

7683
beforeEach(inject(function ($controller, $rootScope, $q) {

ui/test/unit/common/uicontrols/programmanagement/directives/programAttributes.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
describe("ensure that the directive program-attributes works properly", function () {
44

5-
var scope,filter;
5+
var scope, translate, filter;
66

77
beforeEach(module('bahmni.common.uicontrols.programmanagment'));
88

9-
beforeEach(inject(function ($controller, $rootScope,$filter) {
9+
beforeEach(inject(function ($controller, $rootScope, $filter) {
1010
scope = $rootScope.$new();
1111
scope.patientProgram = patientProgram;
1212
scope.programAttributeTypes = attributeTypes;
1313
filter = $filter;
1414
$controller('ProgramAttributesController', {
15-
$scope: scope
15+
$scope: scope,
16+
$translate: translate
1617
});
1718
}));
1819

0 commit comments

Comments
 (0)