Commit 6bab22da by root

issue #666 closed (lectoescritura)

parent c516233a
......@@ -921,6 +921,29 @@ module.exports = {
});
},
// update action
// update picto atributes for a studentPicto
//
update_legend: function (req, res) {
var params = req.allParams();
var query='update stu_picto'+
' set attributes=json_set(attributes, \'$.legend\',\''+params.legend_value+'\')'+
' where id_stu='+params.id_stu;
console.log('Updating legend for student ' + params.id_stu +" collection to "+
params.legend_value+": "+query);
StuPicto.query(query, function(err, result) {
if (err)
throw new Error ("error on update");
else {
console.log('Updated attributes for picto student:' + params.id_stu);
return res.ok({
id: params.id_stu,
legend_value: params.legend_value, // picto attributes for student
});
}
});
},
/**
* Updates the student profile image
* @param {request} req
......
......@@ -3,7 +3,7 @@
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInstance, $http, config, studentPicto, sup, stu) {
dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $modalInstance, $http, config, studentPicto, sup, stu) {
// Last parameter passed from collections.js
// Basic data passed from the main window
......@@ -34,7 +34,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
console.log("Expression changed: " + JSON.stringify(data)+": "+$scope.studentPicto.expression.text);
$scope.studentPicto.attributes.expression=$scope.studentPicto.expression.text;
// Close the modal instance
$modalInstance.close($scope.studentPicto.expression.text);
//$modalInstance.close($scope.studentPicto.expression.text);
// Notifcar cambio
io.socket.post('/stu/vocabulary', {
......@@ -70,7 +70,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
console.log("Properties updated");
// Close the modal instance
$modalInstance.close($scope.expression);
//$modalInstance.close($scope.expression);
// /////////////////////////////////////////////////////////////
// Websocket: Emit vocabulary update action
......@@ -92,6 +92,21 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
});
};
$scope.update_legend = function(){
console.log("Legend: " + $scope.studentPicto.attributes.legend+" to be modified");
$http
.put(config.backend+'/stu/'+ $scope.stu.id + '/legend/' + $scope.studentPicto.attributes.legend)
.success(function(data, status, headers, config) {
console.log("Legend updated");
// Close the modal instance
$modalInstance.close($scope.expression);
$window.location.reload();
});
};
$scope.close = function () {
// Lo que se devuelve a collection
$modalInstance.dismiss('cancel');
......
......@@ -62,12 +62,12 @@
<hr>
<div class="row">
<div class="col-md-8">
<input type="checkbox">
<input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false">
<span translate>legend_apply_all</span>
</div>
<div class="col-md-4">
<div class="form-group text-center">
<button type="submit" class="btn btn-primary ng-scope" ng-click="" disabled translate>apply</button>
<button type="submit" class="btn btn-primary ng-scope" ng-click="update_all_legend ? update_legend() : close()" translate>apply</button>
</div>
</div>
</div>
......
......@@ -96,6 +96,7 @@ module.exports.policies = {
ws: ['tokenAuth'],
update: ['tokenAuth'],
update_picto: ['tokenAuth', 'isSupervisorOfStudent'],
update_legend: ['tokenAuth'],
login: true,
create: ['tokenAuth'],
upload: ['tokenAuth'],
......
......@@ -81,6 +81,7 @@ module.exports.routes = {
'GET /stu/:id_stu/ws': 'StudentController.ws',
'PUT /stu/:id_stu': 'StudentController.update',
'PUT /stu/:id_stu/picto/:id_stuPicto': 'StudentController.update_picto',
'PUT /stu/:id_stu/legend/:legend_value': 'StudentController.update_legend',
'PUT /stu/:id_stu/picto': 'StudentController.update_picto',
'POST /stu/login': 'StudentController.login',
'POST /stu': 'StudentController.create',
......
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