issue #676 fixed

parent 9a113ef3
...@@ -79,6 +79,10 @@ module.exports = { ...@@ -79,6 +79,10 @@ module.exports = {
var l = []; var l = [];
var fs = require('fs'); var fs = require('fs');
// return empty for category 0 (that represents category pictos and all custom pictos)
if (req.params.id_cat == 0)
return res.ok(l);
Supervisor.findOne({ id: req.params.id }).then(function (supervisor) { Supervisor.findOne({ id: req.params.id }).then(function (supervisor) {
if (supervisor) { if (supervisor) {
Picto.find({ category: req.params.id_cat }) Picto.find({ category: req.params.id_cat })
...@@ -103,12 +107,12 @@ module.exports = { ...@@ -103,12 +107,12 @@ module.exports = {
function (err) { // loop has end function (err) { // loop has end
if (err) throw err; if (err) throw err;
sails.log.debug(pictos.length + " pictos sent for category " + req.params.id_cat + " in language " + supervisor.lang); sails.log.debug(pictos.length + " pictos sent for category " + req.params.id_cat + " in language " + supervisor.lang);
res.ok(l); return res.ok(l);
}); // end async.eachSeries }); // end async.eachSeries
}) })
.catch(() => res.badRequest()); .catch(() => res.badRequest());
} else { } else {
res.badRequest(); return res.badRequest();
} }
}) })
.catch(() => res.serverError()); .catch(() => res.serverError());
......
/* global Supervisor, sails */ /* global Supervisor, sails */
const lodash = require('lodash');
/** /**
* supervisor.js * supervisor.js
......
...@@ -63,7 +63,6 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -63,7 +63,6 @@ dashboardControllers.controller('AddPictoCtrl', function (
// //
// Load pictos from owned by the actual supervisor // Load pictos from owned by the actual supervisor
// TEST --> change with real supervisor pictos
// //
$scope.load_own_pictos = function () { $scope.load_own_pictos = function () {
$scope.source = 'ownpictos'; $scope.source = 'ownpictos';
......
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