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,8 +135,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -134,8 +135,8 @@ 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
...@@ -147,16 +148,22 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -147,16 +148,22 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
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 () {});
$translate('picto_removed').then(function (translation) {
ngToast.danger({ content: translation });
});
}).error(function () {}); }).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
...@@ -167,11 +174,17 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -167,11 +174,17 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
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 () {});
$translate('picto_removed').then(function (translation) {
ngToast.danger({ content: translation });
});
}).error(function () {}); }).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;
} }
} }
}); });
......
...@@ -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);
......
...@@ -27,8 +27,6 @@ dashboardControllers.controller('PictoExpCtrl', function ($scope, $modalInstance ...@@ -27,8 +27,6 @@ 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);
......
...@@ -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