Commit f05be3a3 by Jose Antonio

Fix Issue #186, still having problem refreshing select

parent 62dcf558
......@@ -32,6 +32,7 @@ module.exports = {
id_met: method.id,
name: req.param('name'),
objective: req.param('objective'),
lang: method.lang
})
.then(function (instruction) {
if (instruction)
......
......@@ -184,7 +184,8 @@ module.exports = {
MetaInstruction.create({
id_met: createdMethod.id,
name: mins.name,
objective: mins.objective
objective: mins.objective,
lang: createdMethod.lang
}).exec(function(err, added){
if(err) sails.log.debug("MetaInstruction.create: " + err);
if(added){
......
......@@ -12,7 +12,7 @@ module.exports = {
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
......@@ -32,6 +32,11 @@ module.exports = {
required: true,
type: "integer",
model: "MetaMethod"
},
lang: {
required: true,
type: "string",
size: 5
}
}
};
\ No newline at end of file
};
......@@ -29,8 +29,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
}
// Add to list
$scope.methods_available = data;
console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available));
//console.log("Meta Methods charged:");
//console.log(JSON.stringify($scope.methods_available));
// Option to add new methods
$scope.methods_available.push({ id: 0, name: $translate.instant('new_method'), disabled: false });
})
......@@ -49,8 +49,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
//console.log(JSON.stringify($scope.methods));
//console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......@@ -85,7 +85,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.success(function(data, status, headers, config) {
// Add empty array of instructions
data.instructions = [];
console.log('Created new empty Method:' + JSON.stringify(data));
//console.log('Created new empty Method:' + JSON.stringify(data));
$scope.methods.unshift(data);
})
.error(function(data, status, headers, config) {
......@@ -100,8 +100,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
'id_stu': $scope.studentData.id
})
.success(function(data, status, headers, config) {
console.log('Created Method and Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data));
//console.log('Created Method and Instructions');
//console.log('Method (with Instructions):' + JSON.stringify(data));
$scope.methods.unshift(data);
})
.error(function(data, status, headers, config) {
......@@ -120,7 +120,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.delete(config.backend+'/method/template/' + $scope.method_selected.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
// console.log('Delete Method Template and its Instructions');
ngToast.success({content: $translate.instant('template_deleted')});
......@@ -153,7 +153,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.put(config.backend+'/method/' + method.id, method_to_save)
.success(function(data, status, headers, config) {
console.log('Updated method:' + JSON.stringify(data));
//console.log('Updated method:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + JSON.stringify(data));
......@@ -167,10 +167,12 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.post(config.backend+'/method/save', { 'id_met': method.id, 'id_sup': $scope.user.id, 'lang': $scope.user.lang })
.then( //success
function(data, status, headers, config) {
console.log('Saved method as template:' + JSON.stringify(data));
//console.log('Saved method as template:' + JSON.stringify(data));
// Add to select method
$scope.methods_available.push({ id: method.id, name: method.name });
$scope.$apply(function(){
$scope.methods_available.push({ id: method.id, name: method.name });
});
ngToast.success({
content: $translate.instant('method_saved', {method_name: method.name}),
......@@ -196,8 +198,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.delete(config.backend+'/method/' + method.id)
.success(function(data, status, headers, config) {
console.log('Delete Method and its Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data));
//console.log('Delete Method and its Instructions');
//console.log('Method (with Instructions):' + JSON.stringify(data));
// Delete in view
for(var i=0; i<$scope.methods.length; i++) {
if($scope.methods[i].id == method.id){
......@@ -228,7 +230,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.post(config.backend+'/instruction', data )
.success(function(data, status, headers, config) {
console.log('Added instruction:' + JSON.stringify(data));
//console.log('Added instruction:' + JSON.stringify(data));
// Add in view
method.instructions.push(data);
})
......@@ -243,7 +245,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.put(config.backend+'/instruction/' + ins.id, ins)
.success(function(data, status, headers, config) {
console.log('Updated instruction:' + JSON.stringify(data));
//console.log('Updated instruction:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......@@ -266,7 +268,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.delete(config.backend+'/instruction/' + ins.id)
.success(function(data, status, headers, config) {
console.log('Deleted instruction:' + JSON.stringify(data));
//console.log('Deleted instruction:' + JSON.stringify(data));
// Buscar method
for(var i=0; i<$scope.methods.length; i++) {
var m = $scope.methods[i];
......
......@@ -60,7 +60,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
$http
.delete(config.backend+'/method/template/' + method.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
//console.log('Delete Method Template and its Instructions');
ngToast.success($translate.instant('template_deleted'));
for(var i=0; i<$scope.methods.length; i++) {
......@@ -87,7 +87,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
$http
.put(config.backend+'/method/template/' + method.id, method_to_save)
.success(function(data, status, headers, config) {
console.log('Updated method:' + JSON.stringify(data));
//console.log('Updated method:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + JSON.stringify(data));
......@@ -106,7 +106,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
$http
.post(config.backend+'/instruction/template/', new_instruction)
.success(function(data, status, headers, config) {
console.log('Added instruction:' + JSON.stringify(data));
//console.log('Added instruction:' + JSON.stringify(data));
// Add in view
method.metainstructions.push(data);
})
......@@ -121,7 +121,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
$http
.put(config.backend+'/instruction/template/' + ins.id, ins)
.success(function(data, status, headers, config) {
console.log('Updated instruction:' + JSON.stringify(data));
//console.log('Updated instruction:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......@@ -133,7 +133,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
$http
.delete(config.backend+'/instruction/template/' + ins.id)
.success(function(data, status, headers, config) {
console.log('Deleted instruction:' + JSON.stringify(data));
//console.log('Deleted instruction:' + JSON.stringify(data));
// Buscar method
for(var i=0; i<$scope.methods.length; i++) {
var m = $scope.methods[i];
......
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