scenes completed, bug on creation with categories

parent 5a8d9b6d
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
SET FOREIGN_KEY_CHECKS = 0; SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE stu_picto DROP FOREIGN KEY stu_picto_scene_fk; ALTER TABLE stu_picto DROP FOREIGN KEY stu_picto_scene_fk;
ALTER TABLE stu_picto DROP COLUMN id_scene; ALTER TABLE stu_picto DROP COLUMN id_scene;
ALTER TABLE stu_picto DROP id_scene;
DROP TABLE scene; DROP TABLE scene;
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
*/ */
......
...@@ -42,7 +42,7 @@ Changes to be performed manually in servers to upgrade ...@@ -42,7 +42,7 @@ Changes to be performed manually in servers to upgrade
`source /vagrant/roles/database/files/scene_adapt.sql` `source /vagrant/roles/database/files/scene_adapt.sql`
- Reload enrolments trigger - Reload enrolments trigger
`source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql;` `source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql`
(already done in dev & pre) (already done in dev & pre)
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
"country": "Country", "country": "Country",
"country_requested": "Country requested", "country_requested": "Country requested",
"country_office_requested": "Country for office/center is mandatory", "country_office_requested": "Country for office/center is mandatory",
"create": "Create",
"create_account": "Create account", "create_account": "Create account",
"create_an_account": "Create an account", "create_an_account": "Create an account",
"creation": "Creation", "creation": "Creation",
...@@ -107,6 +108,7 @@ ...@@ -107,6 +108,7 @@
"disclaimer_requested": "Conditions of use must be read and accepted", "disclaimer_requested": "Conditions of use must be read and accepted",
"double_click": "Double click", "double_click": "Double click",
"down": "Down", "down": "Down",
"duplicate": "Duplicate",
"duration_in_months": "Duration (in number of months)", "duration_in_months": "Duration (in number of months)",
"drag": "Drag", "drag": "Drag",
"edit": "Edit", "edit": "Edit",
...@@ -222,6 +224,8 @@ ...@@ -222,6 +224,8 @@
"new_instruction": "New instruction", "new_instruction": "New instruction",
"new_method": "New method", "new_method": "New method",
"new_objective": "New objective", "new_objective": "New objective",
"new_scene_with_categories": "Create scene with categories",
"new_scene_without_categories": "Create scene without categories",
"new_session": "New session", "new_session": "New session",
"next_actions": "Next actions", "next_actions": "Next actions",
"next_sessions": "Next sessions", "next_sessions": "Next sessions",
...@@ -309,10 +313,15 @@ ...@@ -309,10 +313,15 @@
"room_changed": "A partner is offline. Session paused.", "room_changed": "A partner is offline. Session paused.",
"save": "Save", "save": "Save",
"save_as_template": "Save as template", "save_as_template": "Save as template",
"scene_active": "Active scene",
"scene_activate": "Activate scene",
"scene_added": "Scene data has been saved", "scene_added": "Scene data has been saved",
"scene_already_activated": "Scene already activated",
"scene_already_deleted": "Scene was already deleted", "scene_already_deleted": "Scene was already deleted",
"scene_create":"Create new scene",
"scene_deleted": "Scene has been deleted", "scene_deleted": "Scene has been deleted",
"scene_duplicated": "Scene has been copied", "scene_duplicated": "Scene has been copied",
"scene_inactive": "Inactive scene",
"scene_updated": "Scene data updated", "scene_updated": "Scene data updated",
"search": "Search", "search": "Search",
"search_sup_email": "Search supervisor by email", "search_sup_email": "Search supervisor by email",
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
"country": "País", "country": "País",
"country_requested": "Debe especificar el país", "country_requested": "Debe especificar el país",
"country_office_requested": "Debe especificar el país del gabinete/centro", "country_office_requested": "Debe especificar el país del gabinete/centro",
"create": "Crear",
"create_account": "Crear cuenta", "create_account": "Crear cuenta",
"create_an_account": "Crear una cuenta", "create_an_account": "Crear una cuenta",
"creation": "Creación", "creation": "Creación",
...@@ -107,6 +108,7 @@ ...@@ -107,6 +108,7 @@
"disclaimer_requested": "Las condiciones de uso deben ser leídas y aceptadas", "disclaimer_requested": "Las condiciones de uso deben ser leídas y aceptadas",
"double_click": "Doble clic", "double_click": "Doble clic",
"down": "Abajo", "down": "Abajo",
"duplicate": "Duplicar",
"duration_in_months": "Duración (en número de meses)", "duration_in_months": "Duración (en número de meses)",
"drag": "Arrastrar", "drag": "Arrastrar",
"edit": "Editar", "edit": "Editar",
...@@ -222,6 +224,8 @@ ...@@ -222,6 +224,8 @@
"new_instruction": "Nueva instrucción", "new_instruction": "Nueva instrucción",
"new_method": "Nuevo método", "new_method": "Nuevo método",
"new_objective": "Nuevo objetivo", "new_objective": "Nuevo objetivo",
"new_scene_with_categories": "Crear escena con categorías",
"new_scene_without_categories": "Crear escena sin categorías",
"new_session": "Nueva sesión", "new_session": "Nueva sesión",
"next_actions": "Acciones posteriores", "next_actions": "Acciones posteriores",
"next_sessions": "Sesiones posteriores", "next_sessions": "Sesiones posteriores",
...@@ -309,10 +313,15 @@ ...@@ -309,10 +313,15 @@
"room_changed":"Un participante abandonó la sesión. Sesión en pausa.", "room_changed":"Un participante abandonó la sesión. Sesión en pausa.",
"save": "Guardar", "save": "Guardar",
"save_as_template": "Guardar como plantilla", "save_as_template": "Guardar como plantilla",
"scene_already_deleted": "La escena ya se había eliminado", "scene_active": "Escena activa",
"scene_activate": "Activar escena",
"scene_added": "Escena creada correctamente", "scene_added": "Escena creada correctamente",
"scene_already_activated": "Escena ya activada",
"scene_already_deleted": "La escena ya se había eliminado",
"scene_create":"Crear nueva escena",
"scene_deleted": "Escena eliminada", "scene_deleted": "Escena eliminada",
"scene_duplicated": "Escena duplicada", "scene_duplicated": "Escena duplicada",
"scene_inactive": "Escena inactiva",
"scene_updated": "Datos de la escena actualizados", "scene_updated": "Datos de la escena actualizados",
"search": "Buscar", "search": "Buscar",
"search_sup_email": "Buscar supervisor por email", "search_sup_email": "Buscar supervisor por email",
......
...@@ -50,7 +50,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -50,7 +50,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.viewingScene = null; $scope.viewingScene = null;
$scope.scenesList = null; $scope.scenesList = null;
$scope.newSceneCat = null; $scope.newSceneCat = null;
$scope.newSceneName = "no name"; $scope.newSceneName = "";
$scope.isCategory = function (studentPicto) { $scope.isCategory = function (studentPicto) {
...@@ -222,27 +222,28 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -222,27 +222,28 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Delete student scene, if is not active // Delete student scene, if is not active
//If scene is viewingScene, load activeScene //If scene is viewingScene, load activeScene
$scope.delete_scene = function (idScene) { $scope.delete_scene = function (scene) {
var active = false;
var viewing = idScene == $scope.viewingScene.id;
for(var i=0; i<$scope.scenesList; i++){
if($scope.scenesList[i].id == idScene){
active=$scope.scenesList[i].active;
}
}
$translate('confirmation').then(t => { $translate('confirmation').then(t => {
if ($window.confirm(t)) { if ($window.confirm(t)) {
if(!active){ if(!scene.active){ // only delete if scene not active
$http.delete(config.backend + '/scene/' + idScene + '/stu/' + $scope.studentData.id) $http.delete(config.backend + '/scene/' + scene.id + '/stu/' + $scope.studentData.id)
.success(function () { .success(function () {
//Socket notify
io.socket.post('/scene', { io.socket.post('/scene', {
action: 'delete', action: 'delete',
data: {id:idScene} data: {id:scene.id}
}, function () {}); }, function () {});
if(viewing){
//Reload active scene
if(scene == $scope.viewingScene){
$scope.showActiveScene(); $scope.showActiveScene();
} }
//Reload scenes list
$scope.loadScenesList(); $scope.loadScenesList();
$translate('scene_deleted').then(function (translation) { $translate('scene_deleted').then(function (translation) {
ngToast.success({ content: translation }); ngToast.success({ content: translation });
}); });
...@@ -252,7 +253,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -252,7 +253,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
ngToast.warning({ content: translation }); ngToast.warning({ content: translation });
}); });
}); });
}else{ }else{ // if scene active, show warning
$translate('cant_delete_active_scene').then(function (translation) { $translate('cant_delete_active_scene').then(function (translation) {
ngToast.warning({ content: translation }); ngToast.warning({ content: translation });
}); });
...@@ -261,33 +262,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -261,33 +262,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}); });
}; };
// Create a new student scene
$scope.new_scene = function () {
$http.post(config.backend + '/scene/' + scene.id + '/stu/' + $scope.studentData.id, {
name: $scope.newSceneName,
id_sup: $scope.user.id,
categories:$scope.newSceneCat})
.success(function (scene) {
var data= {name: scene.name,
active: scene.active,
categories: scene.categories,
student: scene.student,
supervisor: scene.supervisor};
io.socket.post('/scene', {
action: 'add',
scene: data
}, function () {});
$translate('scene_added').then(function (translation) {
ngToast.success({ content: translation });
});
}).error(function () {});
};
// Update student scene // Update student scene
$scope.update_scene = function (scene) { $scope.update_scene = function (scene) {
...@@ -615,6 +589,31 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -615,6 +589,31 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}; };
// Modal window to create scenes
$scope.open_new_scene = function () {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'modules/student/views/newscene.html',
controller: 'NewSceneCtrl',
size: 'md',
resolve: { // Passing data to NewSceneCtrl
sup: function () {
return $scope.user;
},
stu_id: function () {
return $scope.studentData.id;
},
newSceneName: function(){
return $scope.newSceneName;
},
newSceneCat: function(){
return $scope.newSceneCat;
}
}
});
};
// Add new listener to the event // Add new listener to the event
io.socket.off('vocabulary'); io.socket.off('vocabulary');
io.socket.on('vocabulary', function (data) { io.socket.on('vocabulary', function (data) {
......
/* global dashboardControllers */
'use strict';
/**
* NewSceneCtrl
*/
dashboardControllers.controller('NewSceneCtrl', function (
$scope,
$modalInstance,
$http,
config,
$translate,
ngToast,
sup,
stu_id,
newSceneName,
newSceneCat
) {
$scope.sup = sup;
$scope.stu_id = stu_id;
$scope.newSceneName = newSceneName;
$scope.newSceneCat = newSceneCat;
// Create a new student scene
$scope.new_scene = function () {
$http.post(config.backend + '/scene/stu/' + $scope.stu_id, {
name: $scope.newSceneName,
id_sup: $scope.sup.id,
categories: $scope.newSceneCat,
id_stu: $scope.stu_id
})
.success(function (scene) {
var data = {
name: scene.name,
active: scene.active,
categories: scene.categories,
student: scene.student,
supervisor: scene.supervisor
};
io.socket.post('/scene', {
action: 'add',
scene: data
}, function () {});
$translate('scene_added').then(function (translation) {
ngToast.success({ content: translation });
});
location.reload();
}).error(function () {});
};
$scope.close = function () {
$modalInstance.close('Ejemplo de elemento devuelto');
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
});
...@@ -321,9 +321,9 @@ ...@@ -321,9 +321,9 @@
<div class="col-xs-2"> <div class="col-xs-2">
<div class="text-center"> <div class="text-center">
<input type="text" class="editable scene-name text-center" ng-model="viewingScene.name"> <input type="text" class="editable scene-name text-center" ng-model="viewingScene.name" ng-blur="update_scene(viewingScene)">
<a style="text-decoration:none" popover="Escena ya activada" popover-trigger="mouseenter" ng-if="viewingScene.active"><span class="label label-success"><i class="fa fa-star" aria-hidden="true"></i> Escena activa</span></a> <a style="text-decoration:none" popover="{{ 'scene_already_activated' | translate}}" popover-trigger="mouseenter" ng-if="viewingScene.active"><span class="label label-success"><i class="fa fa-star" aria-hidden="true"></i> {{ 'scene_active' | translate }}</span></a>
<a style="text-decoration:none" popover="Activar escena" popover-trigger="mouseenter" ng-if="!viewingScene.active" ng-click="viewingScene.active=true;update_scene(viewingScene)"><span class="label label-default"><i class="fa fa-star-o" aria-hidden="true"></i> Escena inactiva</span></a> <a style="text-decoration:none" popover="{{ 'scene_activate' | translate}}" popover-trigger="mouseenter" ng-if="!viewingScene.active" ng-click="viewingScene.active=true;update_scene(viewingScene)"><span class="label label-default"><i class="fa fa-star-o" aria-hidden="true"></i> {{ 'scene_inactive' | translate }}</span></a>
</div> </div>
<hr> <hr>
...@@ -337,17 +337,17 @@ ...@@ -337,17 +337,17 @@
<hr> <hr>
<div class="text-center"> <div class="text-center">
<div class="btn-group text-left"> <div class="btn-group text-left" title="{{ 'add' | translate}}">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-plus" aria-hidden="true"></i> <i class="fa fa-plus" aria-hidden="true"></i>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Nueva escena con categorías</a></li> <li><a ng-click="newSceneCat=true;open_new_scene()">{{ 'new_scene_with_categories' | translate}}</a></li>
<li><a href="#">Nueva escena sin categorías</a></li> <li><a ng-click="newSceneCat=false;open_new_scene()">{{ 'new_scene_without_categories' | translate}}</a></li>
</ul> </ul>
</div> </div>
<button type="button" class="btn btn-primary"ng-click="copy_scene()"><i class="fa fa-files-o" aria-hidden="true"></i></button> <button type="button" class="btn btn-primary"ng-click="copy_scene()" title="{{ 'duplicate' | translate}}"><i class="fa fa-files-o" aria-hidden="true"></i></button>
<button type="button" class="btn btn-danger" ng-click="delete_scene(viewingScene.id)"><i class="fa fa-trash" aria-hidden="true"></i></button> <button type="button" class="btn btn-danger" ng-click="delete_scene(viewingScene)" title="{{ 'delete' | translate}}"><i class="fa fa-trash" aria-hidden="true"></i></button>
</div> </div>
</div> </div>
......
<div id="new-scene">
<div class="modal-header">
<button type="button" class="close" ng-click="close()">
<span aria-hidden="true">&times;</span><span class="sr-only" translate>close</span>
</button>
<h4 class="modal-title" id="myModalLabel" translate>scene_create</h4>
</div>
<div class="modal-body">
<form ng-submit="new_scene()">
<div id="add_label" class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span></span>
<input type="text" class="form-control" ng-model="newSceneName" autofocus/>
<span class="input-group-btn">
<button class="btn btn-success" type="submit" translate>create</button>
</span>
</div>
</form>
</div>
<!-- End modal-body -->
</div>
...@@ -78,7 +78,7 @@ module.exports.routes = { ...@@ -78,7 +78,7 @@ module.exports.routes = {
'GET /scene/:id': 'SceneController.getScene', 'GET /scene/:id': 'SceneController.getScene',
'GET /scene/:id/stu/:id_stu/copy': 'SceneController.duplicate', 'GET /scene/:id/stu/:id_stu/copy': 'SceneController.duplicate',
'POST /scene/:id/stu/:id_stu': 'SceneController.create', 'POST /scene/stu/:id_stu': 'SceneController.create',
'PUT /scene/:id/stu/:id_stu': 'SceneController.update', 'PUT /scene/:id/stu/:id_stu': 'SceneController.update',
'DELETE /scene/:id/stu/:id_stu': 'SceneController.destroy', 'DELETE /scene/:id/stu/:id_stu': 'SceneController.destroy',
......
...@@ -66,6 +66,7 @@ module.exports = function (grunt) { ...@@ -66,6 +66,7 @@ module.exports = function (grunt) {
'assets/scripts/modules/student/controllers/tags.js', 'assets/scripts/modules/student/controllers/tags.js',
'assets/scripts/modules/student/controllers/pictoconfig.js', 'assets/scripts/modules/student/controllers/pictoconfig.js',
'assets/scripts/modules/student/controllers/pictoexp.js', 'assets/scripts/modules/student/controllers/pictoexp.js',
'assets/scripts/modules/student/controllers/newscene.js',
'assets/scripts/modules/student/controllers/instructiondetail.js', 'assets/scripts/modules/student/controllers/instructiondetail.js',
'assets/scripts/modules/translate/controllers/translate.js', 'assets/scripts/modules/translate/controllers/translate.js',
......
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