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
ca3f0369
authored
Jan 18, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue #701 close - category pictos can be modified
parent
a2a259e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
30 deletions
sails/src/api/controllers/StudentController.js
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/api/controllers/StudentController.js
View file @
ca3f0369
...
@@ -980,38 +980,41 @@ module.exports = {
...
@@ -980,38 +980,41 @@ module.exports = {
.
then
((
sp
)
=>
{
.
then
((
sp
)
=>
{
if
(
!
sp
)
throw
new
Error
(
"error on update"
);
if
(
!
sp
)
throw
new
Error
(
"error on update"
);
// Get student to get language
Student
.
findOne
(
params
.
id_stu
)
Student
.
findOne
(
params
.
id_stu
)
.
then
((
s
)
=>
{
.
then
((
s
)
=>
{
if
(
!
s
)
throw
new
Error
(
"Student not found"
);
if
(
!
s
)
throw
new
Error
(
"Student not found"
);
console
.
log
(
"id_pic: "
+
sp
.
picto
+
", lang: "
+
s
.
lang
);
PictoExp
.
findOne
({
id_pic
:
sp
.
picto
,
lang
:
s
.
lang
})
PictoExp
.
findOne
({
id_pic
:
sp
.
picto
,
lang
:
s
.
lang
})
.
then
((
pe
)
=>
{
.
then
((
pe
)
=>
{
if
(
!
pe
)
if
(
!
pe
)
throw
new
Error
(
"Expression not found"
);
throw
new
Error
(
"Expression not found"
);
var
old_picto
=
sp
.
picto
;
// store old picto id to update pictos in category
sp
.
picto
=
params
.
new_id_pic
;
var
old_picto
=
sp
.
picto
;
if
(
sp
.
attributes
.
expression
==
undefined
||
sp
.
attributes
.
expression
==
null
)
sp
.
attributes
.
expression
=
pe
.
text
;
sp
.
attributes
.
expression
=
pe
.
text
;
// Save modified stu_picto entry for category
sp
.
picto
=
params
.
new_id_pic
;
sp
.
save
((
err
)
=>
{
if
(
err
)
throw
err
;
// Save modified stu_picto entry for category
// Update attributes.id_cat for all pictos
sp
.
save
((
err
)
=>
{
StuPicto
.
find
({
id_stu
:
params
.
id_stu
})
if
(
err
)
throw
err
;
.
then
(
sps
=>
{
// Update attributes.id_cat for all pictos
for
(
var
i
=
0
;
i
<
sps
.
length
;
i
++
)
{
StuPicto
.
find
({
id_stu
:
params
.
id_stu
})
if
(
sps
[
i
].
attributes
.
id_cat
==
old_picto
)
{
.
then
(
sps
=>
{
sps
[
i
].
attributes
.
id_cat
=
params
.
new_id_pic
;
for
(
var
i
=
0
;
i
<
sps
.
length
;
i
++
)
{
sps
[
i
].
save
();
if
(
sps
[
i
].
attributes
.
id_cat
==
old_picto
)
{
}
sps
[
i
].
attributes
.
id_cat
=
params
.
new_id_pic
;
sps
[
i
].
save
();
}
}
return
res
.
ok
(
sp
);
}
})
return
res
.
ok
(
sp
);
.
catch
(
e
=>
{
throw
e
});
})
});
.
catch
(
err
=>
{
throw
err
});
});
})
})
.
catch
(
e
=>
{
throw
e
});
.
catch
(
e
rr
=>
{
throw
err
});
})
})
.
catch
(
e
=>
{
throw
e
})
.
catch
(
e
rr
=>
{
throw
err
})
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
return
res
.
serverError
(
'Unable to update category for student: '
+
err
);
return
res
.
serverError
(
'Unable to update category for student: '
+
err
);
...
...
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
ca3f0369
...
@@ -52,7 +52,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -52,7 +52,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
selectedCategory
=
$scope
.
emptyStudentPicto
;
$scope
.
selectedCategory
=
$scope
.
emptyStudentPicto
;
$scope
.
studentPictos
=
{};
$scope
.
studentPictos
=
{};
$scope
.
freeCategoryPictos
=
null
;
$scope
.
freeCategoryPictos
=
null
;
$scope
.
categories
=
[];
$scope
.
loadingPictos
=
true
;
$scope
.
loadingPictos
=
true
;
$scope
.
isCategory
=
function
(
studentPicto
)
{
$scope
.
isCategory
=
function
(
studentPicto
)
{
...
@@ -109,10 +108,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -109,10 +108,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
=
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
if
(
$scope
.
isCategory
(
picto
))
{
$scope
.
categories
.
push
(
picto
);
}
// Categories disabled
// Categories disabled
if
(
typeof
freeCategoryPositionX
===
'number'
&&
if
(
typeof
freeCategoryPositionX
===
'number'
&&
typeof
freeCategoryPositionY
===
'number'
)
{
typeof
freeCategoryPositionY
===
'number'
)
{
...
@@ -126,6 +121,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -126,6 +121,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
getCategoryId
(
picto
);
$scope
.
getCategoryId
(
picto
);
$scope
.
studentPictos
[
category
]
=
$scope
.
studentPictos
[
category
]
||
generateGrid
();
$scope
.
studentPictos
[
category
]
=
$scope
.
studentPictos
[
category
]
||
generateGrid
();
$scope
.
studentPictos
[
category
][
positionX
][
positionY
]
=
picto
;
$scope
.
studentPictos
[
category
][
positionX
][
positionY
]
=
picto
;
console
.
log
(
"picto placed at "
+
positionX
+
" "
+
positionY
);
}
}
};
};
...
@@ -140,7 +136,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -140,7 +136,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Get user's pictos
// Get user's pictos
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/pictos'
)
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/pictos'
)
.
success
(
function
(
studentPictos
)
{
.
success
(
function
(
studentPictos
)
{
$scope
.
categories
=
[];
$scope
.
showFreeCategory
=
!
$scope
.
studentData
.
attributes
.
categories
;
$scope
.
showFreeCategory
=
!
$scope
.
studentData
.
attributes
.
categories
;
studentPictos
.
forEach
(
placePicto
);
studentPictos
.
forEach
(
placePicto
);
...
@@ -337,8 +332,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -337,8 +332,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
new_id_pic
:
pictoId
new_id_pic
:
pictoId
})
})
.
success
(
function
(
studentPicto
)
{
.
success
(
function
(
studentPicto
)
{
console
.
log
(
attributes
);
console
.
log
(
JSON
.
stringify
(
studentPicto
)
);
placePicto
(
studentPicto
);
$scope
.
loadPictos
(
);
// notify
// notify
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
...
...
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