issue #455 fixed

parent ca331421
...@@ -139,21 +139,25 @@ module.exports = { ...@@ -139,21 +139,25 @@ module.exports = {
duplicate: function(req,res){ duplicate: function(req,res){
Grid.findOne({id:req.params.id}) Grid.findOne({id:req.params.id})
.populate('stuPictos').then(function(grid){ .populate('stuPictos')
.then(function(grid) {
Grid.create({ Grid.create({
name: grid.name, name: grid.name,
//categories: grid.categories, //categories: grid.categories,
supervisor: grid.supervisor, supervisor: grid.supervisor,
student: grid.student student: grid.student
}).then(newGrid=>{ })
.then((newGrid) => {
grid.stuPictos.forEach(function (stuPicto, cb) { grid.stuPictos.forEach(function (stuPicto, cb) {
StuPicto.create({ StuPicto.create({
student: stuPicto.student, student: stuPicto.student,
picto: stuPicto.picto, picto: stuPicto.picto,
grid: newGrid.id, grid: newGrid.id,
childGrid: stuPicto.childGrid,
attributes: stuPicto.attributes attributes: stuPicto.attributes
}).catch(function (err){ })
console.log("Error creating stu_picto "+err.details); .catch(function (err){
console.log("Error creating stu_picto " + err.details);
sails.log.error(err.details); sails.log.error(err.details);
}); });
}); });
......
...@@ -1189,7 +1189,7 @@ module.exports = { ...@@ -1189,7 +1189,7 @@ module.exports = {
StuPicto.update(query, { StuPicto.update(query, {
attributes: params.attributes, attributes: params.attributes,
id_child_grid: params.id_child_grid || null childGrid: params.childGrid || null
}) })
.then(updated => { .then(updated => {
if (!updated) if (!updated)
......
...@@ -101,12 +101,12 @@ module.exports = { ...@@ -101,12 +101,12 @@ module.exports = {
stuPicto.attributes.uri_sound = stuPicto.attributes.uri_sound ? stuPicto.attributes.uri_sound : null; stuPicto.attributes.uri_sound = stuPicto.attributes.uri_sound ? stuPicto.attributes.uri_sound : null;
stuPicto.attributes.user_avatar = stuPicto.attributes.user_avatar ? stuPicto.attributes.user_avatar : null; stuPicto.attributes.user_avatar = stuPicto.attributes.user_avatar ? stuPicto.attributes.user_avatar : null;
var stuPictoToAdd = { var stuPictoToAdd = {
"id": stuPicto.id, id: stuPicto.id,
"picto": stuPicto.picto, picto: stuPicto.picto,
"id_grid": stuPicto.grid, grid: stuPicto.grid,
"id_child_grid": stuPicto.id_child_grid, childGrid: stuPicto.childGrid,
"attributes": stuPicto.attributes, attributes: stuPicto.attributes,
"tags": picto.tags ? picto.tags : [] tags: picto.tags ? picto.tags : []
}; };
l.push(stuPictoToAdd); l.push(stuPictoToAdd);
next_cb(); next_cb();
......
...@@ -37,7 +37,7 @@ module.exports = { ...@@ -37,7 +37,7 @@ module.exports = {
type: 'integer', type: 'integer',
model: 'Grid' model: 'Grid'
}, },
id_child_grid: { childGrid: {
columnName: 'id_child_grid', columnName: 'id_child_grid',
type: 'integer', type: 'integer',
model: 'Grid' model: 'Grid'
......
...@@ -396,7 +396,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -396,7 +396,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$http.put(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + studentPicto.id, { $http.put(config.backend + '/stu/' + $scope.studentData.id + '/picto/' + studentPicto.id, {
attributes: studentPicto.attributes, attributes: studentPicto.attributes,
id_child_grid: studentPicto.id_child_grid childGrid: studentPicto.childGrid
}) })
.success(function (newStuPicto) { .success(function (newStuPicto) {
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
......
...@@ -57,8 +57,8 @@ dashboardControllers.controller('PictoConfigCtrl', function ( ...@@ -57,8 +57,8 @@ dashboardControllers.controller('PictoConfigCtrl', function (
$http $http
.put(config.backend+'/stu/'+ stu.id + '/picto/' + $scope.studentPicto.id, .put(config.backend+'/stu/'+ stu.id + '/picto/' + $scope.studentPicto.id,
{ {
'attributes': $scope.studentPicto.attributes, attributes: $scope.studentPicto.attributes,
'id_child_grid': $scope.studentPicto.id_child_grid || null childGrid: $scope.studentPicto.childGrid || null
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
resolve(data); resolve(data);
......
...@@ -59,14 +59,14 @@ ...@@ -59,14 +59,14 @@
<!-- Red cross --> <!-- Red cross -->
<img src="/app/img/redcross.png" <img src="/app/img/redcross.png"
ng-click="showGrid(studentPicto.id_child_grid,'parentPicto')" ng-click="showGrid(studentPicto.childGrid,'parentPicto')"
class="red-cross-visibility disabled" class="red-cross-visibility disabled"
ng-if="studentPicto.attributes.status == 'disabled'"> ng-if="studentPicto.attributes.status == 'disabled'">
<!--./ Red cross --> <!--./ Red cross -->
<!-- Picto --> <!-- Picto -->
<img class="unselectable" <img class="unselectable"
ng-click="showGrid(studentPicto.id_child_grid,'parentPicto')" ng-click="showGrid(studentPicto.childGrid,'parentPicto')"
ng-src="{{studentPicto.picto.uri}}" ng-src="{{studentPicto.picto.uri}}"
ng-class="{ 'novisible': studentPicto.attributes.status == 'invisible', 'deactivate': studentPicto.attributes.status == 'disabled' }" ng-class="{ 'novisible': studentPicto.attributes.status == 'invisible', 'deactivate': studentPicto.attributes.status == 'disabled' }"
ng-style="{ 'background-color': studentPicto.attributes.color || '#ffffff' }"> ng-style="{ 'background-color': studentPicto.attributes.color || '#ffffff' }">
......
...@@ -64,12 +64,12 @@ ...@@ -64,12 +64,12 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<select class="form-control" ng-model="studentPicto.id_child_grid"> <select class="form-control" ng-model="studentPicto.childGrid">
<option value="">--- Ninguno ---</option> <option value="">--- Ninguno ---</option>
<option <option
ng-repeat="grid in gridsList track by $index" ng-repeat="grid in gridsList track by $index"
ng-if="grid.id != viewingGrid.id" ng-if="grid.id != viewingGrid.id"
ng-selected="(grid.id == studentPicto.id_child_grid)" ng-selected="(grid.id == studentPicto.childGrid)"
value="{{ grid.id }}">{{ grid.name }} value="{{ grid.id }}">{{ grid.name }}
</option> </option>
</select> </select>
......
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