Commit f395e976 by Jose Antonio

Issue #241, closed

parent ffbf1e07
......@@ -1205,6 +1205,7 @@ module.exports = {
@params {request} req {
id_stu: {integer} studentID,
legend_value: {string} 'none' | 'normal' | 'full'
id_scene: {integer} sceneID
}
@params {response} res {
id: {integer} studentID,
......@@ -1213,16 +1214,20 @@ module.exports = {
*/
update_legend: function (req, res) {
var params = req.allParams();
Student.update_legend(params.id_stu, params.legend_value, function (err) {
if (err) {
sails.log.debug(JSON.stringify(err));
return res.serverError("Error on legend update: ");
}
return res.ok({
id: params.id_stu,
legend_value: params.legend_value, // picto attributes for student
});
})
if(params.id_scene){
Student.update_legend(params.id_scene, params.legend_value, function (err) {
if (err) {
sails.log.debug(JSON.stringify(err));
return res.serverError("Error on legend update: ");
}
return res.ok({
id: params.id_stu,
legend_value: params.legend_value, // picto attributes for student
});
})
}else{
return res.badRequest("id_scene required");
}
},
/**
......
......@@ -102,6 +102,7 @@ module.exports = {
var stuPictoToAdd = {
"id": stuPicto.id,
"picto": stuPicto.picto,
"id_scene": stuPicto.scene,
"attributes": stuPicto.attributes,
"tags": picto.tags ? picto.tags : []
};
......
......@@ -409,6 +409,7 @@ module.exports = {
var stuPictoToAdd = {
"id": stuPicto.id,
"picto": stuPicto.picto,
"id_scene": stuPicto.id_scene,
"attributes": stuPicto.attributes,
"tags": picto.tags ? picto.tags : []
};
......@@ -556,10 +557,10 @@ module.exports = {
* Updates legend in student pictos
* legend is not updated for categories
*/
update_legend: function(id_stu, legend_value, cb) {
update_legend: function(id_scene, legend_value, cb) {
var query='UPDATE stu_picto' +
' SET attributes = json_set(attributes, \'$.legend\',\''+legend_value+'\')' +
' WHERE id_stu=' + id_stu + ' AND ' +
' WHERE id_scene=' + id_scene + ' AND ' +
' (json_extract(attributes, \'$.id_cat\') LIKE \'null\' AND ' +
' json_extract(attributes, \'$.coord_y\') = 0 OR ' +
' json_extract(attributes, \'$.id_cat\') NOT LIKE \'null\' AND ' +
......
......@@ -608,7 +608,13 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}
}
});
// Returned data from the modal window
modalInstance.result.then(function (all_legend) {
if(all_legend){
ngToast.success({ content: $translate.instant('reloading_pictos') });
$scope.showScene($scope.viewingScene.id);
}
});
};
// Modal window to create scenes
......
......@@ -52,7 +52,9 @@ dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $t
return new Promise(function (resolve, reject) {
if ($scope.update_all_legend) {
$http
.put(config.backend+'/stu/'+ stu.id + '/legend/' + $scope.studentPicto.attributes.legend)
.put(config.backend+'/stu/'+ stu.id + '/legend/' + $scope.studentPicto.attributes.legend,{
id_scene: $scope.studentPicto.id_scene
})
.success(function(data, status, headers, config) {
resolve(result);
})
......@@ -78,10 +80,6 @@ dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $t
studentPicto.attributes = $scope.studentPicto.attributes;
$modalInstance.close($scope.studentPicto.attributes.expression);
if ($scope.update_all_legend) {
ngToast.success({ content: $translate.instant('reloading_pictos') });
$window.location.reload();
}
})
});
......@@ -89,7 +87,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $t
$scope.close = function () {
// Lo que se devuelve a collection
$modalInstance.dismiss('cancel');
$modalInstance.dismiss($scope.update_all_legend);
// Devolver el picto actualizado, situándolo en su posición
};
......
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