issue #248 fixed

parent f4473d5c
......@@ -11,6 +11,7 @@ Los ficheros SQL que importará este rol son los siguientes:
los datos almacenados por symbolstx.
- [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`.
- [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
- [triggers-enrolments-integrity-constraints][7] añade disparadores para el control de
integridad de inscripciones.
......@@ -34,3 +35,5 @@ Obsoleto:
[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
[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
CREATE TABLE IF NOT EXISTS `meta_method` (
`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,
`id_sup` INT( 11 ) DEFAULT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
......
......@@ -33,7 +33,7 @@ module.exports = {
res.ok(metaMethods);
})
.catch(function (err) {
res.serverError(err);
res.serverError(err.message);
});
},
......
......@@ -304,7 +304,7 @@ module.exports = {
Picto.create({
uri: pictoFileName,
source: 1, // @TODO check for other sources
source: 2, // 1 -> SymbolStix, 2 -> custom
owner: supervisor.id
})
.then(picto => {
......
......@@ -12,7 +12,7 @@ module.exports = {
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
......@@ -25,6 +25,11 @@ module.exports = {
type: "string",
size: 40
},
lang: {
required: true,
type: "string",
size: 5
},
description: {
type: "string",
size: 1024
......@@ -35,10 +40,10 @@ module.exports = {
required: false,
model: "Supervisor"
},
// Relación con MetaInstruction. [1 MetaMethod to N MetaInstruction]
// Relación con MetaInstruction. [1 MetaMethod to N MetaInstruction]
metainstructions: {
collection: "MetaInstruction",
via: "id_met"
}
}
};
\ No newline at end of file
};
......@@ -14,6 +14,25 @@
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`
var req = this.req;
var res = this.res;
......@@ -30,7 +49,7 @@ module.exports = function serverError (data, options) {
// If the user-agent wants JSON, always respond with JSON
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.
......@@ -60,7 +79,7 @@ module.exports = function serverError (data, options) {
else {
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);
......
......@@ -6,7 +6,7 @@
"license": "Private",
"private": true,
"dependencies": {
"angular": "1.3.x",
"angular": "1.2.x",
"angular-mocks": "1.3.x",
"jquery": "~2.1.1",
"bootstrap": "~3.1.1",
......
......@@ -24,12 +24,15 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.get(config.backend+'/method/template/' + $scope.user.id)
.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
$scope.methods_available = data;
console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available));
// 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) {
console.log("Error from API: " + data.error);
......
......@@ -4,7 +4,14 @@
<div class="panel-body">
<!-- Select to add new method -->
<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>
</select>
......@@ -22,18 +29,19 @@
<!-- Method instructions -->
<div class="method_details" ng-repeat="m in methods">
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/>
<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="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>
<textarea class="editable" ng-model="m.description " placeholder="{{'description' | translate}}" ng-blur="update_method(m)"></textarea>
<!-- Tabla método -->
<table class="table_instructions table">
<tr>
......@@ -66,12 +74,12 @@
</div>
</td>
<td class="editable_status">
<span class="pointer text_medium glyphicon" ng-class="{
'color_green': i.status == 'finished',
'glyphicon-check': i.status == 'finished',
'color_blue': i.status == 'started',
'glyphicon-edit': i.status == 'started',
'glyphicon-minus': i.status == null
<span class="pointer text_medium glyphicon" ng-class="{
'color_green': i.status == 'finished',
'glyphicon-check': i.status == 'finished',
'color_blue': i.status == 'started',
'glyphicon-edit': i.status == 'started',
'glyphicon-minus': i.status == null
}" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span>
</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 @@
</div>
<!-- END .panel-body -->
</div>
<!-- END .panel -->
\ No newline at end of file
<!-- END .panel -->
......@@ -6,5 +6,6 @@
dashboardControllers.controller('TranslateController', function($translate, $scope) {
$scope.changeLanguage = function (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