Skip to content
Snippets Groups Projects
Commit 5677789f authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Enforce use of angular-translate, when some keys are not defined (avoid...

[fix] Enforce use of angular-translate, when some keys are not defined (avoid error "translationId must be a not empty string")
parent 60ab2b10
No related branches found
No related tags found
No related merge requests found
...@@ -43,17 +43,17 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle']) ...@@ -43,17 +43,17 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle'])
function alertError(err, subtitle) { function alertError(err, subtitle) {
if (!err) { if (!err) {
return $q.when(); return $q.when(); // Silent
} }
return $q(function(resolve) { return $q(function(resolve) {
$translate([err, subtitle, 'ERROR.POPUP_TITLE', 'ERROR.UNKNOWN_ERROR', 'COMMON.BTN_OK']) $translate([err, 'ERROR.POPUP_TITLE', 'ERROR.UNKNOWN_ERROR', 'COMMON.BTN_OK'].concat(subtitle ? [subtitle] : []))
.then(function (translations) { .then(function (translations) {
var message = err.message || translations[err]; var message = err.message || translations[err];
return $ionicPopup.show({ return $ionicPopup.show({
template: '<p>' + (message || translations['ERROR.UNKNOWN_ERROR']) + '</p>', template: '<p>' + (message || translations['ERROR.UNKNOWN_ERROR']) + '</p>',
title: translations['ERROR.POPUP_TITLE'], title: translations['ERROR.POPUP_TITLE'],
subTitle: translations[subtitle], subTitle: subtitle && translations[subtitle] || undefined,
buttons: [ buttons: [
{ {
text: '<b>'+translations['COMMON.BTN_OK']+'</b>', text: '<b>'+translations['COMMON.BTN_OK']+'</b>',
...@@ -69,6 +69,7 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle']) ...@@ -69,6 +69,7 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle'])
} }
function alertInfo(message, subtitle) { function alertInfo(message, subtitle) {
if (!message) return $q.reject("Missing 'message' argument");
return $q(function(resolve) { return $q(function(resolve) {
$translate([message, 'INFO.POPUP_TITLE', 'COMMON.BTN_OK'].concat(subtitle ? [subtitle] : [])) $translate([message, 'INFO.POPUP_TITLE', 'COMMON.BTN_OK'].concat(subtitle ? [subtitle] : []))
.then(function (translations) { .then(function (translations) {
...@@ -159,6 +160,7 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle']) ...@@ -159,6 +160,7 @@ angular.module('cesium.utils.services', ['angular-fullscreen-toggle'])
} }
function showToast(message, duration, position) { function showToast(message, duration, position) {
if (!message) return $q.reject("Missing 'message' argument");
duration = duration || 'short'; duration = duration || 'short';
position = position || 'bottom'; position = position || 'bottom';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment