working on issue #527

parent 155a26ab
......@@ -36,6 +36,7 @@
"birthdate": "Birthdate",
"cancel": "Cancel",
"cannot_delete_method": "Method could not be deleted, maybe due to existing recorded sessions.",
"cannot_delete_instruction": "Instruction could not be deleted, maybe due to existing recorded sessions.",
"categories": "Categories",
"category_pictograms": "Category's pictograms",
"change_password": "Change password",
......
......@@ -36,6 +36,7 @@
"birthdate": "Fecha de nacimiento",
"cancel": "Cancelar",
"cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.",
"cannot_delete_instruction": "No se pudo eliminar la instrucción, tal vez porque existen sesiones asociadas.",
"categories": "Categorías",
"category_pictograms": "Pictogramas de la categoría",
"change_password": "Cambiar contraseña",
......
......@@ -34,12 +34,12 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
......@@ -53,7 +53,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
console.log("Error from API: " + data.error);
});
//
//
// Get last method/instruction for this student
//
/* $http
......@@ -75,7 +75,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
if($scope.method_selected.id == 0){
$http
.post(config.backend+'/method/new', {
.post(config.backend+'/method/new', {
'id_stu': $scope.studentData.id,
'name': "Nuevo método (cambiar nombre)"
})
......@@ -92,8 +92,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
}else{
// Add method from templates
$http
.post(config.backend+'/method', {
'id_mmethod': $scope.method_selected.id,
.post(config.backend+'/method', {
'id_mmethod': $scope.method_selected.id,
'id_stu': $scope.studentData.id
})
.success(function(data, status, headers, config) {
......@@ -120,7 +120,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.delete(config.backend+'/method/template/' + $scope.method_selected.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
var myToastMsg = ngToast.success({
content: 'Eliminado método de plantillas',
timeout: 6000 // By default 4000
......@@ -141,12 +141,12 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
}
};
// Update method
// Update method
$scope.update_method = function(method){
// Remove instructions as we only update title or description
var method_to_save = {};
Object.assign(method_to_save, method);
Object.assign(method_to_save, method);
delete method_to_save.instructions;
$http
......@@ -158,8 +158,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
console.log("Error from API: " + JSON.stringify(data));
});
};
// Save method and its instructions as template in metamethods and metainstructions
// Save method and its instructions as template in metamethods and metainstructions
$scope.save_as_template = function(method){
$http
......@@ -167,10 +167,10 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.then( //success
function(data, status, headers, config) {
console.log('Saved method as template:' + JSON.stringify(data));
// Add to select method
$scope.methods_available.push({ id: method.id, name: method.name });
// creating a toast using "success", "info", "warning" or "danger" shortcut methods:
var myToastMsg = $translate('method_save').then(function (translation) {
// Show message
......@@ -179,7 +179,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
timeout: 6000 // By default 4000
});
});
}
,function(data, status, headers, config) { //error
console.log("Error from API: " + data.error+"("+data.status+")");
......@@ -212,7 +212,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
break;
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......@@ -276,21 +276,28 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Buscar method
for(var i=0; i<$scope.methods.length; i++) {
var m = $scope.methods[i];
if(ins.method == m.id){
if(ins.method == m.id){
// Buscar la instrucción y eliminar de la vista
for(var j=0; j<m.instructions.length; j++) {
if(ins.id == m.instructions[j].id){
if(ins.id == m.instructions[j].id){
$scope.methods[i].instructions.splice(j,1);
break;
}
}
break;
}
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
var myToastMsg = $translate('cannot_delete_instruction').then(function (translation) {
// Show message
ngToast.warning({
content: translation,
timeout: 6000 // By default 4000
});
});
});
};
......@@ -319,4 +326,4 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
};
// End Modal window to view instruction details
});
\ No newline at end of file
});
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