minor bug fixed when adding pictos

parent 51d0f4ee
...@@ -70,6 +70,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -70,6 +70,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// function to make category colores brighter // function to make category colores brighter
$scope.shadeColor = function (color, percent) { $scope.shadeColor = function (color, percent) {
if (!color)
return;
var f=parseInt(color.slice(1),16),t=percent<0?0:255,p=percent<0?percent*-1:percent,R=f>>16,G=f>>8&0x00FF,B=f&0x0000FF; var f=parseInt(color.slice(1),16),t=percent<0?0:255,p=percent<0?percent*-1:percent,R=f>>16,G=f>>8&0x00FF,B=f&0x0000FF;
return "#"+(0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1); return "#"+(0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);
}; };
...@@ -102,6 +104,11 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -102,6 +104,11 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
var freeCategoryPositionY = picto.attributes.free_category_coord_y; var freeCategoryPositionY = picto.attributes.free_category_coord_y;
var category; var category;
// Fill with grid (if not done before)
$scope.freeCategoryPictos = $scope.freeCategoryPictos || generateGrid();
$scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] =
$scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] || generateGrid();
if ($scope.isCategory(picto)) { if ($scope.isCategory(picto)) {
$scope.categories.push(picto); $scope.categories.push(picto);
} }
...@@ -326,6 +333,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -326,6 +333,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Send the picto to the server // Send the picto to the server
$http.post(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + pictoId, { $http.post(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + pictoId, {
attributes: { attributes: {
id_cat: $scope.showFreeCategory ? null : $scope.getCategoryId($scope.selectedCategory),
coord_x: $scope.showFreeCategory ? null : col, coord_x: $scope.showFreeCategory ? null : col,
coord_y: $scope.showFreeCategory ? null : row, coord_y: $scope.showFreeCategory ? null : row,
status: 'enabled', status: 'enabled',
...@@ -352,7 +360,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -352,7 +360,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}); });
}); });
$scope.loadPictos(); // not needed
// $scope.loadPictos();
}); });
}; };
......
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