issue #501 fixed

parent b9d580e1
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* Check out the `tasks` directory instead. * Check out the `tasks` directory instead.
*/ */
module.exports = function (grunt) { module.exports = function (grunt) {
var includeAll; var includeAll;
var taskConfigurations; var taskConfigurations;
var registerDefinitions; var registerDefinitions;
......
...@@ -184,6 +184,7 @@ ...@@ -184,6 +184,7 @@
"picto_added": "Picto successfully added", "picto_added": "Picto successfully added",
"picto_behavior": "Behavior of a pictogram when it is selected (without phrase tape)", "picto_behavior": "Behavior of a pictogram when it is selected (without phrase tape)",
"picto_labels": "Pictogram labels", "picto_labels": "Pictogram labels",
"picto_removed": "Picto has been removed from vocabulary",
"picto_style": "Pictogram style", "picto_style": "Pictogram style",
"picto_upload_error": "Error uploading picto", "picto_upload_error": "Error uploading picto",
"picto_upload_limit": "Image size is too large", "picto_upload_limit": "Image size is too large",
......
...@@ -184,6 +184,7 @@ ...@@ -184,6 +184,7 @@
"picto_added": "Picto añadido correctamente", "picto_added": "Picto añadido correctamente",
"picto_behavior": "Comportamiento de un pictograma al seleccionarlo (sin cinta de frase)", "picto_behavior": "Comportamiento de un pictograma al seleccionarlo (sin cinta de frase)",
"picto_labels": "Etiquetas del pictograma", "picto_labels": "Etiquetas del pictograma",
"picto_removed": "El pictograma se ha eliminado del vocabulario",
"picto_style": "Aspecto de los pictogramas", "picto_style": "Aspecto de los pictogramas",
"picto_upload_error": "Hubo un error al guardar el picto", "picto_upload_error": "Hubo un error al guardar el picto",
"picto_upload_limit": "El tamaño del picto es demasiado grande", "picto_upload_limit": "El tamaño del picto es demasiado grande",
......
...@@ -338,6 +338,37 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -338,6 +338,37 @@ dashboardControllers.controller('AddPictoCtrl', function (
}; };
// //
// Delete picto added to free category
//
$scope.removeFreePicto = function (studentPicto) {
$http.delete(config.backend + '/stu/' + student.id + '/picto/' + studentPicto.id)
.success(function () {
var i;
freeCategoryPictos
[studentPicto.attributes.free_category_coord_x]
[studentPicto.attributes.free_category_coord_y] = emptyStudentPicto;
for (i = 0; i < $scope.freeAddedPictos.length; i++) {
if (studentPicto === $scope.freeAddedPictos[i]) {
$scope.freeAddedPictos.splice(i, 1);
break;
}
}
// websocket emit vocabulary delete action
io.socket.post('/stu/vocabulary', {
action: 'delete',
attributes: {
id_stu: student.id,
stu_picto: studentPicto
}
}, function () {});
})
.error(function () {});
};
//
// Delete own picto // Delete own picto
// //
$scope.remove_own_picto = function (pictoId) { $scope.remove_own_picto = function (pictoId) {
...@@ -351,6 +382,16 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -351,6 +382,16 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope.pictos.splice(i, 1); $scope.pictos.splice(i, 1);
} }
} }
// websocket emit vocabulary delete action
io.socket.post('/stu/vocabulary', {
action: 'delete',
attributes: {
id_stu: student.id,
stu_picto: pictoId
}
}, function () {});
}) })
.error(function () {}); .error(function () {});
}); });
......
...@@ -16,7 +16,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -16,7 +16,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$location, $location,
$filter, $filter,
$anchorScroll, $anchorScroll,
$modal) { $modal,
$translate) {
$scope.emptyStudentPicto = { $scope.emptyStudentPicto = {
id: null, id: null,
picto: { picto: {
...@@ -134,44 +135,56 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -134,44 +135,56 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Delete student picto // Delete student picto
$scope.delete_picto = function (studentPicto) { $scope.delete_picto = function (studentPicto) {
var deleteStuPicto = $window.confirm('Are you absolutely sure you want to delete?'); $translate('confirmation').then(t => {
if (deleteStuPicto) { if ($window.confirm(t)) {
$http.delete(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + studentPicto.id) $http.delete(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + studentPicto.id)
.success(function () { .success(function () {
$scope.studentPictos $scope.studentPictos
[$scope.getCategoryId(studentPicto)] [$scope.getCategoryId(studentPicto)]
[studentPicto.attributes.coord_x] [studentPicto.attributes.coord_x]
[studentPicto.attributes.coord_y] = $scope.emptyStudentPicto; [studentPicto.attributes.coord_y] = $scope.emptyStudentPicto;
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
action: 'delete', action: 'delete',
attributes: { attributes: {
id_stu: $scope.studentData.id, id_stu: $scope.studentData.id,
stu_picto: studentPicto stu_picto: studentPicto.id
} }
}, function () {}); }, function () {});
}).error(function () {});
} $translate('picto_removed').then(function (translation) {
ngToast.danger({ content: translation });
});
}).error(function () {});
}
});
}; };
$scope.deleteFreePicto = function (studentPicto) { $scope.deleteFreePicto = function (studentPicto) {
var deleteStuPicto = $window.confirm('Are you absolutely sure you want to delete?'); $translate('confirmation').then(t => {
if (deleteStuPicto) { if ($window.confirm(t)) {
$http.delete(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + studentPicto.id) $http.delete(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + studentPicto.id)
.success(function () { .success(function () {
$scope.freeCategoryPictos $scope.freeCategoryPictos
[studentPicto.attributes.free_category_coord_x] [studentPicto.attributes.free_category_coord_x]
[studentPicto.attributes.free_category_coord_y] = $scope.emptyStudentPicto; [studentPicto.attributes.free_category_coord_y] = $scope.emptyStudentPicto;
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
action: 'delete', action: 'delete',
attributes: { attributes: {
id_stu: $scope.studentData.id, id_stu: $scope.studentData.id,
stu_picto: studentPicto stu_picto: studentPicto.id
} }
}, function () {}); }, function () {});
}).error(function () {});
} $translate('picto_removed').then(function (translation) {
ngToast.danger({ content: translation });
});
}).error(function () {});
}
});
}; };
// View student picto // View student picto
...@@ -248,6 +261,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -248,6 +261,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
attributes: studentPicto.attributes attributes: studentPicto.attributes
}) })
.success(function (newStudentPicto) { .success(function (newStudentPicto) {
// notify
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
action: 'update', action: 'update',
attributes: { attributes: {
...@@ -312,6 +327,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -312,6 +327,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}, },
sup: function () { sup: function () {
return $scope.user; return $scope.user;
},
stu: function () {
return $scope.studentData;
} }
} }
}); });
......
...@@ -9,7 +9,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta ...@@ -9,7 +9,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
// Student // Student
$scope.stu = stu; $scope.stu = stu;
// Supervisor // Supervisor
$scope.sup = sup; $scope.sup = sup;
// Picto // Picto
$scope.studentPicto = studentPicto; $scope.studentPicto = studentPicto;
...@@ -24,7 +24,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta ...@@ -24,7 +24,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
// Comprobación del supervisor propietario del picto // Comprobación del supervisor propietario del picto
if(studentPicto.picto.owner == sup.id){ if(studentPicto.picto.owner == sup.id){
$http $http
.post(config.backend+'/picto/exp', .post(config.backend+'/picto/exp',
{ 'picto': studentPicto.picto.id, { 'picto': studentPicto.picto.id,
'lang': $scope.sup.lang, 'lang': $scope.sup.lang,
'text': $scope.expression 'text': $scope.expression
...@@ -36,6 +36,14 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta ...@@ -36,6 +36,14 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
$modalInstance.close($scope.expression); $modalInstance.close($scope.expression);
// Notifcar cambio // Notifcar cambio
io.socket.post('/stu/vocabulary', {
action: 'update',
attributes: {
id_stu: student.id,
stu_picto: studentPicto.id
}
}, function () {});
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
...@@ -48,7 +56,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta ...@@ -48,7 +56,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
console.log("Atributos: " + JSON.stringify($scope.studentPicto.attributes)); console.log("Atributos: " + JSON.stringify($scope.studentPicto.attributes));
$http $http
.put(config.backend+'/stu/'+ $scope.stu.id + '/picto/' + .put(config.backend+'/stu/'+ $scope.stu.id + '/picto/' +
$scope.studentPicto.id, { 'attributes': $scope.studentPicto.attributes }) $scope.studentPicto.id, { 'attributes': $scope.studentPicto.attributes })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
console.log("Properties updated"); console.log("Properties updated");
...@@ -58,15 +66,15 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta ...@@ -58,15 +66,15 @@ dashboardControllers.controller('PictoConfigCtrl', function ($scope, $modalInsta
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
action: 'update', action: 'update',
attributes: { attributes: {
id_stu: $scope.stu.id, id_stu: $scope.stu.id,
picto: data picto: data
} }
}, },
function(res) { function(res) {
console.log("Vocabulary emited: " + JSON.stringify(res.msg)); console.log("Vocabulary emited: " + JSON.stringify(res.msg));
}); });
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
......
...@@ -15,9 +15,9 @@ dashboardControllers.controller('PictoExpCtrl', function ($scope, $modalInstance ...@@ -15,9 +15,9 @@ dashboardControllers.controller('PictoExpCtrl', function ($scope, $modalInstance
// Save expression // Save expression
$scope.save = function () { $scope.save = function () {
$http $http
.post(config.backend+'/picto/exp', .post(config.backend+'/picto/exp',
{ 'picto': picto.id, { 'picto': picto.id,
'lang': $scope.sup.lang, 'lang': $scope.sup.lang,
'text': $scope.expression 'text': $scope.expression
...@@ -27,13 +27,11 @@ dashboardControllers.controller('PictoExpCtrl', function ($scope, $modalInstance ...@@ -27,13 +27,11 @@ dashboardControllers.controller('PictoExpCtrl', function ($scope, $modalInstance
// Close the modal instance // Close the modal instance
$modalInstance.close(data); $modalInstance.close(data);
// Notifcar cambio
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
}); });
}; };
$scope.close = function () { $scope.close = function () {
......
...@@ -12,12 +12,16 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl( ...@@ -12,12 +12,16 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
config, config,
studentPicto, studentPicto,
sup, sup,
stu,
$translate, $translate,
ngToast) { ngToast) {
// Supervisor // Supervisor
$scope.sup = sup; $scope.sup = sup;
// Student
$scope.stu = stu;
// List of tags // List of tags
$scope.tags = []; // tags we don't own $scope.tags = []; // tags we don't own
$scope.ownTags = []; // tags we own $scope.ownTags = []; // tags we own
...@@ -43,6 +47,17 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl( ...@@ -43,6 +47,17 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
$scope.ownTags.push(data); $scope.ownTags.push(data);
studentPicto.tags.push(data); studentPicto.tags.push(data);
$scope.tagToAdd = ''; $scope.tagToAdd = '';
// Notifcar cambio
io.socket.post('/stu/vocabulary', {
action: 'update',
attributes: {
id_stu: $scope.stu,
stu_picto: studentPicto.id
}
}, function () {});
}) })
.error(function () { .error(function () {
$translate('error_adding_tag').then(function (translation) { $translate('error_adding_tag').then(function (translation) {
......
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