new controllers added

parent bfc040f7
/* 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({
method: 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 = {
/**
* Creates a new method for a student using a template (metamethod)
* @param {request} req
* {
* id_mmethod: metaMethodId,
* id_stu: studentId
* }
* @param {response} res
* {
* id: methodId,
* name: 'MetaMethod Name',
* description: 'MetaMethod Description',
* instructions: [
* {
* id: instructionId,
* name: 'Instruction Name',
* objective: 'Instruction Objective',
* method: methodId
* },
* ...
* ]
* }
*/
create: function(req, res) {
var params = req.allParams();
if (!params.id_mmethod) return res.badRequest("No meta method defined");
if (!params.id_stu) return res.badRequest("No student defined");
// Find meta method
MetaMethod.findOne({id: params.id_mmethod})
.then(mmethod => {
if (!mmethod)
throw new Error("Meta method not found");
// Create new method by meta method
return Method.create(
{
name: mmethod.name,
description: mmethod.description,
student: params.id_stu
})
.then(created => created)
.fail(err => {throw err});
})
.then(created => {
// Find meta instructions associated to meta method
MetaInstruction.find({id_met: params.id_mmethod})
.then(minstructions => {
if (!minstructions)
minstructions = [];
var l_ins = [];
// Every meta instruction is going to be created in 'Instruction'
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(minstructions, function(mins, next) {
Instruction.create({
method: created.id,
name: mins.name,
objective: mins.objective
})
.then(added => {
l_ins.push(added);
sails.log.debug("Instruction " + added.name + " added to method " + created.id);
})
.fail(err => {throw err})
.done(() => {next()});
},
function(err, results) {
if (err)
throw new Error("Error while looping through instructions");
return res.ok({
"name": created.name,
"description": created.description,
"id": created.id,
"student": created.id_stu,
"instructions": l_ins
});
});
})
.fail( err => {throw err});
})
.fail(err => {
return res.badRequest(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,
* student: studentId,
* name: 'Method name'
* }
*/
newMethod: function (req, res) {
if (req.param('name') && req.param('id_stu')) {
Method.create({
name: req.param('name'),
student: req.param('id_stu')
}).then(function (method) {
if (!method) {
res.badRequest();
throw new Error('method not created');
}
res.ok(method);
})
.catch(function () {
res.serverError();
});
} else {
res.badRequest();
}
},
/**
* 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);
});
},
//
// Saves a new meta method (template)
//
save: 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("Error creating method template");
});
},
//
// Deletes a meta methdo
//
destroy: function(req, res){
var params = req.allParams();
if (!params.id_mmet) {
return res.badRequest("No meta method defined");
}
// Destroy instructions
MetaInstruction.destroy({ id_met: params.id_mmet }).exec(function(err, metainstructions) {
if (err)
return res.serverError(err);
// Destroy method
MetaMethod.destroy({ id: params.id_mmet }).exec(function(err, metamethod) {
if (err || !metamethod){
sails.log.debug("Destroy MetaMethod: " + err);
return res.serverError("No meta method found");
}
return res.ok(metamethod);
});
});
}
};
......@@ -131,35 +131,11 @@ 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
// FERNANDO: avoid method name duplicates
//
// Saves a method as a template
//
save: function(req, res){
var params = req.allParams();
......@@ -173,8 +149,6 @@ module.exports = {
return res.json(500, {error: "No method found"}); // empty array
}
MetaMethod.create({
"name": method.name,
"description": method.description,
......@@ -230,68 +204,27 @@ module.exports = {
var params = req.allParams();
if (!params.id) {
return res.json(500, {error: "No method defined"});
}
if (!params.id)
return res.badRquest("No method defined");
// Destroy instructions
Instruction.destroy({ method: params.id }).exec(function(err, instructions) {
// Destroy instructions
Instruction.destroy({ method: params.id }).exec(function(err, instructions) {
if (err || !instructions){
if (err || !instructions){
sails.log.debug("Destroy Instructions: " + err);
return res.json(500, {error: "Cannot delete instructions"});
}
return res.serverError("Cannot delete instructions");
}
// Destroy method
// Destroy method
Method.destroy({ id: params.id }).exec(function(err, method) {
if (err || !method){
sails.log.debug("Destroy Method: " + err);
return res.serverError("No method found");
}
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){
var params = req.allParams();
if (!params.id_mmet) {
return res.json(500, {error: "No meta method defined"});
}
// 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 method
MetaMethod.destroy({ id: params.id_mmet }).exec(function(err, metamethod) {
if (err || !metamethod){
sails.log.debug("Destroy MetaMethod: " + err);
return res.json(500, {error: "No meta method found"});
}
return res.json(metamethod);
});
});
return res.ok(method);
});
});
}
};
......@@ -595,4 +595,5 @@ module.exports = {
res.badRequest();
}
}
};
......@@ -142,6 +142,7 @@
"minutes": "minutes",
"month_totals": "Month totals",
"name": "Name",
"new_method": "New method",
"new_session": "New session",
"next_actions": "Next actions",
"next_sessions": "Next sessions",
......@@ -168,6 +169,7 @@
"office_not_updated": "Office not updated",
"office_updated": "Office updated",
"offices": "Offices",
"own_instructions": "Own method and instructions",
"own_labels": "Your labels",
"own_pictos": "Your pictograms",
"pages": "Pages",
......
......@@ -142,6 +142,7 @@
"minutes": "minutos",
"month_totals": "Totales mes",
"name": "Nombre",
"new_method": "Nuevo método",
"new_session": "Nueva sesión",
"next_actions": "Acciones posteriores",
"next_sessions": "Sesiones posteriores",
......@@ -168,6 +169,7 @@
"office_not_updated": "El gabinete no se ha podido actualizar",
"office_updated": "Gabinete actualizado",
"offices": "Gabinetes",
"own_instructions": "Métodos e instrucciones propias",
"own_labels": "Propias",
"own_pictos": "Propios",
"pages": "Páginas",
......
......@@ -94,6 +94,12 @@ dashboardApp.config(function ($stateProvider, $urlRouterProvider) {
templateUrl: 'modules/supervisor/views/setup.html',
controller: 'SetupCtrl',
})
.state('instructions', {
url: '/instructions',
parent: 'supervisor',
templateUrl: 'modules/supervisor/views/instructions.html',
controller: 'InstructionsCtrl',
})
// Abstract page for student
.state('student', {
templateUrl: 'modules/student/views/student.html',
......
......@@ -29,7 +29,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
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" });
$scope.methods_available.push({ id: 0, name: $translate.instant('new_method') });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......@@ -99,7 +99,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.success(function(data, status, headers, config) {
console.log('Created Method and Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data));
$scope.methods.push(data);
$scope.methods.unshift(data);
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......
'use strict';
//-----------------------
// Student Instructions Controller
// Instructions Controller
//-----------------------
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';
dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) {
// ----------------------------------------------------------------------
// METHODS
......@@ -22,124 +19,70 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.get(config.backend+'/metamethods/' + $scope.user.id)
.get(config.backend+'/method/templates/owned/' + $scope.user.id)
.success(function(data, status, headers, config) {
// Add to list
$scope.methods_available = data;
$scope.methods = 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" });
$scope.methods_available.push({ id: 0, name: $translate.instant('new_method') });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// -----------------------------------------------------------------------
// Functions
//
// 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);
});
// Add new method template (metamethod) selected to the student
$scope.add_method = function(){
//
// Get last method/instruction for this student
//
/* $http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/last_instruction')
.success(function(data, status, headers, config) {
$scope.studentData.current_method = data.met_name;
$scope.studentData.current_instruction = data.ins_name;
console.log('Last method/instruction:' + JSON.stringify(data));
})
.error(function(data, status, headers, config) {
console.log('Last method/instruction error:' + JSON.stringify(data));
$scope.studentData.current_method = 'undefined';
$scope.studentData.current_instruction = 'undefined';
});*/
var data = {
name: $translate.instant("new_method");
};
// Add method selected to the student
$scope.add_method = function(){
// Create a new method
if($scope.method_selected.id == 0){
$scope.method.unshift(data);
$http
.post(config.backend+'/method/new', {
'id_stu': $scope.studentData.id,
'name': "Nuevo método (cambiar nombre)"
})
.success(function(data, status, headers, config) {
// Add empty array of instructions
data.instructions = [];
console.log('Created new empty Method:' + JSON.stringify(data));
$scope.methods.unshift(data);
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
$http
.post(config.backend+'/method/template/save', {'id_sup': $scope.user.id })
.then( //success
function(data, status, headers, config) {
ngToast.success($translate.instant('method_saved', {method_name: method.name}));
}
,function(data, status, headers, config) { //error
ngToast.success($translate.instant('method_name_duplicated', {method_name: method.name})),
}
);
};
} else {
// Add method from templates
// Delete method template
$scope.delete_method = function(method){
newconfirm($translate.instant('confirmation')).then(function() {
$http
.post(config.backend+'/method', {
'id_mmethod': $scope.method_selected.id,
'id_stu': $scope.studentData.id
})
.delete(config.backend+'/method/template/' + $scope.method.id)
.success(function(data, status, headers, config) {
console.log('Created Method and Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data));
$scope.methods.push(data);
console.log('Delete Method Template and its Instructions');
ngToast.success({content: $translate.instant('template_deleted')});
// Delete in select
for(var i=0; i<$scope.methods.length; i++) {
if($scope.methods[i].id == $scope.method_selected.id){
$scope.methods.splice(i,1);
$scope.method_selected = null;
break;
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
console.log($scope.method_selected.id + " " + $scope.studentData.id);
});
}
};
// Delete template
$scope.delete_template = function(){
$translate('confirmation').then(function(translation) {
newconfirm(translation).then(function() {
if($scope.method_selected.supervisor == $scope.user.id){
$http
.delete(config.backend+'/method/template/' + $scope.method_selected.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
ngToast.success({content: $translate.instant('template_deleted')});
// Delete in select
for(var i=0; i<$scope.methods_available.length; i++) {
if($scope.methods_available[i].id == $scope.method_selected.id){
$scope.methods_available.splice(i,1);
$scope.method_selected = null;
break;
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
});
});
}
};
// Update method
// Update method template
$scope.update_method = function(method){
// Remove instructions as we only update title or description
......@@ -148,7 +91,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
delete method_to_save.instructions;
$http
.put(config.backend+'/method/' + method.id, method_to_save)
.put(config.backend+'/method/template/' + method.id, method_to_save)
.success(function(data, status, headers, config) {
console.log('Updated method:' + JSON.stringify(data));
})
......@@ -157,69 +100,11 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
});
};
// Save method and its instructions as template in metamethods and metainstructions
$scope.save_as_template = function(method){
$http
.post(config.backend+'/method/save', { 'id_met': method.id, 'id_sup': $scope.user.id })
.then( //success
function(data, status, headers, config) {
console.log('Saved method as template:' + JSON.stringify(data));
// Add to select method
$scope.methods_available.push({ id: method.id, name: method.name });
ngToast.success({
content: $translate.instant('method_saved', {method_name: method.name}),
timeout: 6000 // By default 4000
});
}
,function(data, status, headers, config) { //error
console.log("Error from API: " + data.error+"("+data.status+")");
ngToast.success({
content: $translate.instant('method_name_duplicated', {method_name: method.name}),
timeout: 6000 // By default 4000
});
}
);
};
// Delete method t and its instructions
$scope.delete_method = function(method){
$translate('confirmation').then(function(translation) {
newconfirm(translation).then(function() {
$http
.delete(config.backend+'/method/' + method.id)
.success(function(data, status, headers, config) {
console.log('Delete Method and its Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data));
// Delete in view
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);
ngToast.warning({
content: $translate.instant('cannot_delete_method'),
timeout: 6000 // By default 4000
});
});
});
});
};
// Add instruction
// Add instruction template
$scope.add_instruction = function(method){
$http
.post(config.backend+'/instruction', { method: method.id } )
.post(config.backend+'/instruction/template/', { method: method.id } )
.success(function(data, status, headers, config) {
console.log('Added instruction:' + JSON.stringify(data));
// Add in view
......@@ -230,11 +115,11 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
});
};
// Update instruction of a method
// Update instruction template
$scope.update_instruction = function(ins){
$http
.put(config.backend+'/instruction/' + ins.id, ins)
.put(config.backend+'/instruction/template/' + ins.id, ins)
.success(function(data, status, headers, config) {
console.log('Updated instruction:' + JSON.stringify(data));
})
......@@ -243,21 +128,10 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
});
};
// Change the status of an instruction (and update)
$scope.change_status = function(ins){
if(ins.status == null) ins.status = "started";
else if(ins.status == "started") ins.status = "finished";
else if(ins.status == "finished") ins.status = null;
// update the instruction with the new value
$scope.update_instruction(ins);
};
// Delete instruction of a method
// Delete instruction template
$scope.delete_instruction = function(ins){
$http
.delete(config.backend+'/instruction/' + ins.id)
.delete(config.backend+'/instruction/template/' + ins.id)
.success(function(data, status, headers, config) {
console.log('Deleted instruction:' + JSON.stringify(data));
// Buscar method
......@@ -279,36 +153,8 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
// Show message
ngToast.warning({
content: $translate.instant('cannot_delete_instruction'),
timeout: 6000 // By default 4000
});
ngToast.warning($translate.instant('cannot_delete_instruction'));
});
};
// Modal window to open instruction details
$scope.open_instruction = function (ins) {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'modules/student/views/instructiondetail.html',
controller: 'InstructionDetailCtrl',
size: 'md',
resolve: { // Passing data to the controller of the window
instruction: function(){
return ins;
}
}
});
// Returned data from the modal window
modalInstance.result.then(
function (ins) {
// Output from the window by clicking cancel or outside its borders
console.log("Modal dismissed: " + JSON.stringify(ins));
}
);
};
// End Modal window to view instruction details
});
......@@ -27,6 +27,18 @@
</div>
<ul class="dropdown-menu" role="menu">
<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">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
{{ 'setup' | translate }}
......
<!-- InstructionsCtrl controls here, see app.js -->
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" translate>students</h3></div>
<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">
<select class="form-control" name="method_select" id="method_select" ng-model="method_selected" ng-options="ma.name for ma in methods_available">
<option value="" translate>select_method</option>
</select>
<!-- Botón añadir método -->
<button ng-click="add_method()" class="btn btn-success btn-sm" popover="{{ 'add' | translate}}" popover-trigger="mouseenter" ng-disabled="method_selected.id == undefined">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
<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>
<!-- Botón eliminar plantilla -->
<button ng-click="delete_template()" class="btn btn-danger btn-sm" popover="{{ 'delete_template' | translate}}" popover-trigger="mouseenter" ng-show="method_selected.supervisor == user.id">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</button>
</div>
<!-- END select to add new method -->
......@@ -28,8 +21,6 @@
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/>
<div class="options">
<a ng-click="save_as_template(m)" popover="{{ 'save_as_template' | translate}}" popover-trigger="mouseenter"><span class="text_medium color_black glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></a>
<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>
......@@ -42,40 +33,11 @@
<th></th>
<th translate>instruction</th>
<th translate>objetive</th>
<th class="text-center" translate>instruction_begin</th>
<th class="text-center" translate>instruction_end</th>
<th class="text-center" translate>state</th>
<th></th>
</tr>
<tr ng-repeat="i in m.instructions">
<td>
<a ng-click="open_instruction(i)"><span class="glyphicon glyphicon-file text_medium" aria-hidden="true"></span></a>
</td>
<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 class="editable">
<div class="text-center">
<span class="color_blue">{{ i.begin | date:"dd-MM-yyyy" }}</span>
<br />
{{ i.begin | date:"HH:mm:ss" }}
</div>
</td>
<td class="editable">
<div class="text-center" ng-class="{ color_green : i.id == m.last_ins }">
<span ng-class="{ color_green : i.id == m.last_ins, color_blue : i.id != m.last_ins }">{{ i.end | date:"dd-MM-yyyy" }}</span>
<br/>
{{ i.end | date:"HH:mm:ss" }}
</div>
</td>
<td class="editable_status">
<span class="pointer text_medium glyphicon" ng-class="{
'color_green': i.status == 'finished',
'glyphicon-check': i.status == 'finished',
'color_blue': i.status == 'started',
'glyphicon-edit': i.status == 'started',
'glyphicon-minus': i.status == null
}" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span>
</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>
......
......@@ -37,14 +37,26 @@ module.exports.policies = {
destroy: ['tokenAuth']
},
MetaInstructionController: {
update: ['tokenAuth'],
create: ['tokenAuth'],
destroy: ['tokenAuth']
},
MetaMethodController: {
supVisible: ['tokenAuth'],
supOwned: ['tokenAuth'],
create: ['tokenAuth'],
update: ['tokenAuth'],
destroy: ['tokenAuth']
},
MethodController: {
update: ['tokenAuth'],
create: ['tokenAuth'],
newMethod: ['tokenAuth'],
save: ['tokenAuth'],
destroy: ['tokenAuth'],
destroyTemplate: ['tokenAuth'],
meta_methods: ['tokenAuth']
},
OfficeController: {
......
......@@ -35,14 +35,21 @@ module.exports.routes = {
'POST /instruction': 'InstructionController.create',
'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',
'POST /method': 'MethodController.create',
'POST /method/new': 'MethodController.newMethod',
'POST /method/save': 'MethodController.save',
'DELETE /method/:id': 'MethodController.destroy',
'DELETE /method/template/:id_mmet': 'MethodController.destroyTemplate',
'GET /method/templates/:id_sup': 'MetaMethodController.supVisible',
'GET /method/templates/owned/:id_sup': 'MetaMethodController.supOwned',
'POST /method/template/new': 'MetaMethodController.create',
'PUT /method/template/:id': 'MetaMethodController.update',
'DELETE /method/template/:id': 'MetaMethodController.destroy',
'GET /office/get_all': 'OfficeController.getAll',
'GET /office/get/:id': 'OfficeController.get',
......
......@@ -44,6 +44,7 @@ module.exports = function (grunt) {
'assets/scripts/modules/supervisor/controllers/supervisor.js',
'assets/scripts/modules/supervisor/controllers/students.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/student.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