issue #723 fixed

parent 8a83f625
......@@ -288,6 +288,7 @@
"student_pictograms": "Student's pictograms",
"student_updated": "Student updated",
"students": "Students",
"sup_already_added": "Supervisor already in the list",
"sup_not_added": "Supervisor not added to the student",
"sup_not_deleted": "The supervisor couldn't be deleted by the student",
"sup_not_found": "There is no supervisor account in Pictogram with this email",
......
......@@ -289,6 +289,7 @@
"student_pictograms": "Pictogramas del estudiante",
"student_updated": "Estudiante actualizado",
"students": "Alumnos",
"sup_already_added": "El supervisor ya está en la lista",
"sup_not_added": "El supervisor no se ha podido añadir al estudiante.",
"sup_not_deleted": "El supervisor no se ha podido desvincular del alumno.",
"sup_not_found": "No hay ningún usuario en Pictogram con ese correo electrónico.",
......
......@@ -183,22 +183,30 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
supervisor: $scope.supToAdd.id
};
// Ensure supervisor is not already in the list
if ($scope.studentSupervisors.map((s) => s.id).includes($scope.supToAdd.id)) {
ngToast.danger({ content: $translate.instant('sup_already_added') });
$scope.supsForm.email_sup = '';
$scope.showmessagesupfound = false;
return;
}
$http.post(config.backend + '/stu/' + $scope.studentData.id + '/sup/' + $scope.supToAdd.id, {asTherapist: true})
.success(function (data) {
// Assign the info of supervisor to add
stusup.supervisor = $scope.supToAdd;
stusup.id = data.id;
// Add to the list of tutors in view
$scope.studentSupervisors.push($scope.supToAdd);
// Delete the email form field
$scope.supsForm.email_sup = '';
// Hide the message of supervisor founded
$scope.showmessagesupfound = false;
})
.error(function () {
$translate('sup_not_added').then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant('sup_not_added') });
});
};
......@@ -262,6 +270,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
supervisor: $scope.tutorToAdd.id
};
// Ensure supervisor is not already in the list
if ($scope.studentTutors.map((s) => s.id).includes($scope.tutorToAdd.id)) {
ngToast.danger({ content: $translate.instant('sup_already_added') });
$scope.supsForm.email_tutor = '';
$scope.showmessagetutorfound = false;
return;
}
$http.post(config.backend + '/stu/' + $scope.studentData.id + '/sup/' + $scope.tutorToAdd.id)
.success(function (data) {
// Assign the info of supervisor to add
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment