Skip to content

Commit

Permalink
Add Error Messages for Enroll, FinalEnroll and AddCorrelative Modals (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiasMercado committed Feb 6, 2017
1 parent 9da368a commit 8075a8d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/scripts/controllers/modals/AddCorrelativeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ define(['paw', 'services/modalFactory', 'services/Courses', 'services/flashMessa
flashMessages.setSuccess('i18nAddCorrelativeSuccess');
$route.reload();
}, function(response) {
if (response.status === 409) { // Correlativity Loop
flashMessages.setError('i18nAddCorrelativeError');
$route.reload();
return;
}
flashMessages.setError('i18nFormErrors');
$log.warn('[ERROR] - Response: ' + JSON.stringify(response));
$route.reload();
Expand Down
12 changes: 9 additions & 3 deletions app/scripts/controllers/modals/EnrollController.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
'use strict';

define(['paw', 'services/modalFactory', 'services/Students', 'services/flashMessages'], function(paw) {
define(['paw', 'services/Paths', 'services/modalFactory', 'services/Students', 'services/flashMessages'], function(paw) {
paw.controller('EnrollController',
['modalFactory', '$log', 'Students', '$route', 'flashMessages',
function (modalFactory, $log, Students, $route, flashMessages) {
['modalFactory', '$log', 'Students', '$route', 'flashMessages', 'Paths',
function (modalFactory, $log, Students, $route, flashMessages, Paths) {
var _this = this;
var modalTemplateUrl = 'views/modals/enroll.html';
var onSuccess = function(result) {
Students.enroll(result.docket, result.courseId)
.then(function(response) {
flashMessages.setSuccess('i18nEnrollSuccess');
$route.reload();
}, function(response) {
if (response.status === 409) { // Didn't pass all correlatives
flashMessages.setError('i18nEnrollError');
$route.reload();
return;
}
flashMessages.setError('i18nFormErrors');
$log.warn('[ERROR] - Response: ' + JSON.stringify(response));
$route.reload();
Expand Down
5 changes: 5 additions & 0 deletions app/scripts/controllers/modals/FinalEnrollController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ define(['paw', 'services/modalFactory', 'services/Students', 'services/flashMess
flashMessages.setSuccess('i18nFinalEnrollSuccess');
$route.reload();
}, function(response) {
if (response.status === 409) { // Didn't pass all correlatives
flashMessages.setError('i18nFinalEnrollError');
$route.reload();
return;
}
flashMessages.setError('i18nFormErrors');
$log.warn('[ERROR] - Response: ' + JSON.stringify(response));
$route.reload();
Expand Down
3 changes: 3 additions & 0 deletions app/scripts/i18n/translations.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ define([], function() {
i18nUnenrollSuccess: 'Se ha eliminado la inscripción',
i18nFinalUnenrollSuccess: 'Se ha eliminado la inscripción',
i18nFormErrors: 'Hay errores en los datos ingresados',
i18nEnrollError: 'No es posible inscribirse en la materia',
i18nFinalEnrollError: 'No es posible inscribirse en el final',
i18nAddCorrelativeError: 'No es posible agregar la correlatividad',
i18nSuccess: '¡Éxito! - ',
i18nError: '¡Error! - ',
i18nFinalSuccessfullyCreated: 'Se ha creado la inscripción',
Expand Down

0 comments on commit 8075a8d

Please sign in to comment.