scenes completed, bug on creation with categories

parent 5a8d9b6d
......@@ -2,7 +2,6 @@
SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE stu_picto DROP FOREIGN KEY stu_picto_scene_fk;
ALTER TABLE stu_picto DROP COLUMN id_scene;
ALTER TABLE stu_picto DROP id_scene;
DROP TABLE scene;
SET FOREIGN_KEY_CHECKS = 1;
*/
......
......@@ -42,7 +42,7 @@ Changes to be performed manually in servers to upgrade
`source /vagrant/roles/database/files/scene_adapt.sql`
- 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)
......
......@@ -77,6 +77,7 @@
"country": "Country",
"country_requested": "Country requested",
"country_office_requested": "Country for office/center is mandatory",
"create": "Create",
"create_account": "Create account",
"create_an_account": "Create an account",
"creation": "Creation",
......@@ -107,6 +108,7 @@
"disclaimer_requested": "Conditions of use must be read and accepted",
"double_click": "Double click",
"down": "Down",
"duplicate": "Duplicate",
"duration_in_months": "Duration (in number of months)",
"drag": "Drag",
"edit": "Edit",
......@@ -222,6 +224,8 @@
"new_instruction": "New instruction",
"new_method": "New method",
"new_objective": "New objective",
"new_scene_with_categories": "Create scene with categories",
"new_scene_without_categories": "Create scene without categories",
"new_session": "New session",
"next_actions": "Next actions",
"next_sessions": "Next sessions",
......@@ -309,10 +313,15 @@
"room_changed": "A partner is offline. Session paused.",
"save": "Save",
"save_as_template": "Save as template",
"scene_active": "Active scene",
"scene_activate": "Activate scene",
"scene_added": "Scene data has been saved",
"scene_already_activated": "Scene already activated",
"scene_already_deleted": "Scene was already deleted",
"scene_create":"Create new scene",
"scene_deleted": "Scene has been deleted",
"scene_duplicated": "Scene has been copied",
"scene_inactive": "Inactive scene",
"scene_updated": "Scene data updated",
"search": "Search",
"search_sup_email": "Search supervisor by email",
......
......@@ -77,6 +77,7 @@
"country": "País",
"country_requested": "Debe especificar el país",
"country_office_requested": "Debe especificar el país del gabinete/centro",
"create": "Crear",
"create_account": "Crear cuenta",
"create_an_account": "Crear una cuenta",
"creation": "Creación",
......@@ -107,6 +108,7 @@
"disclaimer_requested": "Las condiciones de uso deben ser leídas y aceptadas",
"double_click": "Doble clic",
"down": "Abajo",
"duplicate": "Duplicar",
"duration_in_months": "Duración (en número de meses)",
"drag": "Arrastrar",
"edit": "Editar",
......@@ -222,6 +224,8 @@
"new_instruction": "Nueva instrucción",
"new_method": "Nuevo método",
"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",
"next_actions": "Acciones posteriores",
"next_sessions": "Sesiones posteriores",
......@@ -309,10 +313,15 @@
"room_changed":"Un participante abandonó la sesión. Sesión en pausa.",
"save": "Guardar",
"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_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_duplicated": "Escena duplicada",
"scene_inactive": "Escena inactiva",
"scene_updated": "Datos de la escena actualizados",
"search": "Buscar",
"search_sup_email": "Buscar supervisor por email",
......
......@@ -50,7 +50,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.viewingScene = null;
$scope.scenesList = null;
$scope.newSceneCat = null;
$scope.newSceneName = "no name";
$scope.newSceneName = "";
$scope.isCategory = function (studentPicto) {
......@@ -222,27 +222,28 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Delete student scene, if is not active
//If scene is viewingScene, load activeScene
$scope.delete_scene = function (idScene) {
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;
}
}
$scope.delete_scene = function (scene) {
$translate('confirmation').then(t => {
if ($window.confirm(t)) {
if(!active){
$http.delete(config.backend + '/scene/' + idScene + '/stu/' + $scope.studentData.id)
if(!scene.active){ // only delete if scene not active
$http.delete(config.backend + '/scene/' + scene.id + '/stu/' + $scope.studentData.id)
.success(function () {
//Socket notify
io.socket.post('/scene', {
action: 'delete',
data: {id:idScene}
data: {id:scene.id}
}, function () {});
if(viewing){
//Reload active scene
if(scene == $scope.viewingScene){
$scope.showActiveScene();
}
//Reload scenes list
$scope.loadScenesList();
$translate('scene_deleted').then(function (translation) {
ngToast.success({ content: translation });
});
......@@ -252,7 +253,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
ngToast.warning({ content: translation });
});
});
}else{
}else{ // if scene active, show warning
$translate('cant_delete_active_scene').then(function (translation) {
ngToast.warning({ content: translation });
});
......@@ -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
$scope.update_scene = function (scene) {
......@@ -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
io.socket.off('vocabulary');
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 @@
<div class="col-xs-2">
<div class="text-center">
<input type="text" class="editable scene-name text-center" ng-model="viewingScene.name">
<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="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>
<input type="text" class="editable scene-name text-center" ng-model="viewingScene.name" ng-blur="update_scene(viewingScene)">
<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="{{ '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>
<hr>
......@@ -337,17 +337,17 @@
<hr>
<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">
<i class="fa fa-plus" aria-hidden="true"></i>
</button>
<ul class="dropdown-menu">
<li><a href="#">Nueva escena con categorías</a></li>
<li><a href="#">Nueva escena sin categorías</a></li>
<li><a ng-click="newSceneCat=true;open_new_scene()">{{ 'new_scene_with_categories' | translate}}</a></li>
<li><a ng-click="newSceneCat=false;open_new_scene()">{{ 'new_scene_without_categories' | translate}}</a></li>
</ul>
</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-danger" ng-click="delete_scene(viewingScene.id)"><i class="fa fa-trash" 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)" title="{{ 'delete' | translate}}"><i class="fa fa-trash" aria-hidden="true"></i></button>
</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 = {
'GET /scene/:id': 'SceneController.getScene',
'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',
'DELETE /scene/:id/stu/:id_stu': 'SceneController.destroy',
......
......@@ -66,6 +66,7 @@ module.exports = function (grunt) {
'assets/scripts/modules/student/controllers/tags.js',
'assets/scripts/modules/student/controllers/pictoconfig.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/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