Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
89b4cdee
authored
Feb 22, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue #953 fixed
parent
df7dd36c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
10 deletions
sails/src/api/controllers/MetaMethodController.js
sails/src/api/controllers/MethodController.js
sails/src/assets/scripts/modules/student/controllers/instructions.js
sails/src/assets/scripts/modules/supervisor/controllers/instructions.js
sails/src/api/controllers/MetaMethodController.js
View file @
89b4cdee
...
...
@@ -86,10 +86,14 @@ module.exports = {
if
(
!
params
.
id_sup
)
return
res
.
badRequest
(
"No supervisor defined"
);
if
(
!
params
.
lang
)
return
res
.
badRequest
(
"No lang defined"
);
MetaMethod
.
create
({
"name"
:
params
.
name
,
"description"
:
""
,
"supervisor"
:
params
.
id_sup
"supervisor"
:
params
.
id_sup
,
"lang"
:
params
.
lang
})
.
then
(
function
(
createdMethod
){
return
res
.
ok
(
createdMethod
);
...
...
sails/src/api/controllers/MethodController.js
View file @
89b4cdee
...
...
@@ -132,16 +132,29 @@ module.exports = {
},
// FERNANDO: avoid method name duplicates
//
// Saves a method as a template
//
/*
* Saves a method as a template
* @param {request} req
* {
* id_stu: studentId,
* id_sup: supervisorID
* lang: student lang code
* }
* @param {response} res
* {
* id: methodId,
* supervisor: supervisorId
* lang: {string} language code
* description: {string}
* }
*/
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"
});
if
(
!
params
.
lang
)
return
res
.
json
(
500
,
{
error
:
"No lang defined"
});
Method
.
findOne
(
params
.
id_met
).
populate
(
'instructions'
).
exec
(
function
(
err
,
method
)
{
if
(
err
){
...
...
@@ -152,7 +165,8 @@ module.exports = {
MetaMethod
.
create
({
"name"
:
method
.
name
,
"description"
:
method
.
description
,
"supervisor"
:
params
.
id_sup
"supervisor"
:
params
.
id_sup
,
"lang"
:
params
.
lang
}).
exec
(
function
(
err
,
createdMethod
){
if
(
err
){
sails
.
log
.
debug
(
"Create Method error: "
+
err
);
...
...
sails/src/assets/scripts/modules/student/controllers/instructions.js
View file @
89b4cdee
...
...
@@ -164,7 +164,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$scope
.
save_as_template
=
function
(
method
){
$http
.
post
(
config
.
backend
+
'/method/save'
,
{
'id_met'
:
method
.
id
,
'id_sup'
:
$scope
.
user
.
id
})
.
post
(
config
.
backend
+
'/method/save'
,
{
'id_met'
:
method
.
id
,
'id_sup'
:
$scope
.
user
.
id
,
'lang'
:
$scope
.
user
.
lang
})
.
then
(
//success
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
'Saved method as template:'
+
JSON
.
stringify
(
data
));
...
...
@@ -180,7 +180,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
}
,
function
(
data
,
status
,
headers
,
config
)
{
//error
console
.
log
(
"Error from API: "
+
data
.
error
+
"("
+
data
.
status
+
")"
);
ngToast
.
success
({
ngToast
.
warning
({
content
:
$translate
.
instant
(
'method_name_duplicated'
,
{
method_name
:
method
.
name
}),
timeout
:
6000
// By default 4000
});
...
...
sails/src/assets/scripts/modules/supervisor/controllers/instructions.js
View file @
89b4cdee
...
...
@@ -33,12 +33,13 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
// Functions
//
// Add new method template (metamethod)
selected to the student
// Add new method template (metamethod)
$scope
.
add_method
=
function
(){
var
new_data
=
{
name
:
$translate
.
instant
(
"new_method"
),
id_sup
:
$scope
.
user
.
id
id_sup
:
$scope
.
user
.
id
,
lang
:
$scope
.
user
.
lang
,
};
$http
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment