Skip to content

Commit

Permalink
A-1208424039194249 | Translate Program attributes in active tab (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjun-Go authored Oct 11, 2024
1 parent 443c1ea commit c590085
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down Expand Up @@ -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"
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="form-field" ng-repeat="attributeType in programAttributeTypes" ng-show="!patientProgram.editing" ng-if="isIncluded(attributeType)">
<div class="field-attribute">
<label>{{attributeType.description}} : </label>
<label>{{::getTranslatedAttributeTypes(attributeType.description) | translate}} : </label>
</div>
<div class="field-value">
<span>
Expand Down
3 changes: 3 additions & 0 deletions ui/app/i18n/clinical/locale_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion ui/app/i18n/clinical/locale_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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', {
$state: state,
$scope: scope,
$rootScope: rootScope,
q: q,
confirmBox: confirmBox
confirmBox: confirmBox,
$translate: translate
});
};

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}));

Expand Down

0 comments on commit c590085

Please sign in to comment.