Skip to content

Commit

Permalink
feat(i18n): override translate helper w/ lang
Browse files Browse the repository at this point in the history
The handlebars translated helper is now overridden with the correct
language translation helper. This means that the developer does not have
to specify the translation key in templates - it is transparently
configured prior to compiling the template.

Closes #618.
  • Loading branch information
Jonathan Niles committed Aug 3, 2016
1 parent 0c9ceb9 commit 725c61f
Show file tree
Hide file tree
Showing 20 changed files with 360 additions and 132 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@
"ORIGINAL" : "This patient has never been checked in.",
"RECENT" : "Recent Visits",
"ITEM" : "Checked in",
"BY" : "by",
"SUCCESS" : "Patient has been checked in"
}
},
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@
"ORIGINAL" : "Ce patient n'a jamais été vérifiée.",
"RECENT" : "Visites récentes",
"ITEM" : "Vérifiée",
"BY" : "par",
"SUCCESS" : "Le patient a déjà été vérifié"
},
"TITLE" : "Patients",
Expand Down
3 changes: 1 addition & 2 deletions client/src/js/components/bhFindDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translat
/** delete document */
function deleteDocument(uuid, pattern) {
var request = { pattern: pattern, elementName: 'document'};

Modal.openConfirmDeletion(request)
.then(function (ans) {
if (!ans) { return; }
Expand All @@ -69,7 +69,6 @@ function FindDocumentComponent(Patient, Modal, Document, Notify, User, $translat
Notify.success('FORM.INFOS.DELETE_SUCCESS');
startup();
});

})
.catch(Notify.handleError);
}
Expand Down
25 changes: 20 additions & 5 deletions client/src/js/components/bhPDFPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@ angular.module('bhima.components')
pdfUrl : '@',
options : '<'
},
transclude : true,
template :
'<bh-loading-button button-class="btn-default" loading-state="$ctrl.$loading" ng-click="$ctrl.print()">' +
'<span><i class="fa fa-print"></i> {{ "FORM.BUTTONS.PRINT" | translate }}</span>' +
'<span><i class="fa fa-print"></i> {{ "FORM.BUTTONS.PRINT" | translate }}</span>' +
'</bh-loading-button>' +
'<iframe ng-src="{{$ctrl.src}}" id="{{$ctrl.embeddedContentId}}" style="display : none"></iframe>',
controller : bhPDFPrintController
});

angular.module('bhima.components')
.component('bhPdfLink', {
bindings : {
pdfUrl : '@',
options : '<'
},
transclude : true,
template :
'<a href ng-click="$ctrl.print()">' +
'<span ng-if="!$ctrl.$loading"><i class="fa fa-print"></i> {{ "FORM.BUTTONS.PRINT" | translate }}</span>' +
'<span ng-if="$ctrl.$loading"><i class="fa fa-spin fa-circle-o-notch"></i> {{ "FORM.INFOS.LOADING" | translate }}</span>' +
'</a>' +
'<iframe ng-src="{{$ctrl.src}}" id="{{$ctrl.embeddedContentId}}" style="display : none"></iframe>',
controller : bhPDFPrintController
});


bhPDFPrintController.$inject = ['$window', '$http', '$sce', '$timeout'];

