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
f395e976
authored
May 22, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Issue
#241
, closed
parent
ffbf1e07
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
19 deletions
sails/src/api/controllers/StudentController.js
sails/src/api/models/Scene.js
sails/src/api/models/Student.js
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/assets/scripts/modules/student/controllers/pictoconfig.js
sails/src/api/controllers/StudentController.js
View file @
f395e976
...
...
@@ -1205,6 +1205,7 @@ module.exports = {
@params {request} req {
id_stu: {integer} studentID,
legend_value: {string} 'none' | 'normal' | 'full'
id_scene: {integer} sceneID
}
@params {response} res {
id: {integer} studentID,
...
...
@@ -1213,16 +1214,20 @@ module.exports = {
*/
update_legend
:
function
(
req
,
res
)
{
var
params
=
req
.
allParams
();
Student
.
update_legend
(
params
.
id_stu
,
params
.
legend_value
,
function
(
err
)
{
if
(
err
)
{
sails
.
log
.
debug
(
JSON
.
stringify
(
err
));
return
res
.
serverError
(
"Error on legend update: "
);
}
return
res
.
ok
({
id
:
params
.
id_stu
,
legend_value
:
params
.
legend_value
,
// picto attributes for student
});
})
if
(
params
.
id_scene
){
Student
.
update_legend
(
params
.
id_scene
,
params
.
legend_value
,
function
(
err
)
{
if
(
err
)
{
sails
.
log
.
debug
(
JSON
.
stringify
(
err
));
return
res
.
serverError
(
"Error on legend update: "
);
}
return
res
.
ok
({
id
:
params
.
id_stu
,
legend_value
:
params
.
legend_value
,
// picto attributes for student
});
})
}
else
{
return
res
.
badRequest
(
"id_scene required"
);
}
},
/**
...
...
sails/src/api/models/Scene.js
View file @
f395e976
...
...
@@ -102,6 +102,7 @@ module.exports = {
var
stuPictoToAdd
=
{
"id"
:
stuPicto
.
id
,
"picto"
:
stuPicto
.
picto
,
"id_scene"
:
stuPicto
.
scene
,
"attributes"
:
stuPicto
.
attributes
,
"tags"
:
picto
.
tags
?
picto
.
tags
:
[]
};
...
...
sails/src/api/models/Student.js
View file @
f395e976
...
...
@@ -409,6 +409,7 @@ module.exports = {
var
stuPictoToAdd
=
{
"id"
:
stuPicto
.
id
,
"picto"
:
stuPicto
.
picto
,
"id_scene"
:
stuPicto
.
id_scene
,
"attributes"
:
stuPicto
.
attributes
,
"tags"
:
picto
.
tags
?
picto
.
tags
:
[]
};
...
...
@@ -556,10 +557,10 @@ module.exports = {
* Updates legend in student pictos
* legend is not updated for categories
*/
update_legend
:
function
(
id_s
tu
,
legend_value
,
cb
)
{
update_legend
:
function
(
id_s
cene
,
legend_value
,
cb
)
{
var
query
=
'UPDATE stu_picto'
+
' SET attributes = json_set(attributes, \'$.legend\',\''
+
legend_value
+
'\')'
+
' WHERE id_s
tu='
+
id_stu
+
' AND '
+
' WHERE id_s
cene='
+
id_scene
+
' AND '
+
' (json_extract(attributes, \'$.id_cat\') LIKE \'null\' AND '
+
' json_extract(attributes, \'$.coord_y\') = 0 OR '
+
' json_extract(attributes, \'$.id_cat\') NOT LIKE \'null\' AND '
+
...
...
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
f395e976
...
...
@@ -608,7 +608,13 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}
}
});
// Returned data from the modal window
modalInstance
.
result
.
then
(
function
(
all_legend
)
{
if
(
all_legend
){
ngToast
.
success
({
content
:
$translate
.
instant
(
'reloading_pictos'
)
});
$scope
.
showScene
(
$scope
.
viewingScene
.
id
);
}
});
};
// Modal window to create scenes
...
...
sails/src/assets/scripts/modules/student/controllers/pictoconfig.js
View file @
f395e976
...
...
@@ -52,7 +52,9 @@ dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $t
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
$scope
.
update_all_legend
)
{
$http
.
put
(
config
.
backend
+
'/stu/'
+
stu
.
id
+
'/legend/'
+
$scope
.
studentPicto
.
attributes
.
legend
)
.
put
(
config
.
backend
+
'/stu/'
+
stu
.
id
+
'/legend/'
+
$scope
.
studentPicto
.
attributes
.
legend
,{
id_scene
:
$scope
.
studentPicto
.
id_scene
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
resolve
(
result
);
})
...
...
@@ -78,10 +80,6 @@ dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $t
studentPicto
.
attributes
=
$scope
.
studentPicto
.
attributes
;
$modalInstance
.
close
(
$scope
.
studentPicto
.
attributes
.
expression
);
if
(
$scope
.
update_all_legend
)
{
ngToast
.
success
({
content
:
$translate
.
instant
(
'reloading_pictos'
)
});
$window
.
location
.
reload
();
}
})
});
...
...
@@ -89,7 +87,7 @@ dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $t
$scope
.
close
=
function
()
{
// Lo que se devuelve a collection
$modalInstance
.
dismiss
(
'cancel'
);
$modalInstance
.
dismiss
(
$scope
.
update_all_legend
);
// Devolver el picto actualizado, situándolo en su posición
};
...
...
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