fixed issue #506: tags handling fully operational

parent bcecdaa7
......@@ -354,6 +354,7 @@ module.exports = {
// Populate expressions to get it with the picto
Picto.findOne(stuPicto.picto.id)
.populate('expressions', {lang: student.lang})
.populate('tags', {lang: student.lang})
.then((picto) => {
// check picto has expressions associated in student language
......@@ -371,12 +372,15 @@ module.exports = {
return;
}
// Now we have everythin, so we add the picto to the list
//sails.log.debug("Tags: " + JSON.stringify(stuPicto.picto.tags));
// Now we have everything, so we add the picto to the list
var stuPictoToAdd = {
"id": stuPicto.id,
"picto": stuPicto.picto,
"expression": picto.expressions[0],
"attributes": stuPicto.attributes
"attributes": stuPicto.attributes,
"tags": picto.tags ? picto.tags : []
};
l.push(stuPictoToAdd);
......
......@@ -24,7 +24,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
uri: '/app/img/empty.gif',
category: null,
source: 1,
owner: null
owner: null,
tags: null
},
expression: {
id: null,
......@@ -82,6 +83,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.freeCategoryPictos = $scope.freeCategoryPictos || generateGrid();
$scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] =
$scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] || generateGrid();
$http.get(config.backend + '/stu/' + $scope.studentData.id + '/pictos')
.success(function (studentPictos) {
$scope.categories = [];
......@@ -114,7 +116,11 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.loadingPictos = false;
setTimeout(function () { $scope.$apply(); });
})
.error(function () {});
.error(function () {
$translate('error_loading_pictos').then(function (translation) {
ngToast.danger({ content: translation });
});
});
};
// Show the pictograms of a category when it is clicked
......
......@@ -14,23 +14,19 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
sup,
$translate,
ngToast) {
// Supervisor
$scope.sup = sup;
// List of general tags
$scope.tags = [];
// List of own tags
$scope.ownTags = [];
// Request of general tags
$http.get(config.backend + '/picto/' + studentPicto.picto.id)
.success(function (data) {
$scope.tags = data.tags;
$scope.ownTags = data.tagsSup;
})
.error(function () {
$translate('error_loading_pictos').then(function (translation) {
ngToast.danger({ content: translation });
});
// List of tags
$scope.tags = []; // tags we don't own
$scope.ownTags = []; // tags we own
studentPicto.tags.forEach((tag, index, arr) => {
if (tag.supervisor == sup.id)
$scope.ownTags.push(tag);
else
$scope.tags.push(tag);
});
// Add own tag
......@@ -45,6 +41,7 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
)
.success(function (data) {
$scope.ownTags.push(data);
studentPicto.tags.push(data);
$scope.tagToAdd = '';
})
.error(function () {
......@@ -64,9 +61,12 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
});
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
for (i = 0; i < $scope.ownTags.length; i++) {
if (tag.id === $scope.ownTags[i].id) {
if (tag.id === $scope.ownTags[i].id)
$scope.ownTags.splice(i, 1);
}
}
for (i = 0; i < studentPicto.tags.length; i++) {
if (tag.id === studentPicto.tags.id)
studentPicto.tags.splice(i, 1);
}
})
.error(function () {
......
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