/**
Expand All @@ -30,7 +46,6 @@ bhPDFPrintController.$inject = ['$window', '$http', '$sce', '$timeout'];
* Options will be passed as params in the get request.
*
* @todo Investigate abstracting direct print to browser window functionality to allow export drop-down
* @todo Namespace component so that more than one can be used on one page at a time
*
* @example
* let url = '/reports/receipt/invoice';
Expand All @@ -41,7 +56,7 @@ bhPDFPrintController.$inject = ['$window', '$http', '$sce', '$timeout'];
* options="options">
* </bh-pdf-print>
*/
function bhPDFPrintController($window, $http, $sce, $timeout, uuid) {
function bhPDFPrintController($window, $http, $sce, $timeout) {
var cachedRequest;
var component = this;

Expand All @@ -57,7 +72,7 @@ function bhPDFPrintController($window, $http, $sce, $timeout, uuid) {
var loadingIndicatorDelay = 1000;

component.$loading = false;
component.embeddedContentId = 'pdfdirect' + Date.now();
component.embeddedContentId = 'pdfdirect-' + Date.now();

// expose the print method to the view
component.print = print;
Expand Down
38 changes: 23 additions & 15 deletions client/src/partials/patients/record/units/checkin.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
<div class="panel panel-default">
<div class="panel-heading">

<div class="panel-heading clearfix">
{{ "PATIENT_RECORDS.CHECK_IN.TITLE" | translate }}

<span class="pull-right">
<bh-pdf-link
pdf-url="reports/patients/{{ CheckInCtrl.id }}/checkins">
</bh-pdf-link>
</span>
</div>

<div class="panel-body" style="height : 250px; overflow : hidden">
<p
ng-if="CheckInCtrl.outdatedVisit"
class="text-info">
<i class="fa fa-info-circle"></i>
{{ "PATIENT_RECORDS.CHECK_IN.NOT_RECENT" | translate }}
ng-if="CheckInCtrl.outdatedVisit"
class="text-info">
<i class="fa fa-info-circle"></i>
{{ "PATIENT_RECORDS.CHECK_IN.NOT_RECENT" | translate }}
</p>

<bh-loading-button
id="checkin"
loading-state="CheckInCtrl.checkingIn"
button-class="btn-default btn-block"
ng-click="CheckInCtrl.checkin()">
id="checkin"
loading-state="CheckInCtrl.checkingIn"
button-class="btn-default btn-block"
ng-click="CheckInCtrl.checkin()">
<i class="fa fa-sign-in"></i>
{{ "PATIENT_RECORDS.CHECK_IN.SUBMIT" | translate }}
</bh-loading-button>

<br>
<br />
<p><b>{{ "PATIENT_RECORDS.CHECK_IN.RECENT" | translate }}</b></p>

<p
ng-if="CheckInCtrl.loaded && CheckInCtrl.visits.length===0"
class="text-warning">
ng-if="CheckInCtrl.loaded && CheckInCtrl.visits.length===0"
class="text-warning">
<span class="fa fa-warning"></span>
{{ "PATIENT_RECORDS.CHECK_IN.ORIGINAL" | translate }}
</p>

<ul class="list-unstyled">
<li data-check-entry ng-repeat="visit in CheckInCtrl.visits | limitTo : CheckInCtrl.limitVisitDisplay">
<i class="fa fa-check-square-o"></i> {{ "PATIENT_RECORDS.CHECK_IN.ITEM" | translate }} <b><span am-time-ago="visit.start_date"></span></b> by {{visit.username}}
<br>
<i class="fa fa-check-square-o"></i> {{ "PATIENT_RECORDS.CHECK_IN.ITEM" | translate }} <b><span am-time-ago="visit.start_date"></span></b> {{ "PATIENT_RECORDS.CHECK_IN.BY" | translate }} {{ visit.username }}
<br />
<span class="icon-spacer text-muted"><i>{{visit.start_date | date : 'medium'}}</i></span>
</li>
</ul>
</div>
</div>
</div>
40 changes: 20 additions & 20 deletions client/src/partials/patients/record/units/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,64 @@ angular.module('bhima.controllers')

CheckInController.$inject = ['$stateParams', 'moment', 'PatientService', 'NotifyService'];

function CheckInController($stateParams, moment, Patients, Notify) {
function CheckInController($stateParams, moment, Patients, Notify) {
var vm = this;
var id = $stateParams.patientID;
vm.id = id;

// total number of visits to display in the 'Recent Visits' component
var limitVisits = 3;
vm.limitVisitDisplay = 3;
// warn a user after x number of days

// warn a user after x number of days
/** @todo this number and logic should be defined as a global constant that drives all visit logic */
var visitDurationWarnLimit = 5;

vm.loaded = false;
vm.checkingIn = false;
vm.checkin = checkin;

loadVisits();
function loadVisits() {

function loadVisits() {
vm.outdatedVisit = false;
vm.loaded = false;
Patients.Visits.read(id, {limit : limitVisits})
.then(function (visits) {
vm.loaded = true;
vm.visits = visits;
vm.visits = visits;

// exit early if there are no patient visits
if (!visits.length) {
vm.outdatedVisit = true;
return;
}

// check how long ago the most recent patient visit was
vm.latestCheckIn = moment().diff(visits[0].start_date, 'days');

// check to see if the latest visit was before the duration warn limit
if (visitDurationWarnLimit - vm.latestCheckIn <= 0) {

// limit the number of visible check ins given the warning text
vm.limitVisitDisplay = 2;
vm.outdatedVisit = true;
}
})
.catch(Notify.handleError);
.catch(Notify.handleError);
}


function checkin() {



function checkin() {
vm.checkingIn = true;
Patients.Visits.checkin(id)
.then(function (result) {
Patients.Visits.checkin(id)
.then(function (result) {
Notify.success('PATIENT_RECORDS.CHECK_IN.SUCCESS');
loadVisits();
})
.catch(Notify.handleError)
.finally(function () {
.finally(function () {
vm.checkingIn = false;
});
}
}
}
6 changes: 3 additions & 3 deletions client/src/partials/templates/bhFindDocument.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<button
type="button"
title="{{ 'PATIENT_DOCUMENT.DISPLAY_THUMBNAIL' | translate }}"
class="btn btn-sm"
class="btn btn-sm btn-default"
data-document-action="thumbnail"
ng-click="$ctrl.switchDisplay('thumbnail')">
<i class="fa fa-file-image-o"></i>
Expand All @@ -36,7 +36,7 @@
<button
type="button"
title="{{ 'PATIENT_DOCUMENT.DISPLAY_LIST' | translate }}"
class="btn btn-sm"
class="btn btn-sm btn-default"
data-document-action="list"
ng-click="$ctrl.switchDisplay('list')">
<i class="fa fa-list"></i>
Expand All @@ -45,7 +45,7 @@
<button
type="button"
title="{{ 'PATIENT_DOCUMENT.ADD' | translate }}"
class="btn btn-sm"
class="btn btn-sm btn-default"
data-document-action="add"
ng-click="$ctrl.addDocument()">
<i class="fa fa-plus"></i>
Expand Down
1 change: 1 addition & 0 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ exports.configure = function configure(app) {
app.get('/reports/invoices/:uuid', financeReports.receipts.invoices);
app.get('/reports/patient/registrations', medicalReports.patientRegistrations);
app.get('/reports/patient/:uuid', medicalReports.receipts.patients);
app.get('/reports/patients/:uuid/checkins', medicalReports.patientCheckins);
app.get('/reports/purchases/:uuid', inventoryReports.receipts.purchases);

// patient group routes
Expand Down
Loading

0 comments on commit 725c61f

Please sign in to comment.