child grid and color picto picker

parent 25729af0
...@@ -267,7 +267,6 @@ CREATE TABLE `grid` ( ...@@ -267,7 +267,6 @@ CREATE TABLE `grid` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0', `active` tinyint(1) NOT NULL DEFAULT '0',
`categories` tinyint(1) NOT NULL DEFAULT '0',
`id_sup` int(11) DEFAULT NULL, `id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
......
...@@ -20,7 +20,7 @@ thisTrigger: BEGIN ...@@ -20,7 +20,7 @@ thisTrigger: BEGIN
END IF; END IF;
-- Load core collection for student -- Load core collection for student
INSERT INTO grid (id_stu,id_sup,name,categories) VALUES (NEW.id, null, 'with_categories', TRUE); INSERT INTO grid (id_stu,id_sup,name) VALUES (NEW.id, null, 'new_grid');
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
CALL grid_create_core(LID,new.id); CALL grid_create_core(LID,new.id);
END;; END;;
......
# Changes
Angular Animate module has to be downgraded in order to be compatible with
the version of AngularJS used. In order to do show, type `bower install` from
*assets/app* directory.
Para actualizar instalaciones antiguas ejecutar en vagrant/roles/database/files
mysql -u root -p pictodb < upgrade.sql
Relanzar trigger-enrolments-integrity-constraints
En sails/src lanzar `npm install` para instalar nuevos paquetes
# Changes for new grid system # Changes for new grid system
-- Rename columns -- Rename columns
...@@ -21,5 +5,8 @@ RENAME TABLE `scene` TO `grid`; ...@@ -21,5 +5,8 @@ RENAME TABLE `scene` TO `grid`;
ALTER TABLE `stu_picto` CHANGE `id_scene` `id_grid` int(11) NOT NULL; ALTER TABLE `stu_picto` CHANGE `id_scene` `id_grid` int(11) NOT NULL;
ALTER TABLE `student` CHANGE `id_active_scene` `id_active_grid` int(11) NULL; ALTER TABLE `student` CHANGE `id_active_scene` `id_active_grid` int(11) NULL;
-- Add new column -- Add new column 'id_child_grid'
ALTER TABLE `stu_picto` ADD `id_child_grid` int(11) NULL; ALTER TABLE `stu_picto` ADD `id_child_grid` int(11) NULL;
-- Drop column 'categories'
ALTER TABLE `grid` DROP COLUMN `categories`;
...@@ -17,11 +17,13 @@ module.exports = { ...@@ -17,11 +17,13 @@ module.exports = {
var params = req.params.all(); var params = req.params.all();
Grid.create({ Grid.create({
name: params.name, name: params.name,
categories: params.categories, //categories: params.categories,
supervisor: params.id_sup, supervisor: params.id_sup,
student: params.id_stu student: params.id_stu
}).then(grid=>{ }).then(grid=>{
if(grid.categories){ //TODO: modificar el create de nuevos grid
/*if(grid.categories){
Grid.query('CALL grid_create_core(?,?) ',[grid.id, grid.student], function(err, result) { Grid.query('CALL grid_create_core(?,?) ',[grid.id, grid.student], function(err, result) {
// if (err) { // if (err) {
// return res.serverError("Could not call stored procedure create grid picto core "+err); // return res.serverError("Could not call stored procedure create grid picto core "+err);
...@@ -29,7 +31,8 @@ module.exports = { ...@@ -29,7 +31,8 @@ module.exports = {
// return res.ok(grid); // return res.ok(grid);
// } // }
}); });
} }*/
return res.ok(grid); return res.ok(grid);
}).catch(function (err){ }).catch(function (err){
...@@ -51,8 +54,8 @@ module.exports = { ...@@ -51,8 +54,8 @@ module.exports = {
res.badRequest(); res.badRequest();
throw new Error('Grid not found'); throw new Error('Grid not found');
} }
var cat = grid.categories;; //var cat = grid.categories;;
delete grid.categories;//To avoid update these fields //delete grid.categories;//To avoid update these fields
delete grid.supervisor; delete grid.supervisor;
delete grid.student; delete grid.student;
grid.name = params.name || grid.name; grid.name = params.name || grid.name;
...@@ -63,7 +66,7 @@ module.exports = { ...@@ -63,7 +66,7 @@ module.exports = {
Student.findOne({id:grid.student}) Student.findOne({id:grid.student})
.then(student => { .then(student => {
student.attributes.categories=cat; //student.attributes.categories=cat;
delete student.password; delete student.password;
student.save(function(error){ student.save(function(error){
if(error){ if(error){
...@@ -138,7 +141,7 @@ module.exports = { ...@@ -138,7 +141,7 @@ module.exports = {
.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=>{
......
...@@ -918,7 +918,7 @@ module.exports = { ...@@ -918,7 +918,7 @@ module.exports = {
.then(function(grid){ .then(function(grid){
if(!grid) if(!grid)
throw new Error("Grid not found"); throw new Error("Grid not found");
console.log("grid ID: " + grid.id) //console.log("grid ID: " + grid.id)
Grid.pictos(grid.id, function(err, pictos){ Grid.pictos(grid.id, function(err, pictos){
if (err) if (err)
return res.serverError("Error obtaining pictos: "+ err); return res.serverError("Error obtaining pictos: "+ err);
...@@ -994,7 +994,6 @@ module.exports = { ...@@ -994,7 +994,6 @@ module.exports = {
}).catch(function(err){ }).catch(function(err){
return res.badRequest("Student not found"); return res.badRequest("Student not found");
}); });
}, },
// //
...@@ -1188,7 +1187,8 @@ module.exports = { ...@@ -1188,7 +1187,8 @@ module.exports = {
} }
StuPicto.update(query, { StuPicto.update(query, {
attributes: params.attributes attributes: params.attributes,
id_child_grid: params.id_child_grid || null
}) })
.then(updated => { .then(updated => {
if (!updated) if (!updated)
......
...@@ -25,9 +25,6 @@ module.exports = { ...@@ -25,9 +25,6 @@ module.exports = {
type: "string", type: "string",
size: 100 size: 100
}, },
categories: {
type: "boolean"
},
supervisor: { //FK de supervisor 1 a N supervisor: { //FK de supervisor 1 a N
columnName: "id_sup", columnName: "id_sup",
required: false, required: false,
...@@ -103,6 +100,7 @@ module.exports = { ...@@ -103,6 +100,7 @@ module.exports = {
"id": stuPicto.id, "id": stuPicto.id,
"picto": stuPicto.picto, "picto": stuPicto.picto,
"id_grid": stuPicto.grid, "id_grid": stuPicto.grid,
"id_child_grid": stuPicto.id_child_grid,
"attributes": stuPicto.attributes, "attributes": stuPicto.attributes,
"tags": picto.tags ? picto.tags : [] "tags": picto.tags ? picto.tags : []
}; };
......
...@@ -33,9 +33,14 @@ module.exports = { ...@@ -33,9 +33,14 @@ module.exports = {
model: 'Picto' model: 'Picto'
}, },
grid: { //FK de Grid 1 a N grid: { //FK de Grid 1 a N
columnName: "id_grid", columnName: 'id_grid',
type: "integer", type: 'integer',
model: "Grid" model: 'Grid'
},
id_child_grid: {
columnName: 'id_child_grid',
type: 'integer',
model: 'Grid'
}, },
/** /**
......
...@@ -133,8 +133,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -133,8 +133,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$http.get(config.backend + '/stu/' + $scope.studentData.id + '/activeGrid') $http.get(config.backend + '/stu/' + $scope.studentData.id + '/activeGrid')
.success(function (activeGrid) { .success(function (activeGrid) {
$scope.showFreeCategory = !activeGrid.categories; console.log("show activegrid" , activeGrid);
activeGrid.name = $translate.instant(activeGrid.name); $scope.showFreeCategory = !activeGrid.categories;
activeGrid.name = $translate.instant(activeGrid.name);
$scope.viewingGrid = activeGrid; $scope.viewingGrid = activeGrid;
activeGrid.pictos.forEach(placePicto); activeGrid.pictos.forEach(placePicto);
$scope.loadingPictos = false; $scope.loadingPictos = false;
...@@ -158,9 +159,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -158,9 +159,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$http.get(config.backend + '/grid/' + idGrid) $http.get(config.backend + '/grid/' + idGrid)
.success(function (grid) { .success(function (grid) {
$scope.showFreeCategory = !grid.categories; $scope.showFreeCategory = !grid.categories;
grid.name = $translate.instant(grid.name); grid.name = $translate.instant(grid.name);
$scope.viewingGrid = grid; $scope.viewingGrid = grid;
grid.pictos.forEach(placePicto); grid.pictos.forEach(placePicto);
$scope.loadingPictos = false; $scope.loadingPictos = false;
...@@ -175,7 +176,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -175,7 +176,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Load the grid list // Load the grid list
$scope.loadGridsList = function () { $scope.loadGridsList = function () {
$http.get(config.backend + '/stu/' + $scope.studentData.id +'/grids') $http.get(config.backend + '/stu/' + $scope.studentData.id +'/grids')
.success(function (grids) { .success(function (grids) {
grids.map((sce) => {sce.name = $translate.instant(sce.name); return sce}); grids.map((sce) => {sce.name = $translate.instant(sce.name); return sce});
...@@ -285,7 +285,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -285,7 +285,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.loadGridsList(); $scope.loadGridsList();
}).error(function () {}); }).error(function () {});
}; };
// Activate student grid // Activate student grid
...@@ -584,6 +583,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -584,6 +583,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Modal window to open picto config // Modal window to open picto config
$scope.open_config = function (studentPicto) { $scope.open_config = function (studentPicto) {
console.log(studentPicto);
var modalInstance = $modal.open({ var modalInstance = $modal.open({
animation: true, animation: true,
templateUrl: 'modules/student/views/pictoconfig.html', templateUrl: 'modules/student/views/pictoconfig.html',
...@@ -601,6 +601,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -601,6 +601,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}, },
viewingGrid: function(){ viewingGrid: function(){
return $scope.viewingGrid; return $scope.viewingGrid;
},
gridsList: function(){
return $scope.gridsList;
} }
} }
}); });
......
...@@ -14,11 +14,16 @@ dashboardControllers.controller('PictoConfigCtrl', function ( ...@@ -14,11 +14,16 @@ dashboardControllers.controller('PictoConfigCtrl', function (
studentPicto, studentPicto,
sup, sup,
stu, stu,
viewingGrid) { viewingGrid,
gridsList
) {
// Picto // Picto
$scope.studentPicto = JSON.parse(JSON.stringify(studentPicto)); $scope.studentPicto = JSON.parse(JSON.stringify(studentPicto));
// Grid list
$scope.gridsList = gridsList;
/* /*
* Save changes introduced in dialog window * Save changes introduced in dialog window
*/ */
...@@ -30,7 +35,8 @@ dashboardControllers.controller('PictoConfigCtrl', function ( ...@@ -30,7 +35,8 @@ dashboardControllers.controller('PictoConfigCtrl', function (
if (studentPicto.picto.owner == sup.id) { if (studentPicto.picto.owner == sup.id) {
$http $http
.post(config.backend+'/picto/exp', .post(config.backend+'/picto/exp',
{ 'picto': studentPicto.picto.id, {
'picto': studentPicto.picto.id,
'lang': sup.lang, 'lang': sup.lang,
'text': $scope.studentPicto.attributes.expression 'text': $scope.studentPicto.attributes.expression
}) })
...@@ -49,7 +55,8 @@ dashboardControllers.controller('PictoConfigCtrl', function ( ...@@ -49,7 +55,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
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
resolve(data); resolve(data);
...@@ -103,5 +110,21 @@ dashboardControllers.controller('PictoConfigCtrl', function ( ...@@ -103,5 +110,21 @@ dashboardControllers.controller('PictoConfigCtrl', function (
// Devolver el picto actualizado, situándolo en su posición // Devolver el picto actualizado, situándolo en su posición
}; };
// Load the grid list
/*$scope.loadGridsList = function () {
console.log("test");
$http.get(config.backend + '/stu/' + stu.id +'/grids')
.success(function (grids) {
grids.map((sce) => {sce.name = $translate.instant(sce.name); return sce});
$scope.gridsList = grids;
})
.error(function () {
$translate('error_loading_grids').then(function (translation) {
ngToast.danger({ content: translation });
});
});
};
$scope.loadGridsList();*/
}); });
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
data-loading="{{ 'loading_pictos' | translate }}"> data-loading="{{ 'loading_pictos' | translate }}">
<!-- No categories grid --> <!-- No categories grid -->
<div <div
ng-if="showFreeCategory"
class="picto-grid picto-free-grid"> class="picto-grid picto-free-grid">
<div <div
ng-repeat="studentPictoRow in freeCategoryPictos" ng-repeat="studentPictoRow in freeCategoryPictos"
...@@ -108,217 +107,6 @@ ...@@ -108,217 +107,6 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
</div> </div>
<!-- / No categories grid -->
<!-- Main categories grid -->
<div
ng-if="!showFreeCategory"
class="picto-grid picto-main-grid">
<div
ng-repeat="studentPictoRow in studentPictos[getCategoryId(emptyStudentPicto)]"
ng-init="rowIndex = $index"
class="picto-grid__row">
<div
ng-hide="studentData.attributes.size == 'large' && (rowIndex > 3 || colIndex > 7)"
class="picto pull-left"
ng-repeat="studentPicto in studentPictoRow track by $index"
ng-init="colIndex = $index"
popover="{{ studentPicto != emptyStudentPicto ? studentPicto.attributes.expression : ''}}"
popover-trigger="mouseenter">
<!-- picto-legend -->
<div
class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression }}
</div>
<div
class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression }}
</div>
<!-- /.picto-legend -->
<img
src="/app/img/redcross.png"
class="red-cross-visibility disabled"
ng-if="studentPicto.attributes.status == 'disabled'"/>
<img
ng-src="{{studentPicto.picto.uri}}"
class="unselectable"
ng-click="show_category(studentPicto)"
ng-class="{
'novisible': studentPicto.attributes.status == 'invisible',
'deactivate': studentPicto.attributes.status == 'disabled'
}"
ng-style="{
'background-color': studentPicto.attributes.color
}"/>
<div
class="picto_options"
ng-if="studentPicto == emptyStudentPicto">
<a
ng-click="open_add(rowIndex, colIndex, true)"
class="picto_add"
title="{{ 'add_picto' | translate}}">
<i class="color_green glyphicon glyphicon-plus-sign" aria-hidden="true"></i>
</a>
</div>
<div
class="picto_options"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y != '0'">
<a ng-click="view_picto(studentPicto)" class="picto_ok" >
<i
ng-class="{
color_green: studentPicto.attributes.status == 'invisible',
color_black: studentPicto.attributes.status == 'enabled'
}"
class="glyphicon glyphicon-eye-open"
aria-hidden="true"
title="{{ studentPicto.attributes.status | translate}}"></i>
</a>
<a
ng-click="change_category(studentPicto)"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y != '0'"
class="picto_cat_edit">
<i
class="glyphicon glyphicon-picture" aria-hidden="true"
title="{{ 'change_cat_picto' | translate}}">
</i>
</a>
</div>
<div
class="picto_options"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y == '0'">
<a
ng-click="delete_picto(studentPicto)"
class="picto_remove"
title="{{ 'delete' | translate}}">
<i class="color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></i>
</a>
<a ng-click="view_picto(studentPicto)" class="picto_ok" >
<i ng-class="{
color_green: studentPicto.attributes.status == 'invisible',
color_black: studentPicto.attributes.status == 'enabled'
}"
class="glyphicon glyphicon-eye-open"
aria-hidden="true"
title="{{ studentPicto.attributes.status | translate}}">
</i>
</a>
<a
class="picto_tags"
ng-click="open_tags(studentPicto)">
<i class="glyphicon glyphicon-tags" aria-hidden="true"></i>
</a>
<a
class="picto_config"
ng-click="open_config(studentPicto)">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
</a>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<!-- / Main categories grid -->
<!-- Category grid -->
<a name="picto-category-grid"/>
<div
id="picto-category-grid"
class="picto-grid picto-category-grid"
ng-if="selectedCategory !== emptyStudentPicto && !showFreeCategory"
ng-style="{ 'background-color': shadeColor(selectedCategory.attributes.color, 0.3) }">
<h3 class="picto-category-grid__title">{{ selectedCategory.attributes.expression }}</h3>
<div
ng-repeat="studentPictoRow in studentPictos[getCategoryId(selectedCategory)]"
ng-init="rowIndex = $index"
class="picto-grid__row">
<div
ng-hide="studentData.attributes.size == 'large' && (rowIndex > 3 || colIndex > 7)"
class="picto pull-left"
data-row="{{ rowIndex }}"
data-column="{{ colIndex }}"
id="student-picto-{{
studentPicto.id ||
('empty-' + colIndex + '-' + rowIndex)
}}"
draggable droppable drop="handleDrop"
popover="{{ studentPicto != emptyStudentPicto ? studentPicto.attributes.expression : '' }}"
popover-trigger="mouseenter"
ng-repeat="studentPicto in studentPictoRow track by $index"
ng-init="colIndex = $index">
<!-- picto-legend -->
<div
class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression }}
</div>
<div
class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression }}
</div>
<!-- /.picto-legend -->
<img
src="/app/img/redcross.png"
class="red-cross-visibility disabled"
ng-if="studentPicto.attributes.status == 'disabled'"/>
<img
ng-src="{{studentPicto.picto.uri}}"
class="unselectable"
ng-class="{
'novisible': studentPicto.attributes.status == 'invisible',
'deactivate': studentPicto.attributes.status == 'disabled'
}"
ng-style="{
'background-color': studentPicto.attributes.color || '#ffffff'
}"
/>
<div
class="picto_options"
ng-if="studentPicto == emptyStudentPicto">
<a
ng-click="open_add(rowIndex, colIndex, false)"
class="picto_add"
title="{{ 'add_picto' | translate}}">
<i class="color_green glyphicon glyphicon-plus-sign" aria-hidden="true"></i>
</a>
</div>
<div
class="picto_options"
ng-if="studentPicto !== emptyStudentPicto">
<a
ng-click="delete_picto(studentPicto)"
class="picto_remove"
title="{{ 'delete' | translate}}">
<i class="color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></i>
</a>
<a ng-click="view_picto(studentPicto)" class="picto_ok" >
<i ng-class="{
color_green: studentPicto.attributes.status == 'invisible',
color_black: studentPicto.attributes.status == 'enabled'
}"
class="glyphicon glyphicon-eye-open"
aria-hidden="true"
title="{{ studentPicto.attributes.status | translate}}">
</i>
</a>
<a
class="picto_tags"
ng-click="open_tags(studentPicto)">
<i class="glyphicon glyphicon-tags" aria-hidden="true"></i>
</a>
<a
class="picto_config"
ng-click="open_config(studentPicto)">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
</a>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<!-- / Category grid -->
</div> </div>
</div><!--/. col-xs-10 --> </div><!--/. col-xs-10 -->
......
...@@ -56,7 +56,52 @@ ...@@ -56,7 +56,52 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false"> <input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false">
<span translate>legend_apply_all</span> <span translate>
Aplicar leyenda a todos los pictogramas del tablero
</span>
</div>
</div>
</div>
<hr>
<div class="form-group">
<div class="row">
<label translate>Tablero asociado</label><br/>
</div>
<div class="row">
<div class="col-md-6">
<select class="form-control" name="child_grid" id="child_grid" ng-model="studentPicto.id_child_grid">
<option
ng-repeat="grid in gridsList track by $index"
ng-if="grid.id != studentPicto.id_grid"
ng-selected="(grid.id == studentPicto.id_child_grid)"
value="{{ grid.id }}">{{ grid.name }}
</option>
</select>
</div>
<div class="col-md-6">
<div class="alert alert-info" style="margin: 0 auto;" translate>
Seleccione el tablero que se mostrará al pulsar sobre el pictograma
</div>
</div>
</div>
</div>
<hr>
<div class="form-group">
<div class="row">
<label translate>Color de fondo</label><br/>
</div>
<div class="row">
<div class="col-md-6">
Color: <input type="color" name="favcolor" value="{{studentPicto.attributes.color}}" ng-init="studentPicto.attributes.color" style="width:20px;height:20px;" ng-model="studentPicto.attributes.color">
</div>
<div class="col-md-6">
<div class="alert alert-info" style="margin: 0 auto;" translate>
Seleccione un color de fondo para el pictograma
</div>
</div> </div>
</div> </div>
</div> </div>
......
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