From c5900859e679d757bb4d63dd7f54b2f234c969a6 Mon Sep 17 00:00:00 2001 From: Arjun G <91885483+Arjun-Go@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:19:59 +0530 Subject: [PATCH] A-1208424039194249 | Translate Program attributes in active tab (#1009) --- .../controllers/manageProgramController.js | 8 ++++---- .../programmanagement/directive/programAttributes.js | 7 ++++++- .../programmanagement/views/programAttributes.html | 2 +- ui/app/i18n/clinical/locale_en.json | 3 +++ ui/app/i18n/clinical/locale_fr.json | 5 ++++- .../controllers/manageProgramController.spec.js | 11 +++++++++-- .../directives/programAttributes.spec.js | 7 ++++--- 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js b/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js index f40575ee54..a6edc1a4c2 100644 --- a/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js +++ b/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js @@ -1,9 +1,9 @@ 'use strict'; angular.module('bahmni.common.uicontrols.programmanagment') - .controller('ManageProgramController', ['$scope', 'retrospectiveEntryService', '$window', 'programService', + .controller('ManageProgramController', ['$scope', 'retrospectiveEntryService', '$window', 'programService', '$translate', 'spinner', 'messagingService', '$stateParams', '$q', 'confirmBox', '$state', - function ($scope, retrospectiveEntryService, $window, programService, + function ($scope, retrospectiveEntryService, $window, programService, $translate, spinner, messagingService, $stateParams, $q, confirmBox, $state) { var DateUtil = Bahmni.Common.Util.DateUtil; $scope.programSelected = {}; @@ -221,12 +221,12 @@ angular.module('bahmni.common.uicontrols.programmanagment') $scope.confirmDeletion = function (patientProgram) { var scope = {}; - scope.message = 'Are you sure, you want to delete ' + patientProgram.display + '?'; + scope.message = $translate.instant('PROGRAM_DELETE_POPUP_MESSAGE_KEY', {programName: patientProgram.display}); scope.cancel = _.partial(unVoidPatientProgram, patientProgram, _); scope.delete = _.partial(voidPatientProgram, patientProgram, _); confirmBox({ scope: scope, - actions: [{ name: 'cancel', display: 'cancel' }, { name: 'delete', display: 'delete' }], + actions: [{ name: 'cancel', display: $translate.instant('PROGRAM_DELETE_POPUP_CANCEL_KEY') }, { name: 'delete', display: $translate.instant('PROGRAM_DELETE_POPUP_DELETE_KEY') }], className: "ngdialog-theme-default delete-program-popup" }); }; diff --git a/ui/app/common/uicontrols/programmanagement/directive/programAttributes.js b/ui/app/common/uicontrols/programmanagement/directive/programAttributes.js index 9c21449053..55f9c8a8ba 100644 --- a/ui/app/common/uicontrols/programmanagement/directive/programAttributes.js +++ b/ui/app/common/uicontrols/programmanagement/directive/programAttributes.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('bahmni.common.uicontrols.programmanagment') - .controller('ProgramAttributesController', ['$scope', function ($scope) { + .controller('ProgramAttributesController', ['$scope', '$translate', function ($scope, $translate) { var program = $scope.patientProgram.program; $scope.getProgramAttributesMap = function () { var programAttributesMap = {}; @@ -23,6 +23,11 @@ angular.module('bahmni.common.uicontrols.programmanagment') return programAttributesMap; }; + $scope.getTranslatedAttributeTypes = function (attribute) { + var translatedName = Bahmni.Common.Util.TranslationUtil.translateAttribute(attribute, Bahmni.Common.Constants.patientAttribute, $translate); + return translatedName; + }; + $scope.getValueForAttributeType = function (attributeType) { var programAttributesMap = $scope.patientProgram.patientProgramAttributes; diff --git a/ui/app/common/uicontrols/programmanagement/views/programAttributes.html b/ui/app/common/uicontrols/programmanagement/views/programAttributes.html index d3d82afeeb..ef4724b8c3 100644 --- a/ui/app/common/uicontrols/programmanagement/views/programAttributes.html +++ b/ui/app/common/uicontrols/programmanagement/views/programAttributes.html @@ -1,6 +1,6 @@
- +
diff --git a/ui/app/i18n/clinical/locale_en.json b/ui/app/i18n/clinical/locale_en.json index 78997c7efc..f5009e149a 100644 --- a/ui/app/i18n/clinical/locale_en.json +++ b/ui/app/i18n/clinical/locale_en.json @@ -174,6 +174,9 @@ "ENTER_DIAGNOSIS_ERROR": "Primary diagnosis has not been captured. Prescription cannot be created", "PATIENT_WEIGHT_AND_DIAGNOSIS_ERROR": "Patient weight has not been captured recently & no primary diagnosis is found. Prescription cannot be created", + "PROGRAM_DELETE_POPUP_MESSAGE_KEY": "Are you sure, you want to delete {{ programName }} ?", + "PROGRAM_DELETE_POPUP_CANCEL_KEY": "Cancel", + "PROGRAM_DELETE_POPUP_DELETE_KEY": "Delete", "DRUG_DETAILS_DRUG_NAME": "Drug", "DRUG_DETAILS_DOSE_INFO": "Dose", "DRUG_DETAILS_ROUTE": "Route", diff --git a/ui/app/i18n/clinical/locale_fr.json b/ui/app/i18n/clinical/locale_fr.json index 0cc29c49f2..506ae2ef8b 100644 --- a/ui/app/i18n/clinical/locale_fr.json +++ b/ui/app/i18n/clinical/locale_fr.json @@ -362,5 +362,8 @@ "SIGN_SYMPTOM_DURATION_KEY": "Durée des signes/symptômes", "CHIEF_COMPLAINT_DURATION_UNIT_KEY": "Durée de la plainte principale", "IPD_BUTTON": "IPD", - "OPD_BUTTON": "OPD" + "OPD_BUTTON": "OPD", + "PROGRAM_DELETE_POPUP_MESSAGE_KEY": "Êtes-vous sûr de vouloir supprimer {{ programName }} ?", + "PROGRAM_DELETE_POPUP_CANCEL_KEY": "Annuler", + "PROGRAM_DELETE_POPUP_DELETE_KEY": "Supprimer" } \ No newline at end of file diff --git a/ui/test/unit/common/uicontrols/programmanagement/controllers/manageProgramController.spec.js b/ui/test/unit/common/uicontrols/programmanagement/controllers/manageProgramController.spec.js index 5bc993f369..b0dd5febbf 100644 --- a/ui/test/unit/common/uicontrols/programmanagement/controllers/manageProgramController.spec.js +++ b/ui/test/unit/common/uicontrols/programmanagement/controllers/manageProgramController.spec.js @@ -4,7 +4,7 @@ describe("ManageProgramController", function () { var scope, messageService, i = 0, programService, _provide, deferred, q, _spinner, retrospectiveEntryService, listOfPatientPrograms, programAttributeTypes, allPrograms, - controller, rootScope, confirmBox, state; + controller, rootScope, confirmBox, state, translate; var setUp = function () { return controller('ManageProgramController', { @@ -12,7 +12,8 @@ describe("ManageProgramController", function () { $scope: scope, $rootScope: rootScope, q: q, - confirmBox: confirmBox + confirmBox: confirmBox, + $translate: translate }); }; @@ -30,6 +31,11 @@ describe("ManageProgramController", function () { return deferred.promise; }); + translate = jasmine.createSpyObj('$translate', ['instant']); + translate.instant.and.callFake(function (key) { + return key; + }); + programService.getPatientPrograms.and.callFake(function () { deferred = q.defer(); deferred.resolve(listOfPatientPrograms); @@ -71,6 +77,7 @@ describe("ManageProgramController", function () { $provide.value('messagingService', messageService); $provide.value('retrospectiveEntryService', retrospectiveEntryService); $provide.value('$stateParams', { configName: "default" }); + $provide.value('$translate', translate); })); beforeEach(inject(function ($controller, $rootScope, $q) { diff --git a/ui/test/unit/common/uicontrols/programmanagement/directives/programAttributes.spec.js b/ui/test/unit/common/uicontrols/programmanagement/directives/programAttributes.spec.js index 845c892b3f..754c90355d 100644 --- a/ui/test/unit/common/uicontrols/programmanagement/directives/programAttributes.spec.js +++ b/ui/test/unit/common/uicontrols/programmanagement/directives/programAttributes.spec.js @@ -2,17 +2,18 @@ describe("ensure that the directive program-attributes works properly", function () { - var scope,filter; + var scope, translate, filter; beforeEach(module('bahmni.common.uicontrols.programmanagment')); - beforeEach(inject(function ($controller, $rootScope,$filter) { + beforeEach(inject(function ($controller, $rootScope, $filter) { scope = $rootScope.$new(); scope.patientProgram = patientProgram; scope.programAttributeTypes = attributeTypes; filter = $filter; $controller('ProgramAttributesController', { - $scope: scope + $scope: scope, + $translate: translate }); }));