Commit bc63423e by Sebastián Collado

Merge branch 'issue588' of http://scm.ujaen.es/softuno/pictogram into issue588

parents b4cc7b86 59bc9458
/* global Instruction, Method */
/**
* MetaInstructionController manages the requests related to the MetaInstruction model.
* Read it's documentation for further information.
* @type {Object}
*/
module.exports = {
/**
* Create a new Instruction, which is associated to the given method
* @param {request} req
* {
* method: metaMethodId,
* name: 'New instruction' (optional)
* objective: 'This instruction has an objective... description' (optional)
* }
* @param {response} res
* {
* id (instructionId)
* method
* name
* objective
* }
*/
create: function (req, res) {
MetaMethod.findOne({ id: req.param('method') }).then(function (method) {
if (!method)
return res.badRequest();
MetaInstruction.create({
id_met: method.id,
name: req.param('name'),
objective: req.param('objective'),
})
.then(function (instruction) {
if (instruction)
return res.ok(instruction);
return res.badRequest();
})
.catch(function (err) {
return res.serverError(err);
});
})
.catch(function (err) {
return res.serverError(err);
});
},
/**
* Update an existing Instruction template, known by it's ID
* @param {request} req (with instruction id as url parameter)
* {
* method: methodId, (optional)
* name: 'New instruction' (optional)
* objective: 'This instruction has an objective... description' (optional)
* }
* @param {response} res
* {
* id
* method
* name
* objective
* }
*/
update: function (req, res) {
if (!req.params.id)
return res.badRequest();
MetaInstruction.findOne({ id: req.params.id })
.then(function (instruction) {
if (!instruction)
return res.badRequest();
instruction.method = req.param('method') || instruction.method;
instruction.name = req.param('name') || instruction.name;
instruction.objective = req.param('objective') || instruction.objective;
instruction.save(function (error) {
if (error)
return res.serverError();
return res.ok(instruction);
});
})
.catch(function () {
return res.serverError();
});
},
/**
* Delete an instruction template by its ID
* @param {request} req {} (with instructionId as url parameter)
* @param {response} res {}
*/
destroy: function (req, res) {
if (!req.params.id)
return res.badRequest();
MetaInstruction.destroy({ id: req.params.id }).exec(function (error) {
if (error)
return res.badRequest();
else
return res.ok();
});
}
};
/* global sails, Method, MetaMethod */
/**
* MethodController
*
* @description :: Server-side logic for managing methods
* @help :: See http://links.sailsjs.org/docs/controllers
*/
module.exports = {
/**
* Return all the metamethods of a given supervisor (including the public metamethods)
* not associated to a concrete supervisor.
* @param {request} req {} (with idSup specified as url parameter)
* @param {response} res
* [
* {
* id: metamethodId
* name: 'Metamethod Name'
* description: 'Metamethod description, which can be longer'
* },
* ...
* ]
*/
supVisible: function (req, res) {
var params = req.allParams();
MetaMethod.find({ or: [
{ supervisor: null },
{ supervisor: params.id_sup }
] }).then(function (metaMethods) {
res.ok(metaMethods);
})
.catch(function (err) {
res.serverError(err);
});
},
/**
* Return all the metamethods of a given supervisor he owns
* @param {request} req {} (with idSup specified as url parameter)
* @param {response} res
* [
* {
* id: metamethodId
* name: 'Metamethod Name'
* description: 'Metamethod description, which can be longer'
* },
* ...
* ]
*/
supOwned: function (req, res) {
var params = req.allParams();
if (!params.id_sup)
return res.badRequest();
MetaMethod.find({ supervisor: params.id_sup })
.populate('metainstructions')
.then(function (metaMethods) {
res.ok(metaMethods);
})
.catch(function (err) {
res.serverError(err);
});
},
/**
* Creates a new method from scratch (without using a template)
* @param {request} req
* {
* id_stu: studentId,
* name: 'Method name'
* }
* @param {response} res
* {
* id: methodId,
* name: 'Method name'
* }
*/
create: function(req, res){
var params = req.allParams();
if (!params.id_sup)
return res.badRequest("No supervisor defined");
MetaMethod.create({
"name": params.name,
"description": "",
"supervisor": params.id_sup
})
.then(function(createdMethod){
return res.ok(createdMethod);
})
.catch(function(err) {
sails.log.debug("Create Method template error: " + err);
return res.serverError(err);
});
},
//
// Updates a method template (just method, no instructions)
//
update: function (req, res) {
var params = req.allParams();
if (!params.id)
return res.badRequest("No template id specified");
MetaMethod.findOne(params.id)
.then(function (method) {
if (!method)
return res.serverError("No template found");
method.name = params.name;
method.description = params.description;
delete method.metainstructions;
method.save(function (err) {
if (err)
return res.serverError(err);
return res.ok(method);
});
})
.catch(function (err) {
sails.log.debug("Error updating method" + err.msg);
return res.serverError("Error updating method");
});
},
//
// Deletes a meta methdo
//
destroy: function(req, res){
var params = req.allParams();
if (!params.id) {
return res.badRequest("No meta method defined");
}
// Destroy instructions
MetaInstruction.destroy({ id_met: params.id })
.then(function(metainstructions) {
MetaMethod.destroy({ id: params.id })
.then(function(metamethod) {
if (!metamethod){
sails.log.debug("Destroy MetaMethod: " + err);
return res.serverError("No meta method found");
}
return res.ok(metamethod);
})
.catch(function (err) {
return res.serverError(err);
});
})
.catch(function(err) {
return res.serverError(err);
});
}
};
...@@ -9,93 +9,93 @@ ...@@ -9,93 +9,93 @@
module.exports = { module.exports = {
/** /**
* Creates a new method for a student using a template (metamethod) * Creates a new method for a student using a template (metamethod)
* @param {request} req * @param {request} req
* { * {
* id_mmethod: metaMethodId, * id_mmethod: metaMethodId,
* id_stu: studentId * id_stu: studentId
* } * }
* @param {response} res * @param {response} res
* { * {
* id: methodId, * id: methodId,
* name: 'MetaMethod Name', * name: 'MetaMethod Name',
* description: 'MetaMethod Description', * description: 'MetaMethod Description',
* instructions: [ * instructions: [
* { * {
* id: instructionId, * id: instructionId,
* name: 'Instruction Name', * name: 'Instruction Name',
* objective: 'Instruction Objective', * objective: 'Instruction Objective',
* method: methodId * method: methodId
* }, * },
* ... * ...
* ] * ]
* } * }
*/ */
create: function(req, res) { create: function(req, res) {
var params = req.allParams(); var params = req.allParams();
if (!params.id_mmethod) return res.badRequest("No meta method defined"); if (!params.id_mmethod) return res.badRequest("No meta method defined");
if (!params.id_stu) return res.badRequest("No student defined"); if (!params.id_stu) return res.badRequest("No student defined");
// Find meta method // Find meta method
MetaMethod.findOne({id: params.id_mmethod}) MetaMethod.findOne({id: params.id_mmethod})
.then(mmethod => { .then(mmethod => {
if (!mmethod) if (!mmethod)
throw new Error("Meta method not found"); throw new Error("Meta method not found");
// Create new method by meta method // Create new method by meta method
return Method.create( return Method.create(
{ {
name: mmethod.name, name: mmethod.name,
description: mmethod.description, description: mmethod.description,
student: params.id_stu student: params.id_stu
}) })
.then(created => created) .then(created => created)
.fail(err => {throw err}); .fail(err => {throw err});
}) })
.then(created => { .then(created => {
// Find meta instructions associated to meta method // Find meta instructions associated to meta method
MetaInstruction.find({id_met: params.id_mmethod}) MetaInstruction.find({id_met: params.id_mmethod})
.then(minstructions => { .then(minstructions => {
if (!minstructions) if (!minstructions)
minstructions = []; minstructions = [];
var l_ins = []; var l_ins = [];
// Every meta instruction is going to be created in 'Instruction' // Every meta instruction is going to be created in 'Instruction'
// with .eachSeries the order of resulting array will be equal // with .eachSeries the order of resulting array will be equal
// to the original array // to the original array
async.eachSeries(minstructions, function(mins, next) { async.eachSeries(minstructions, function(mins, next) {
Instruction.create({ Instruction.create({
method: created.id, method: created.id,
name: mins.name, name: mins.name,
objective: mins.objective objective: mins.objective
}) })
.then(added => { .then(added => {
l_ins.push(added); l_ins.push(added);
sails.log.debug("Instruction " + added.name + " added to method " + created.id); sails.log.debug("Instruction " + added.name + " added to method " + created.id);
}) })
.fail(err => {throw err}) .fail(err => {throw err})
.done(() => {next()}); .done(() => {next()});
}, },
function(err, results) { function(err, results) {
if (err) if (err)
throw new Error("Error while looping through instructions"); throw new Error("Error while looping through instructions");
return res.ok({ return res.ok({
"name": created.name, "name": created.name,
"description": created.description, "description": created.description,
"id": created.id, "id": created.id,
"student": created.id_stu, "student": created.id_stu,
"instructions": l_ins "instructions": l_ins
}); });
}); });
}) })
.fail( err => {throw err}); .fail( err => {throw err});
}) })
.fail(err => { .fail(err => {
return res.badRequest(err); return res.badRequest(err);
}); });
}, },
/** /**
* Creates a new method from scratch (without using a template) * Creates a new method from scratch (without using a template)
...@@ -131,167 +131,100 @@ module.exports = { ...@@ -131,167 +131,100 @@ module.exports = {
} }
}, },
/**
* Return all the metamethods of a given supervisor (including the public metamethods)
* not associated to a concrete supervisor.
* @param {request} req {} (with idSup specified as url parameter)
* @param {response} res
* [
* {
* id: metamethodId
* name: 'Metamethod Name'
* description: 'Metamethod description, which can be longer'
* },
* ...
* ]
*/
meta_methods: function (req, res) {
var params = req.allParams();
MetaMethod.find({ or: [
{ supervisor: null },
{ supervisor: params.id_sup }
] }).then(function (metaMethods) {
res.ok(metaMethods);
})
.catch(function () {
res.serverError();
});
},
// FERNANDO: avoid method name duplicates
save: function(req, res){
var params = req.allParams();
if (!params.id_met) return res.json(500, {error: "No method defined"});
if (!params.id_sup) return res.json(500, {error: "No supervisor defined"});
Method.findOne(params.id_met).populate('instructions').exec(function(err, method) {
if (err){
sails.log.debug("Find Method: " + err);
return res.json(500, {error: "No method found"}); // empty array
}
MetaMethod.create({ // FERNANDO: avoid method name duplicates
"name": method.name, //
"description": method.description, // Saves a method as a template
"supervisor": params.id_sup //
}).exec(function(err, createdMethod){ save: function(req, res){
if (err){
sails.log.debug("Create Method error: " + err);
return res.json(500, {error: "Error creating method",desc: err, code:err.code}); // empty array
}
if(createdMethod){ var params = req.allParams();
// Every instruction is going to be created in 'Meta Instruction'
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(method.instructions, function(mins, callback) {
sails.log.debug("Loop adding meta instruction: " + mins.name + " from method " + createdMethod.id);
MetaInstruction.create({
id_met: createdMethod.id,
name: mins.name,
objective: mins.objective
}).exec(function(err, added){
if(err) sails.log.debug("MetaInstruction.create: " + err);
if(added){
sails.log.debug("MetaInstruction " + added.name + " added from method " + createdMethod.id);
}
callback();
});
// Finish function when each callback is done
// Optionaly it can be passed and err parameter
}, function(err){
if( err ) {
// One of the iterations produced an error.
// All processing will now stop.
} else {
return res.json(createdMethod);
}
});
}
});
});
},
destroy: function(req, res) {
var params = req.allParams();
if (!params.id) {
return res.json(500, {error: "No method defined"});
}
// Destroy instructions
Instruction.destroy({ method: params.id }).exec(function(err, instructions) {
if (err || !instructions){
sails.log.debug("Destroy Instructions: " + err);
return res.json(500, {error: "Cannot delete instructions"});
}
// Destroy method
Method.destroy({ id: params.id }).exec(function(err, method) {
if (err || !method){
sails.log.debug("Destroy Method: " + err);
return res.json(500, {error: "No method found"});
}
return res.json(method);
});
});
},
destroyTemplate: function(req, res){ if (!params.id_met) return res.json(500, {error: "No method defined"});
if (!params.id_sup) return res.json(500, {error: "No supervisor defined"});
var params = req.allParams(); Method.findOne(params.id_met).populate('instructions').exec(function(err, method) {
if (err){
sails.log.debug("Find Method: " + err);
return res.json(500, {error: "No method found"}); // empty array
}
if (!params.id_mmet) { MetaMethod.create({
return res.json(500, {error: "No meta method defined"}); "name": method.name,
} "description": method.description,
"supervisor": params.id_sup
}).exec(function(err, createdMethod){
if (err){
sails.log.debug("Create Method error: " + err);
return res.json(500, {error: "Error creating method",desc: err, code:err.code}); // empty array
}
if(createdMethod){
// Every instruction is going to be created in 'Meta Instruction'
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(method.instructions, function(mins, callback) {
sails.log.debug("Loop adding meta instruction: " + mins.name + " from method " + createdMethod.id);
MetaInstruction.create({
id_met: createdMethod.id,
name: mins.name,
objective: mins.objective
}).exec(function(err, added){
if(err) sails.log.debug("MetaInstruction.create: " + err);
if(added){
sails.log.debug("MetaInstruction " + added.name + " added from method " + createdMethod.id);
}
callback();
});
// Finish function when each callback is done
// Optionaly it can be passed and err parameter
}, function(err){
if( err ) {
// One of the iterations produced an error.
// All processing will now stop.
} else {
return res.json(createdMethod);
}
});
}
});
// Destroy instructions
MetaInstruction.destroy({ id_met: params.id_mmet }).exec(function(err, metainstructions) {
if (err || !metainstructions){ });
sails.log.debug("Destroy MetaInstructions: " + err); },
return res.json(500, {error: "No meta instructions found"});
}
destroy: function(req, res) {
// Destroy method var params = req.allParams();
MetaMethod.destroy({ id: params.id_mmet }).exec(function(err, metamethod) {
if (!params.id)
return res.badRquest("No method defined");
// Destroy instructions
Instruction.destroy({ method: params.id }).exec(function(err, instructions) {
if (err || !instructions){
sails.log.debug("Destroy Instructions: " + err);
return res.serverError("Cannot delete instructions");
}
if (err || !metamethod){ // Destroy method
sails.log.debug("Destroy MetaMethod: " + err); Method.destroy({ id: params.id }).exec(function(err, method) {
return res.json(500, {error: "No meta method found"}); if (err || !method){
} sails.log.debug("Destroy Method: " + err);
return res.serverError("No method found");
}
return res.json(metamethod); return res.ok(method);
}); });
}); });
} }
}; };
...@@ -595,4 +595,5 @@ module.exports = { ...@@ -595,4 +595,5 @@ module.exports = {
res.badRequest(); res.badRequest();
} }
} }
}; };
...@@ -145,6 +145,9 @@ ...@@ -145,6 +145,9 @@
"month_totals": "Month totals", "month_totals": "Month totals",
"monthly":"Monthly", "monthly":"Monthly",
"name": "Name", "name": "Name",
"new_instruction": "New instruction",
"new_method": "New method",
"new_objective": "New objective",
"new_session": "New session", "new_session": "New session",
"next_actions": "Next actions", "next_actions": "Next actions",
"next_sessions": "Next sessions", "next_sessions": "Next sessions",
...@@ -171,6 +174,7 @@ ...@@ -171,6 +174,7 @@
"office_not_updated": "Office not updated", "office_not_updated": "Office not updated",
"office_updated": "Office updated", "office_updated": "Office updated",
"offices": "Offices", "offices": "Offices",
"own_instructions": "Own method templates",
"own_labels": "Your labels", "own_labels": "Your labels",
"own_pictos": "Your pictograms", "own_pictos": "Your pictograms",
"pages": "Pages", "pages": "Pages",
......
...@@ -145,6 +145,9 @@ ...@@ -145,6 +145,9 @@
"month_totals": "Totales mes", "month_totals": "Totales mes",
"monthly":"Mensual", "monthly":"Mensual",
"name": "Nombre", "name": "Nombre",
"new_instruction": "Nueva instrucción",
"new_method": "Nuevo método",
"new_objective": "Nuevo objetivo",
"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",
...@@ -171,6 +174,7 @@ ...@@ -171,6 +174,7 @@
"office_not_updated": "El gabinete no se ha podido actualizar", "office_not_updated": "El gabinete no se ha podido actualizar",
"office_updated": "Gabinete actualizado", "office_updated": "Gabinete actualizado",
"offices": "Gabinetes", "offices": "Gabinetes",
"own_instructions": "Plantillas de métodos propias",
"own_labels": "Propias", "own_labels": "Propias",
"own_pictos": "Propios", "own_pictos": "Propios",
"pages": "Páginas", "pages": "Páginas",
......
...@@ -94,6 +94,12 @@ dashboardApp.config(function ($stateProvider, $urlRouterProvider) { ...@@ -94,6 +94,12 @@ dashboardApp.config(function ($stateProvider, $urlRouterProvider) {
templateUrl: 'modules/supervisor/views/setup.html', templateUrl: 'modules/supervisor/views/setup.html',
controller: 'SetupCtrl', controller: 'SetupCtrl',
}) })
.state('instructions', {
url: '/instructions',
parent: 'supervisor',
templateUrl: 'modules/supervisor/views/instructions.html',
controller: 'InstructionsCtrl',
})
// Abstract page for student // Abstract page for student
.state('student', { .state('student', {
templateUrl: 'modules/student/views/student.html', templateUrl: 'modules/student/views/student.html',
......
...@@ -22,14 +22,14 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -22,14 +22,14 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Query to meta_methods to fill the select fill with precharged methods // Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods // and supervisor template methods
$http $http
.get(config.backend+'/metamethods/' + $scope.user.id) .get(config.backend+'/method/template/' + $scope.user.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
// Add to list // Add to list
$scope.methods_available = data; $scope.methods_available = data;
console.log("Meta Methods charged:"); console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available)); console.log(JSON.stringify($scope.methods_available));
// Option to add new methods // Option to add new methods
$scope.methods_available.push({ id: 0, name: "Nuevo método" }); $scope.methods_available.push({ id: 0, name: $translate.instant('new_method') });
}) })
.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);
...@@ -99,7 +99,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -99,7 +99,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
console.log('Created Method and Instructions'); console.log('Created Method and Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data)); console.log('Method (with Instructions):' + JSON.stringify(data));
$scope.methods.push(data); $scope.methods.unshift(data);
}) })
.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);
...@@ -217,7 +217,6 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -217,7 +217,6 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Add instruction // Add instruction
$scope.add_instruction = function(method){ $scope.add_instruction = function(method){
$http $http
.post(config.backend+'/instruction', { method: method.id } ) .post(config.backend+'/instruction', { method: method.id } )
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
......
'use strict';
//-----------------------
// Instructions Controller
//-----------------------
dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) {
// ----------------------------------------------------------------------
// 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+'/method/template/owned/' + $scope.user.id)
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// -----------------------------------------------------------------------
// Functions
//
// Add new method template (metamethod) selected to the student
$scope.add_method = function(){
var new_data = {
name: $translate.instant("new_method"),
id_sup: $scope.user.id
};
$http
.post(config.backend+'/method/template', new_data)
.success(function(data, status, headers, config) {
data.metainstructions = [];
$scope.methods.unshift(data);
})
.error(function(data, status, headers, config) { //error
ngToast.warning($translate.instant("method_name_duplicated", {method_name: new_data.name}));
});
};
// Delete method template
$scope.delete_method = function(method){
newconfirm($translate.instant('confirmation'))
.then(function() {
$http
.delete(config.backend+'/method/template/' + method.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
ngToast.success($translate.instant('template_deleted'));
for(var i=0; i<$scope.methods.length; i++) {
if($scope.methods[i].id == method.id){
$scope.methods.splice(i,1);
break;
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
});
};
// Update method template
$scope.update_method = function(method){
// Remove instructions as we only update title or description
var method_to_save = {};
Object.assign(method_to_save, method);
delete method_to_save.metainstructions;
$http
.put(config.backend+'/method/template/' + method.id, method_to_save)
.success(function(data, status, headers, config) {
console.log('Updated method:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + JSON.stringify(data));
});
};
// Add instruction template
$scope.add_instruction = function(method){
var new_instruction = {
method: method.id,
name: $translate.instant("new_instruction"),
objective: $translate.instant("new_objective")
};
$http
.post(config.backend+'/instruction/template/', new_instruction)
.success(function(data, status, headers, config) {
console.log('Added instruction:' + JSON.stringify(data));
// Add in view
method.metainstructions.push(data);
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
};
// Update instruction template
$scope.update_instruction = function(ins){
$http
.put(config.backend+'/instruction/template/' + ins.id, ins)
.success(function(data, status, headers, config) {
console.log('Updated instruction:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
};
// Delete instruction template
$scope.delete_instruction = function(ins){
$http
.delete(config.backend+'/instruction/template/' + ins.id)
.success(function(data, status, headers, config) {
console.log('Deleted instruction:' + JSON.stringify(data));
// Buscar method
for(var i=0; i<$scope.methods.length; i++) {
var m = $scope.methods[i];
if(ins.id_met == m.id){
// Buscar la instrucción y eliminar de la vista
for(var j=0; j<m.metainstructions.length; j++) {
if(ins.id == m.metainstructions[j].id){
$scope.methods[i].metainstructions.splice(j,1);
break;
}
}
break;
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
// Show message
ngToast.warning($translate.instant('cannot_delete_instruction'));
});
};
});
...@@ -27,6 +27,18 @@ ...@@ -27,6 +27,18 @@
</div> </div>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li> <li>
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/students">
<i class="glyphicon glyphicon-user" aria-hidden="true"></i>
{{ 'students' | translate }}
</a>
</li>
<li>
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/instructions">
<i class="glyphicon glyphicon-tasks" aria-hidden="true"></i>
{{ 'instructions' | translate }}
</a>
</li>
<li>
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/setup"> <a class="pointer" role="menuitem" tabindex="0" href="/app/#/setup">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i> <i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
{{ 'setup' | translate }} {{ 'setup' | translate }}
......
<!-- InstructionsCtrl controls here, see app.js -->
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" translate>own_instructions</h3></div>
<div class="panel-body">
<!-- Select to add new method -->
<div class="form-group">
<!-- Botón añadir método -->
<button ng-click="add_method()" class="btn btn-success btn-sm" popover="{{ 'add' | translate}}" popover-trigger="mouseenter">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <span translate>new_method</span>
</button>
</div>
<!-- END select to add new method -->
<!-- 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="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>
<th translate>instruction</th>
<th translate>objetive</th>
<th></th>
</tr>
<tr ng-repeat="i in m.metainstructions">
<td><input class="editable" type="text" ng-model="i.name" ng-blur="update_instruction(i)" /></td>
<td><input class="elipsis editable" type="text" ng-model="i.objective" ng-blur="update_instruction(i)" /></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>
</tr>
</table>
<!-- Añadir instrucción al método -->
<p class="text-right">
<a ng-click="add_instruction(m)" class="add_instruction btn btn-success btn-sm" role="button">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {{ 'add_instruction' | translate }}
</a>
</p>
</div>
<!-- Fin de .method_details -->
</div>
<!-- END .panel-body -->
</div>
<!-- END .panel -->
</div>
...@@ -37,14 +37,26 @@ module.exports.policies = { ...@@ -37,14 +37,26 @@ module.exports.policies = {
destroy: ['tokenAuth'] destroy: ['tokenAuth']
}, },
MetaInstructionController: {
update: ['tokenAuth'],
create: ['tokenAuth'],
destroy: ['tokenAuth']
},
MetaMethodController: {
supVisible: ['tokenAuth'],
supOwned: ['tokenAuth'],
create: ['tokenAuth'],
update: ['tokenAuth'],
destroy: ['tokenAuth']
},
MethodController: { MethodController: {
update: ['tokenAuth'], update: ['tokenAuth'],
create: ['tokenAuth'], create: ['tokenAuth'],
newMethod: ['tokenAuth'], newMethod: ['tokenAuth'],
save: ['tokenAuth'], save: ['tokenAuth'],
destroy: ['tokenAuth'], destroy: ['tokenAuth'],
destroyTemplate: ['tokenAuth'],
meta_methods: ['tokenAuth']
}, },
OfficeController: { OfficeController: {
......
...@@ -35,14 +35,21 @@ module.exports.routes = { ...@@ -35,14 +35,21 @@ module.exports.routes = {
'POST /instruction': 'InstructionController.create', 'POST /instruction': 'InstructionController.create',
'DELETE /instruction/:id': 'InstructionController.destroy', 'DELETE /instruction/:id': 'InstructionController.destroy',
'GET /metamethods/:id_sup': 'MethodController.meta_methods', 'PUT /instruction/template/:id': 'MetaInstructionController.update',
'POST /instruction/template': 'MetaInstructionController.create',
'DELETE /instruction/template/:id': 'MetaInstructionController.destroy',
'PUT /method/:id': 'MethodController.update', 'PUT /method/:id': 'MethodController.update',
'POST /method': 'MethodController.create', 'POST /method': 'MethodController.create',
'POST /method/new': 'MethodController.newMethod', 'POST /method/new': 'MethodController.newMethod',
'POST /method/save': 'MethodController.save', 'POST /method/save': 'MethodController.save',
'DELETE /method/:id': 'MethodController.destroy', 'DELETE /method/:id': 'MethodController.destroy',
'DELETE /method/template/:id_mmet': 'MethodController.destroyTemplate',
'GET /method/template/:id_sup': 'MetaMethodController.supVisible',
'GET /method/template/owned/:id_sup': 'MetaMethodController.supOwned',
'POST /method/template': 'MetaMethodController.create',
'PUT /method/template/:id': 'MetaMethodController.update',
'DELETE /method/template/:id': 'MetaMethodController.destroy',
'GET /office/get_all': 'OfficeController.getAll', 'GET /office/get_all': 'OfficeController.getAll',
'GET /office/get/:id': 'OfficeController.get', 'GET /office/get/:id': 'OfficeController.get',
......
...@@ -44,6 +44,7 @@ module.exports = function (grunt) { ...@@ -44,6 +44,7 @@ module.exports = function (grunt) {
'assets/scripts/modules/supervisor/controllers/supervisor.js', 'assets/scripts/modules/supervisor/controllers/supervisor.js',
'assets/scripts/modules/supervisor/controllers/students.js', 'assets/scripts/modules/supervisor/controllers/students.js',
'assets/scripts/modules/supervisor/controllers/setup.js', 'assets/scripts/modules/supervisor/controllers/setup.js',
'assets/scripts/modules/supervisor/controllers/instructions.js',
'assets/scripts/modules/student/controllers/setup.js', 'assets/scripts/modules/student/controllers/setup.js',
'assets/scripts/modules/student/controllers/student.js', 'assets/scripts/modules/student/controllers/student.js',
'assets/scripts/modules/student/controllers/session.js', 'assets/scripts/modules/student/controllers/session.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