Skip to content

Commit

Permalink
add validation errors message in House & rooms view
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed May 23, 2017
1 parent 2cd7045 commit 05a72dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
18 changes: 16 additions & 2 deletions assets/js/app/house/house.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
.module('gladys')
.controller('HouseCtrl', HouseCtrl);

HouseCtrl.$inject = ['houseService', 'roomService'];
HouseCtrl.$inject = ['houseService', 'roomService', 'notificationService'];

function HouseCtrl(houseService, roomService) {
function HouseCtrl(houseService, roomService, notificationService) {
/* jshint validthis: true */
var vm = this;

Expand Down Expand Up @@ -45,6 +45,13 @@
.then(function(data){
getHouses();
resetNewHouseFields();
})
.catch(err => {
if(err.data && err.data.code && err.data.code == 'E_VALIDATION') {
notificationService.errorNotificationTranslated('VALIDATION.ERROR');
} else {
notificationService.errorNotificationTranslated('DEFAULT.ERROR');
}
});
}

Expand All @@ -53,6 +60,13 @@
.then(function(data){
getRooms();
resetNewRoomFields();
})
.catch(err => {
if(err.data && err.data.code && err.data.code == 'E_VALIDATION') {
notificationService.errorNotificationTranslated('VALIDATION.ERROR');
} else {
notificationService.errorNotificationTranslated('DEFAULT.ERROR');
}
});
}

Expand Down
14 changes: 13 additions & 1 deletion assets/js/app/translate/translate.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var translationsEN = {
CHAT: {
TEXT_BOX_PLACEHOLDER: 'Write your message',
TYPING: 'Typing'
},
VALIDATION: {
ERROR: 'Some fields are invalid !'
},
DEFAULT: {
ERROR: 'Something bad happened :/ Check Gladys logs for more informations.'
}
};

Expand Down Expand Up @@ -65,7 +71,13 @@ var translationsFR = {
CHAT: {
TEXT_BOX_PLACEHOLDER: 'Tapez votre message',
TYPING: 'En train d\'écrire'
}
},
VALIDATION: {
ERROR: 'Certains champs sont invalides !'
},
DEFAULT: {
ERROR: 'Une erreur inconnue est arrivée :/ Regardez les logs Gladys pour plus d\'informations.'
}
};


Expand Down

0 comments on commit 05a72dd

Please sign in to comment.