Skip to content

Commit

Permalink
feat(settings): implement bug report link
Browse files Browse the repository at this point in the history
This commit implements a "Report an Issue" link on the settings page.
The link opens up the default email client of the user with a pre-made
email, translated into their current language.  Only the English
translation exists, but it can be easily updated for French.

Closes #167.
  • Loading branch information
Jonathan Niles committed Aug 26, 2016
1 parent e5983f5 commit 1788840
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
4 changes: 3 additions & 1 deletion client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@
"TITLE" : "Service Management"
},
"SETTINGS": {
"TITLE" : "Settings"
"TITLE" : "Settings",
"BUG_LINK" : "Report an Issue",
"BUG_REPORT" : "Thank you for filing a bug! Please read the following message and replace the text surrounded by brackets ([[]]) with your report.\r\nWhere did the bug occur?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nWhat task were you trying to accomplish?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nWhat result did you expect?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nAny other relevant information or comments?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nMay we contact you for more information?\r\n\t\t[x] YES [ ] NO"
},
"SUBSIDY": {
"ADDING_SUBSIDY" : "Adding subsidy",
Expand Down
4 changes: 3 additions & 1 deletion client/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,9 @@
"TITLE" : "Gestion des services"
},
"SETTINGS": {
"TITLE" : "Paramètres"
"TITLE" : "Paramètres",
"BUG_LINK" : "Signaler un Problème",
"BUG_REPORT" : "Thank you for filing a bug! Please read the following message and replace the text surrounded by brackets ([[]]) with your report.\r\nWhere did the bug occur?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nWhat task were you trying to accomplish?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nWhat result did you expect?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nAny other relevant information or comments?\r\n\t\t[[ ENTER TEXT HERE ]]\r\nMay we contact you for more information?\r\n\t\t[x] YES [ ] NO"
},
"SUBSIDY": {
"ADDING_SUBSIDY" : "Ajout d'une subvention",
Expand Down
3 changes: 3 additions & 0 deletions client/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ function constantConfig() {
purchase : {
GRID_HEIGHT: 200
},
settings: {
CONTACT_EMAIL : 'developers@imaworldhealth.org'
},
dates : {
minDOB : new Date('1900-01-01'),
maxDOB : new Date(),
Expand Down
6 changes: 6 additions & 0 deletions client/src/partials/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
data-logout-button>
<span class="glyphicon glyphicon-log-out"></span> {{ "FORM.BUTTONS.LOGOUT" | translate }}
</button>

<a ng-href="mailto:{{SettingsCtrl.bugLink}}" class="btn btn-default" data-bug-report-button>
<span class="text-danger">
<i class="fa fa-bug"></i> {{ "SETTINGS.BUG_LINK" | translate }}
</span>
</a>
</div>
</div>
</div>
Expand Down
29 changes: 25 additions & 4 deletions client/src/partials/settings/settings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
angular.module('bhima.controllers')
.controller('settings', SettingsController);
.controller('settings', SettingsController);

SettingsController.$inject = [
'$state', 'LanguageService', 'SessionService'
'$state', 'LanguageService', 'SessionService', 'bhConstants', '$translate',
'NotifyService'
];

/**
Expand All @@ -13,7 +14,7 @@ SettingsController.$inject = [
*
* @constructor
*/
function SettingsController($state, Languages, Session) {
function SettingsController($state, Languages, Session, Constants, $translate, Notify) {
var vm = this;

// the url to return to (using the back button)
Expand All @@ -30,5 +31,25 @@ function SettingsController($state, Languages, Session) {
Languages.read()
.then(function (languages) {
vm.languages = languages;
});
})
.catch(Notify.handleError);

// formatting or bug report
var emailAddress = Constants.settings.CONTACT_EMAIL;
var subject = '[BUG] ' + new Date().toLocaleDateString() + ' - ' + Session.enterprise.name;

// get the translated bug report
$translate('SETTINGS.BUG_REPORT')
.then(function (body) {

var text =
Session.user.username + ' ' +
new Date().toLocaleDateString() + '\r\n\r\n' +
body;

// template in the bug link
vm.bugLink = encodeURI(emailAddress + '?subject=' + subject + '&body=' + text);
})
.catch(Notify.handleError);

}

0 comments on commit 1788840

Please sign in to comment.