picto config dialog refactorized

parent fc8fb44f
...@@ -102,11 +102,12 @@ ...@@ -102,11 +102,12 @@
"error_on_request": "The request has not been processed. Please, check your fields", "error_on_request": "The request has not been processed. Please, check your fields",
"error_on_request_sup_not_found": "Account not found or it has not been activated", "error_on_request_sup_not_found": "Account not found or it has not been activated",
"error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.", "error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.",
"error_on_update": "Error on update",
"error_loading_pictos": "Error loading pictos information", "error_loading_pictos": "Error loading pictos information",
"error_general": "An error has been produced", "error_general": "An error has been produced",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
"expression": "Expression:", "expression": "Expression",
"February": "February", "February": "February",
"feedback_picto": "Selection feedback", "feedback_picto": "Selection feedback",
"filter": "Filter", "filter": "Filter",
...@@ -245,6 +246,7 @@ ...@@ -245,6 +246,7 @@
"profile_picture": "Profile picture", "profile_picture": "Profile picture",
"read_picto": "Read picto", "read_picto": "Read picto",
"register": "Sign in", "register": "Sign in",
"reloading_pictos": "Reloading pictograms",
"remember": "Remember me", "remember": "Remember me",
"reports": "Reports", "reports": "Reports",
"request_change_password": "Request change password", "request_change_password": "Request change password",
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
"enormous": "Enorme", "enormous": "Enorme",
"expand_navigation": "Desplegar navegación", "expand_navigation": "Desplegar navegación",
"expand_navigation": "Desplegar navegación", "expand_navigation": "Desplegar navegación",
"expression": "Expresión:", "expression": "Expresión",
"error_adding_picto": "Error al añadir el picto", "error_adding_picto": "Error al añadir el picto",
"error_creating_session": "Error al crear sesión", "error_creating_session": "Error al crear sesión",
"error_deleting_picto": "Error borrando el picto", "error_deleting_picto": "Error borrando el picto",
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
"error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)", "error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)",
"error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.", "error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.",
"error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada", "error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada",
"error_on_update": "Error al actualizar",
"error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.", "error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.",
"error_loading_pictos": "Error cargando información de los pictos", "error_loading_pictos": "Error cargando información de los pictos",
"error_general": "Se ha producido un error", "error_general": "Se ha producido un error",
...@@ -246,6 +247,7 @@ ...@@ -246,6 +247,7 @@
"read_picto": "Leer picto", "read_picto": "Leer picto",
"register": "Regístrate", "register": "Regístrate",
"register_button": "Registrar", "register_button": "Registrar",
"reloading_pictos": "Recargando pictogramas",
"remember": "No cerrar sesión", "remember": "No cerrar sesión",
"reports": "Informes", "reports": "Informes",
"request_change_password": "Solicitar cambio de contraseña", "request_change_password": "Solicitar cambio de contraseña",
......
...@@ -389,7 +389,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -389,7 +389,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
} }
}) })
.success(function (studentPicto) { .success(function (studentPicto) {
console.log(studentPicto.attributes); console.log(studentPicto);
placePicto(studentPicto); placePicto(studentPicto);
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
...@@ -454,7 +454,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -454,7 +454,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}); });
// Returned data from the modal window // Returned data from the modal window
modalInstance.result.then(function (exp) { modalInstance.result.then(function (exp) {
studentPicto.expression.text = exp; studentPicto.expression = exp;
}); });
}; };
......
...@@ -3,109 +3,87 @@ ...@@ -3,109 +3,87 @@
// Please note that $modalInstance represents a modal window (instance) dependency. // Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above. // It is not the same as the $modal service used above.
dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $modalInstance, $http, config, studentPicto, sup, stu) { dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $translate, $modalInstance, $http, config, ngToast, studentPicto, sup, stu) {
// Last parameter passed from collections.js
// Basic data passed from the main window
// Student
$scope.stu = stu;
// Supervisor
$scope.sup = sup;
// Picto // Picto
$scope.studentPicto = studentPicto; $scope.studentPicto = JSON.parse(JSON.stringify(studentPicto));
// Input expression
if ($scope.studentPicto.attributes.expression==undefined || $scope.studentPicto.attributes.expression==null) /*
$scope.studentPicto.attributes.expression=studentPicto.expression.text; * Save changes introduced in dialog window
// Enable or Disable the button 'change' if the supervisor is the owner of the picto */
$scope.isOwner = (studentPicto.picto.owner == sup.id) ? true : false; $scope.save = function () {
// Change expression (if the picto is owned by the supervisor) if ($scope.studentPicto.expression != studentPicto.expression) {
$scope.change = function () { // Update picto expressio because user owns it
if (studentPicto.picto.owner == sup.id) {
// Comprobación del supervisor propietario del picto $http
if(studentPicto.picto.owner == sup.id){ .post(config.backend+'/picto/exp',
$http { 'picto': studentPicto.picto.id,
.post(config.backend+'/picto/exp', 'lang': sup.lang,
{ 'picto': studentPicto.picto.id, 'text': $scope.studentPicto.expression
'lang': $scope.sup.lang, })
'text': $scope.studentPicto.expression.text .success(function(data, status, headers, config) {
}) io.socket.post('/stu/vocabulary', {
.success(function(data, status, headers, config) { action: 'update',
console.log("Expression changed: " + JSON.stringify(data)+": "+$scope.studentPicto.expression.text); attributes: {
$scope.studentPicto.attributes.expression=$scope.studentPicto.expression.text; id_stu: stu.id,
// Close the modal instance stu_picto: {
//$modalInstance.close($scope.studentPicto.expression.text); id: data.id,
expression: data.expression,
// Notifcar cambio attributes: $scope.studentPicto.attributes,
io.socket.post('/stu/vocabulary', { picto: { id: data.picto }
action: 'update', }
attributes: {
id_stu: $scope.stu.id,
stu_picto: {
id: data.id,
expression: data.expression,
attributes: $scope.studentPicto.attributes,
picto: { id: data.picto }
} }
} }, function (res) {});
}, function (res) {console.log("Owned vocabulary emited: " + JSON.stringify(res.msg));}); })
.error(function(data, status, headers, config) {
}) console.log("Error from API: " + data.error);
.error(function(data, status, headers, config) { });
console.log("Error from API: " + data.error); } else {
}); $scope.studentPicto.attributes.expression = $scope.studentPicto.expression;
}
} }
}; // Update attributes
$scope.update_properties = function(){
console.log("Atributos: " + JSON.stringify($scope.studentPicto.attributes));
$http $http
.put(config.backend+'/stu/'+ $scope.stu.id + '/picto/' + $scope.studentPicto.id, .put(config.backend+'/stu/'+ stu.id + '/picto/' + $scope.studentPicto.id,
{ {
'attributes': $scope.studentPicto.attributes 'attributes': $scope.studentPicto.attributes
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
console.log("Properties updated");
// Close the modal instance
//$modalInstance.close($scope.expression);
// /////////////////////////////////////////////////////////////
// Websocket: Emit vocabulary update action
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
action: 'update', action: 'update',
attributes: { attributes: {
id_stu: $scope.stu.id, id_stu: stu.id,
stu_picto: data stu_picto: data
} }
}, },
function(res) { function(res) {});
console.log("Vocabulary emited: " + JSON.stringify(res.msg));
});
///////////////////////////////////////////////////////////////
}) })
.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);
}); });
};
$scope.update_legend = function(){ // Update all lengends format
console.log("Legend: " + $scope.studentPicto.attributes.legend+" to be modified"); if ($scope.update_all_legend) {
$http
$http .put(config.backend+'/stu/'+ stu.id + '/legend/' + $scope.studentPicto.attributes.legend)
.put(config.backend+'/stu/'+ $scope.stu.id + '/legend/' + $scope.studentPicto.attributes.legend) .success(function(data, status, headers, config) {
.success(function(data, status, headers, config) { })
console.log("Legend updated"); .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
// Close the modal instance studentPicto.expression = $scope.studentPicto.expression;
$modalInstance.close($scope.expression); studentPicto.attributes = $scope.studentPicto.attributes;
$modalInstance.close($scope.studentPicto.expression);
if ($scope.update_all_legend) {
ngToast.success({ content: $translate.instant('reloading_pictos') });
$window.location.reload(); $window.location.reload();
}); }
}; };
$scope.close = function () { $scope.close = function () {
// Lo que se devuelve a collection // Lo que se devuelve a collection
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
('empty-' + colIndex + '-' + rowIndex) ('empty-' + colIndex + '-' + rowIndex)
}}" }}"
draggable droppable drop="handleDrop" draggable droppable drop="handleDrop"
popover="{{studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression}}" popover="{{studentPicto != emptyStudentPicto ? studentPicto.expression : ''}}"
popover-trigger="mouseenter" popover-trigger="mouseenter"
ng-init="colIndex = $index" ng-init="colIndex = $index"
ng-repeat="studentPicto in studentPictoRow track by $index"> ng-repeat="studentPicto in studentPictoRow track by $index">
...@@ -41,13 +41,12 @@ ...@@ -41,13 +41,12 @@
<div <div
class="picto-legend-normal" class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'"> ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<div <div
class="picto-legend-full" class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'"> ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<!-- /.picto-legend --> <!-- /.picto-legend -->
<img <img
...@@ -121,19 +120,19 @@ ...@@ -121,19 +120,19 @@
class="picto pull-left ng-class:{'picto-out': studentData.attributes.size == 'large' && (rowIndex > 3 || colIndex > 7)};" class="picto pull-left ng-class:{'picto-out': studentData.attributes.size == 'large' && (rowIndex > 3 || colIndex > 7)};"
ng-repeat="studentPicto in studentPictoRow track by $index" ng-repeat="studentPicto in studentPictoRow track by $index"
ng-init="colIndex = $index" ng-init="colIndex = $index"
popover="{{studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression}}" popover="{{ studentPicto != emptyStudentPicto ? studentPicto.expression : ''}}"
popover-trigger="mouseenter"> popover-trigger="mouseenter">
<!-- picto-legend --> <!-- picto-legend -->
<div <div
class="picto-legend-normal" class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'"> ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<div <div
class="picto-legend-full" class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'"> ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<!-- /.picto-legend --> <!-- /.picto-legend -->
<img <img
...@@ -240,7 +239,7 @@ ...@@ -240,7 +239,7 @@
('empty-' + colIndex + '-' + rowIndex) ('empty-' + colIndex + '-' + rowIndex)
}}" }}"
draggable droppable drop="handleDrop" draggable droppable drop="handleDrop"
popover="{{studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression}}" popover="{{ studentPicto != emptyStudentPicto ? studentPicto.expression : '' }}"
popover-trigger="mouseenter" popover-trigger="mouseenter"
ng-repeat="studentPicto in studentPictoRow track by $index" ng-repeat="studentPicto in studentPictoRow track by $index"
ng-init="colIndex = $index"> ng-init="colIndex = $index">
...@@ -248,13 +247,13 @@ ...@@ -248,13 +247,13 @@
<div <div
class="picto-legend-normal" class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'"> ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<div <div
class="picto-legend-full" class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'"> ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<!-- /.picto-legend --> <!-- /.picto-legend -->
<img <img
......
...@@ -6,73 +6,49 @@ ...@@ -6,73 +6,49 @@
<h4 class="modal-title" id="myModalLabel" translate>pictogram_setup</h4> <h4 class="modal-title" id="myModalLabel" translate>pictogram_setup</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<ul class="list-group"> <div class="form-group">
<label translate>expression</label>
<!-- Modificable sólo si es el propietario del picto -->
<div id="add_label" class="input-group">
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span>
<input type="text" class="form-control" ng-model="studentPicto.expression" />
</div>
</div>
<li class="list-group-item"> <div class="form-group">
<label translate>expression</label> <label translate>legend</label><br/>
<!-- Modificable sólo si es el propietario del picto --> <div class="row">
<form ng-submit="isOwner ? change() : update_properties()"> <div class="col-md-6">
<div id="add_label" class="input-group"> <!-- <div class="checkbox">
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span> <select class="form-control" data-toggle="toggle" ng-model="studentPicto.attributes.legend" ng-change="update_properties()">
<input type="text" class="form-control" ng-if="isOwner" ng-model="studentPicto.expression.text" /> <option value="none" selected>Sin leyenda</option>
<input type="text" class="form-control" ng-if="!isOwner" ng-model="studentPicto.attributes.expression" /> <option value="normal">Leyenda normal</option>
<span class="input-group-btn"> <option value="full">Solo leyenda</option>
<button class="btn btn-success" type="submit" ng-click="close()" translate>save</button> </select>
</span> </div> -->
</div> <input type="radio" ng-model="studentPicto.attributes.legend" value="none">
</form> <span translate>legend_none</span>
</li> <br/>
<input type="radio" ng-model="studentPicto.attributes.legend" value="normal">
<!-- <span translate>legend_normal</span>
<li class="list-group-item"> <br/>
<div class="checkbox"> <input type="radio" ng-model="studentPicto.attributes.legend" value="full">
<label><input data-toggle="toggle" type="checkbox" ng-model="studentPicto.attributes.magnify" ng-change="update_properties()"> Aumentado</label> <span translate>legend_full</span>
</div> </div>
</li> <div class="col-md-6">
--> <input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false">
<span translate>legend_apply_all</span>
<!-- <li class="list-group-item">
<div class="checkbox">
<label><input data-toggle="toggle" type="checkbox" ng-model="studentPicto.attributes.highlight" ng-change="update_properties()" translate> highlighted</label>
</div> </div>
</li> </div>
--> </div>
<li class="list-group-item"> <div class="row">
<div class="row"> <div class="col-md-12">
<div class="col-md-12"> <button class="btn btn-success pull-right" ng-click="save()" translate>save</button>
<label translate>legend</label><br/> <button class="btn btn-secondary margin-right10 pull-right" ng-click="close()" translate>cancel</button>
<!-- <div class="checkbox"> </div>
<select class="form-control" data-toggle="toggle" ng-model="studentPicto.attributes.legend" ng-change="update_properties()"> </div>
<option value="none" selected>Sin leyenda</option> </div>
<option value="normal">Leyenda normal</option>
<option value="full">Solo leyenda</option>
</select>
</div> -->
<input type="radio" ng-model="studentPicto.attributes.legend" value="none" ng-change="update_properties()">
<span translate>legend_none</span>
<br/>
<input type="radio" ng-model="studentPicto.attributes.legend" value="normal" ng-change="update_properties()">
<span translate>legend_normal</span>
<br/>
<input type="radio" ng-model="studentPicto.attributes.legend" value="full" ng-change="update_properties()">
<span translate>legend_full</span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-8">
<input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false">
<span translate>legend_apply_all</span>
</div>
<div class="col-md-4">
<div class="form-group text-center">
<button type="submit" class="btn btn-primary ng-scope" ng-click="update_all_legend ? update_legend() : close()" translate>apply</button>
</div>
</div>
</div>
</li>
</ul>
</div> </div>
<!-- End modal-body --> <!-- End modal-body -->
</div> </div>
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
padding: 8px; padding: 8px;
} }
.margin-right10{
margin-right: 10px;
}
/* Evitar scrolling horizontal */ /* Evitar scrolling horizontal */
body{ body{
overflow-x: hidden; overflow-x: hidden;
......
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