bug of issues #311 and #310 fixed. Also, found bug when deleting method with…

bug of issues #311 and #310 fixed. Also, found bug when deleting method with sessions associated solved with an alert box
parent 5b85ebae
......@@ -36,6 +36,7 @@ sails/config/tmp.sql
android/Pictogrammar/.idea
.idea
android/Pictogrammar/app/app.iml
android/Pictogrammar/Pictogrammar.iml
# Packages #
############
......
......@@ -38,6 +38,9 @@ android {
FernandoFlavor {
resValue "string", "server", "https://127.0.0.1:9944"
}
ArturoFlavor {
resValue "string", "server", "https://192.168.1.37:1337"
}
DefaultFlavor {
resValue "string", "server", "https://pre.yottacode.com:1337"
}
......@@ -47,9 +50,12 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile fileTree(dir: 'E:\\Users\\Fernando\\Google Drive\\experimentos\\Pictogrammar\\android\\app\\libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.github.nkzawa:socket.io-client:0.5.0'
compile 'com.koushikdutta.async:androidasync:2.+'
compile 'com.android.support:support-v4:21.0.+'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
}
......@@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS `instruction` (
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL CHECK (status IN ('started','finished')),
`begin` timestamp,
`begin` timestamp NULL,
`end` timestamp NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
......
......@@ -219,7 +219,7 @@ module.exports = {
if (err || !instructions){
sails.log.debug("Destroy Instructions: " + err);
return res.json(500, {error: "No instructions found"});
return res.json(500, {error: "Cannot delete instructions"});
}
......
......@@ -33,6 +33,7 @@
"beep": "Beep",
"birthdate": "Birthdate",
"cancel": "Cancel",
"cannot_delete_method": "Method could not be deleted, maybe due to existing recorded sessions.",
"categories": "Categories",
"change_password": "Change password",
"change_picture": "Change picture",
......
......@@ -33,6 +33,7 @@
"beep": "Pitido",
"birthdate": "Fecha de nacimiento",
"cancel": "Cancelar",
"cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.",
"categories": "Categorías",
"change_password": "Cambiar contraseña",
"change_picture": "Cambiar fotografía",
......
......@@ -186,3 +186,29 @@ dashboardApp.config(function (reCAPTCHAProvider) {
});
});
//
// New confirm service to avoid Firefox buggy confirm dialog window (which
// results in rootScope.inprog errors)
//
dashboardApp.factory("newconfirm", function ($window, $q, $timeout) {
// Define promise-based confirm() method.
function newconfirm(message) {
var defer = $q.defer();
$timeout(function () {
if ($window.confirm(message)) {
defer.resolve(true);
}
else {
defer.reject(false);
}
}, 0, false);
return defer.promise;
}
return newconfirm;
});
......@@ -8,6 +8,12 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'collections';
// ----------------------------------------------------------------------
// Controller actions
//
// Reload student pictos (back from addpicto)
$scope.reload_pictos = function(){
$http
......@@ -50,8 +56,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
//console.log(JSON.stringify($scope.pictosFromCategory));
// Clean the pcb
for (var i=0;i<rows;i++) {
for (var j=0;j<cols; j++) {
for (var i=0;i<$scope.pcb_rows;i++) {
for (var j=0;j<$scope.pcb_cols; j++) {
$scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
}
}
......
......@@ -3,12 +3,55 @@
//-----------------------
// Student Instructions Controller
//-----------------------
dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast) {
dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) {
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'instructions';
// ----------------------------------------------------------------------
// METHODS
// Load student methods and instructions
//
//
//
// Array with methods available in meta_methods
//
$scope.methods_available = [];
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.get(config.backend+'/metamethods/' + $scope.user.id)
.success(function(data, status, headers, config) {
// 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: "Nuevo método" });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Get last method/instruction for this student
......@@ -102,11 +145,12 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$scope.update_method = function(method){
// Remove instructions as we only update title or description
delete method.instructions;
console.log(JSON.stringify(method));
var method_to_save = {};
Object.assign(method_to_save, method);
delete method_to_save.instructions;
$http
.put(config.backend+'/method/' + method.id, method)
.put(config.backend+'/method/' + method.id, method_to_save)
.success(function(data, status, headers, config) {
console.log('Updated method:' + JSON.stringify(data));
})
......@@ -154,8 +198,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Delete method t and its instructions
$scope.delete_method = function(method){
var deleteMet = $window.confirm('Are you absolutely sure you want to delete?');
if(deleteMet){
$translate('confirmation').then(function(translation) {
newconfirm(translation).then(function() {
$http
.delete(config.backend+'/method/' + method.id)
.success(function(data, status, headers, config) {
......@@ -172,8 +216,16 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
var myToastMsg = $translate('cannot_delete_method').then(function (translation) {
// Show message
ngToast.warning({
content: translation,
timeout: 6000 // By default 4000
});
});
});
});
});
}
};
// Add instruction
......
......@@ -25,6 +25,24 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Read the last working session to show the last tries when session tab is opened
$scope.wsessions = [];
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// Query to obtain an array of only one working session (the last) with its tries/actions
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/lasttries')
......@@ -208,8 +226,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
id: data.id
};
// List of tries --> empty
// BORRAR después lo que no sirva
$scope.actual_try = {
......
......@@ -108,7 +108,6 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
// COLLECTION
// Load student collection
//
//
// List of all student pictos
$scope.studentPictos = [];
......@@ -124,13 +123,13 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
};
// Initialization of PCB (the tablet view) and PCB-Categories
var rows = 5, cols = 10;
$scope.pcb_rows = 5, $scope.pcb_cols = 10;
$scope.pcb = new Array(); $scope.pcb_cat = new Array();
// Set te empty elements
for (var i=0;i<rows;i++) {
// Set the empty elements
for (var i=0;i<$scope.pcb_rows;i++) {
$scope.pcb[i]=new Array(); $scope.pcb_cat[i]=new Array();
for (var j=0;j<cols; j++) {
for (var j=0;j<$scope.pcb_cols; j++) {
// Default value
$scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
$scope.pcb_cat[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
......@@ -142,9 +141,7 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
.success(function(data, status, headers, config) {
// Add to list
$scope.studentPictos = data;
//console.log(JSON.stringify($scope.studentPictos));
console.log("Student pictos listed");
// Filtered only the categories pictos
//console.log(JSON.stringify($scope.pcb_cat));
$scope.pictosCategory = $filter('filter')($scope.studentPictos, {attributes: { id_cat: null }});
console.log("Pictos Categories: " + JSON.stringify($scope.pictosCategory));
// Build the pcb_cat with the coords of the pictos
......@@ -153,58 +150,10 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
$scope.pcb_cat[pic.attributes.coord_x][pic.attributes.coord_y] = pic;
console.log("Pic " + pic.id + ": " + pic.attributes.color );
}
//console.log(JSON.stringify($scope.pcb_cat));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// ----------------------------------------------------------------------
// METHODS
// Load student methods and instructions
//
//
//
// Array with methods available in meta_methods
//
$scope.methods_available = [];
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.get(config.backend+'/metamethods/' + $scope.user.id)
.success(function(data, status, headers, config) {
// 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: "Nuevo método" });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}); // Filtered only the categories pictos
////////////////////////////////////////////////////////////////////////////
......
......@@ -71,6 +71,7 @@
<div ng-repeat="row in pcb" class="filaPictos">
<div class="picto pull-left" ng-repeat="col in row track by $index" id="{{col.attributes.coord_x}}_{{col.attributes.coord_y}}" draggable droppable drop="handleDrop">
<img src='/app/img/redcross.png' alt='' class='disabled' ng-if="col.attributes.status == 'disabled'"/>
<img ng-src="{{col.picto.uri}}" popover="{{col.expression.text}}" popover-trigger="mouseenter" ng-class="{'novisible': col.attributes.status == 'invisible', 'deactivate': col.attributes.status == 'disabled'}" />
<div class="picto_options" ng-if="col.picto.uri != '/app/img/empty.gif'">
<a ng-click="delete_picto(col)" class="picto_remove" title="{{ 'delete' | translate}}">
......
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