issue #248 fixed

parent f4473d5c
...@@ -11,6 +11,7 @@ Los ficheros SQL que importará este rol son los siguientes: ...@@ -11,6 +11,7 @@ Los ficheros SQL que importará este rol son los siguientes:
los datos almacenados por symbolstx. los datos almacenados por symbolstx.
- [pictodb-schema][3] contiene el esquema de la base de datos. - [pictodb-schema][3] contiene el esquema de la base de datos.
- [pictodb-data][4] contiene la información básica que la aplicación necesita para funcionar. Añade información a las tablas `meta_method`, `meta_instruction`, `source`, `picto_core` y `picto_exp`. - [pictodb-data][4] contiene la información básica que la aplicación necesita para funcionar. Añade información a las tablas `meta_method`, `meta_instruction`, `source`, `picto_core` y `picto_exp`.
- [pitcodb-core][11] y [pictodb-corexp][12] contienen la información del subconjunto de symbolstix que conforma el vocabulario básico de un estudiante recién creado
- [symbolstx][11] añade la colección de Symbolstix - [symbolstx][11] añade la colección de Symbolstix
- [triggers-enrolments-integrity-constraints][7] añade disparadores para el control de - [triggers-enrolments-integrity-constraints][7] añade disparadores para el control de
integridad de inscripciones. integridad de inscripciones.
...@@ -34,3 +35,5 @@ Obsoleto: ...@@ -34,3 +35,5 @@ Obsoleto:
[8]: /softuno/pictogram/blob/develop/sails/roles/database/files/triggers-sessions-integrity-constraints.sql [8]: /softuno/pictogram/blob/develop/sails/roles/database/files/triggers-sessions-integrity-constraints.sql
[9]: /softuno/pictogram/blob/develop/sails/roles/database/files/test-autismojaen.sql [9]: /softuno/pictogram/blob/develop/sails/roles/database/files/test-autismojaen.sql
[10]: /softuno/pictogram/blob/develop/sails/roles/database/files/test-caja.sql [10]: /softuno/pictogram/blob/develop/sails/roles/database/files/test-caja.sql
[11]: /softuno/pictogram/blob/develop/sails/roles/database/files/pictodb-core.sql
[12]: /softuno/pictogram/blob/develop/sails/roles/database/files/pictodb-coreexp.sql
...@@ -106,7 +106,7 @@ COMMENT="One in a set of instructions predefined or stored by users. They are re ...@@ -106,7 +106,7 @@ COMMENT="One in a set of instructions predefined or stored by users. They are re
CREATE TABLE IF NOT EXISTS `meta_method` ( CREATE TABLE IF NOT EXISTS `meta_method` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT, `id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_sup` INT( 11 ) DEFAULT NULL, `id_sup` INT( 11 ) DEFAULT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL, `lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
......
...@@ -33,7 +33,7 @@ module.exports = { ...@@ -33,7 +33,7 @@ module.exports = {
res.ok(metaMethods); res.ok(metaMethods);
}) })
.catch(function (err) { .catch(function (err) {
res.serverError(err); res.serverError(err.message);
}); });
}, },
......
...@@ -304,7 +304,7 @@ module.exports = { ...@@ -304,7 +304,7 @@ module.exports = {
Picto.create({ Picto.create({
uri: pictoFileName, uri: pictoFileName,
source: 1, // @TODO check for other sources source: 2, // 1 -> SymbolStix, 2 -> custom
owner: supervisor.id owner: supervisor.id
}) })
.then(picto => { .then(picto => {
......
...@@ -12,7 +12,7 @@ module.exports = { ...@@ -12,7 +12,7 @@ module.exports = {
autoPK : false, autoPK : false,
autoCreatedAt : false, autoCreatedAt : false,
autoUpdatedAt : false, autoUpdatedAt : false,
attributes: { attributes: {
id: { id: {
type: "integer", type: "integer",
...@@ -25,6 +25,11 @@ module.exports = { ...@@ -25,6 +25,11 @@ module.exports = {
type: "string", type: "string",
size: 40 size: 40
}, },
lang: {
required: true,
type: "string",
size: 5
},
description: { description: {
type: "string", type: "string",
size: 1024 size: 1024
...@@ -35,10 +40,10 @@ module.exports = { ...@@ -35,10 +40,10 @@ module.exports = {
required: false, required: false,
model: "Supervisor" model: "Supervisor"
}, },
// Relación con MetaInstruction. [1 MetaMethod to N MetaInstruction] // Relación con MetaInstruction. [1 MetaMethod to N MetaInstruction]
metainstructions: { metainstructions: {
collection: "MetaInstruction", collection: "MetaInstruction",
via: "id_met" via: "id_met"
} }
} }
}; };
\ No newline at end of file
...@@ -14,6 +14,25 @@ ...@@ -14,6 +14,25 @@
module.exports = function serverError (data, options) { module.exports = function serverError (data, options) {
//
// This function avoids converting to JSON circular structures
//
function avoidCircular (object) {
var cache = [];
for (var property in object) {
if (object.hasOwnProperty(property)) {
if (typeof object[property] === 'object' && object[property] !== null) {
if (cache.indexOf(value) !== -1) {
delete object[property];
}
// Store value in our collection
cache.push(value);
}
}
}
return object;
}
// Get access to `req`, `res`, & `sails` // Get access to `req`, `res`, & `sails`
var req = this.req; var req = this.req;
var res = this.res; var res = this.res;
...@@ -30,7 +49,7 @@ module.exports = function serverError (data, options) { ...@@ -30,7 +49,7 @@ module.exports = function serverError (data, options) {
// If the user-agent wants JSON, always respond with JSON // If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) { if (req.wantsJSON) {
return res.jsonx(data); return res.jsonx(avoidCircular(data));
} }
// If second argument is a string, we take that to mean it refers to a view. // If second argument is a string, we take that to mean it refers to a view.
...@@ -60,7 +79,7 @@ module.exports = function serverError (data, options) { ...@@ -60,7 +79,7 @@ module.exports = function serverError (data, options) {
else { else {
sails.log.warn('res.serverError() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err); sails.log.warn('res.serverError() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
} }
return res.jsonx(data); return res.jsonx(avoidCircular(data));
} }
return res.send(html); return res.send(html);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"license": "Private", "license": "Private",
"private": true, "private": true,
"dependencies": { "dependencies": {
"angular": "1.3.x", "angular": "1.2.x",
"angular-mocks": "1.3.x", "angular-mocks": "1.3.x",
"jquery": "~2.1.1", "jquery": "~2.1.1",
"bootstrap": "~3.1.1", "bootstrap": "~3.1.1",
......
...@@ -24,12 +24,15 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -24,12 +24,15 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http $http
.get(config.backend+'/method/template/' + $scope.user.id) .get(config.backend+'/method/template/' + $scope.user.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
for (var i = 0; i < data.length; i++) {
data[i].disabled = data[i].lang != $translate.use();
}
// Add to list // Add to list
$scope.methods_available = data; $scope.methods_available = data;
console.log("Meta Methods charged:"); console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available)); console.log(JSON.stringify($scope.methods_available));
// Option to add new methods // Option to add new methods
$scope.methods_available.push({ id: 0, name: $translate.instant('new_method') }); $scope.methods_available.push({ id: 0, name: $translate.instant('new_method'), disabled: false });
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
<div class="panel-body"> <div class="panel-body">
<!-- Select to add new method --> <!-- Select to add new method -->
<div class="form-group"> <div class="form-group">
<select class="form-control" name="method_select" id="method_select" ng-model="method_selected" ng-options="ma.name for ma in methods_available"> <select class="form-control" name="method_select" id="method_select" ng-model="method_selected">
<option ng-repeat="ma in methods_available track by $index"
value="{{ $index }}"
label="{{ ma.name }}"
ng-if="ma.lang == user.lang">
{{ ma.name }}
</option>
<option value="" translate>select_method</option> <option value="" translate>select_method</option>
</select> </select>
...@@ -22,18 +29,19 @@ ...@@ -22,18 +29,19 @@
<!-- Method instructions --> <!-- Method instructions -->
<div class="method_details" ng-repeat="m in methods"> <div class="method_details" ng-repeat="m in methods">
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/> <input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/>
<div class="options"> <div class="options">
<a ng-click="save_as_template(m)" popover="{{ 'save_as_template' | translate}}" popover-trigger="mouseenter"><span class="text_medium color_black glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></a> <a ng-click="save_as_template(m)" popover="{{ 'save_as_template' | translate}}" popover-trigger="mouseenter"><span class="text_medium color_black glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></a>
<a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a> <a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a>
</div> </div>
<textarea class="editable" ng-model="m.description " placeholder="{{'description' | translate}}" ng-blur="update_method(m)"></textarea> <textarea class="editable" ng-model="m.description " placeholder="{{'description' | translate}}" ng-blur="update_method(m)"></textarea>
<!-- Tabla método --> <!-- Tabla método -->
<table class="table_instructions table"> <table class="table_instructions table">
<tr> <tr>
...@@ -66,12 +74,12 @@ ...@@ -66,12 +74,12 @@
</div> </div>
</td> </td>
<td class="editable_status"> <td class="editable_status">
<span class="pointer text_medium glyphicon" ng-class="{ <span class="pointer text_medium glyphicon" ng-class="{
'color_green': i.status == 'finished', 'color_green': i.status == 'finished',
'glyphicon-check': i.status == 'finished', 'glyphicon-check': i.status == 'finished',
'color_blue': i.status == 'started', 'color_blue': i.status == 'started',
'glyphicon-edit': i.status == 'started', 'glyphicon-edit': i.status == 'started',
'glyphicon-minus': i.status == null 'glyphicon-minus': i.status == null
}" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span> }" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span>
</td> </td>
<td><a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a></td> <td><a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a></td>
...@@ -91,4 +99,4 @@ ...@@ -91,4 +99,4 @@
</div> </div>
<!-- END .panel-body --> <!-- END .panel-body -->
</div> </div>
<!-- END .panel --> <!-- END .panel -->
\ No newline at end of file
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
dashboardControllers.controller('TranslateController', function($translate, $scope) { dashboardControllers.controller('TranslateController', function($translate, $scope) {
$scope.changeLanguage = function (langKey) { $scope.changeLanguage = function (langKey) {
$translate.use(langKey); $translate.use(langKey);
$scope.user.lang = langKey;
}; };
}); });
\ No newline at end of file
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