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
43deb2f6
authored
Jul 29, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fixed issue #506: tags handling fully operational
parent
bcecdaa7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
20 deletions
sails/src/api/models/Student.js
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/assets/scripts/modules/student/controllers/tags.js
sails/src/api/models/Student.js
View file @
43deb2f6
...
@@ -354,6 +354,7 @@ module.exports = {
...
@@ -354,6 +354,7 @@ module.exports = {
// Populate expressions to get it with the picto
// Populate expressions to get it with the picto
Picto
.
findOne
(
stuPicto
.
picto
.
id
)
Picto
.
findOne
(
stuPicto
.
picto
.
id
)
.
populate
(
'expressions'
,
{
lang
:
student
.
lang
})
.
populate
(
'expressions'
,
{
lang
:
student
.
lang
})
.
populate
(
'tags'
,
{
lang
:
student
.
lang
})
.
then
((
picto
)
=>
{
.
then
((
picto
)
=>
{
// check picto has expressions associated in student language
// check picto has expressions associated in student language
...
@@ -371,12 +372,15 @@ module.exports = {
...
@@ -371,12 +372,15 @@ module.exports = {
return
;
return
;
}
}
// Now we have everythin, so we add the picto to the list
//sails.log.debug("Tags: " + JSON.stringify(stuPicto.picto.tags));
// Now we have everything, so we add the picto to the list
var
stuPictoToAdd
=
{
var
stuPictoToAdd
=
{
"id"
:
stuPicto
.
id
,
"id"
:
stuPicto
.
id
,
"picto"
:
stuPicto
.
picto
,
"picto"
:
stuPicto
.
picto
,
"expression"
:
picto
.
expressions
[
0
],
"expression"
:
picto
.
expressions
[
0
],
"attributes"
:
stuPicto
.
attributes
"attributes"
:
stuPicto
.
attributes
,
"tags"
:
picto
.
tags
?
picto
.
tags
:
[]
};
};
l
.
push
(
stuPictoToAdd
);
l
.
push
(
stuPictoToAdd
);
...
...
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
43deb2f6
...
@@ -24,7 +24,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -24,7 +24,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
uri
:
'/app/img/empty.gif'
,
uri
:
'/app/img/empty.gif'
,
category
:
null
,
category
:
null
,
source
:
1
,
source
:
1
,
owner
:
null
owner
:
null
,
tags
:
null
},
},
expression
:
{
expression
:
{
id
:
null
,
id
:
null
,
...
@@ -82,6 +83,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -82,6 +83,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$scope
.
freeCategoryPictos
=
$scope
.
freeCategoryPictos
||
generateGrid
();
$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
();
$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
.
categories
=
[];
...
@@ -114,7 +116,11 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -114,7 +116,11 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
loadingPictos
=
false
;
$scope
.
loadingPictos
=
false
;
setTimeout
(
function
()
{
$scope
.
$apply
();
});
setTimeout
(
function
()
{
$scope
.
$apply
();
});
})
})
.
error
(
function
()
{});
.
error
(
function
()
{
$translate
(
'error_loading_pictos'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
});
});
};
};
// Show the pictograms of a category when it is clicked
// Show the pictograms of a category when it is clicked
...
...
sails/src/assets/scripts/modules/student/controllers/tags.js
View file @
43deb2f6
...
@@ -14,23 +14,19 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
...
@@ -14,23 +14,19 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
sup
,
sup
,
$translate
,
$translate
,
ngToast
)
{
ngToast
)
{
// Supervisor
// Supervisor
$scope
.
sup
=
sup
;
$scope
.
sup
=
sup
;
// List of general tags
$scope
.
tags
=
[];
// List of own tags
$scope
.
ownTags
=
[];
// Request of general tags
// List of tags
$http
.
get
(
config
.
backend
+
'/picto/'
+
studentPicto
.
picto
.
id
)
$scope
.
tags
=
[];
// tags we don't own
.
success
(
function
(
data
)
{
$scope
.
ownTags
=
[];
// tags we own
$scope
.
tags
=
data
.
tags
;
$scope
.
ownTags
=
data
.
tagsSup
;
studentPicto
.
tags
.
forEach
((
tag
,
index
,
arr
)
=>
{
})
if
(
tag
.
supervisor
==
sup
.
id
)
.
error
(
function
()
{
$scope
.
ownTags
.
push
(
tag
);
$translate
(
'error_loading_pictos'
).
then
(
function
(
translation
)
{
else
ngToast
.
danger
({
content
:
translation
});
$scope
.
tags
.
push
(
tag
);
});
});
});
// Add own tag
// Add own tag
...
@@ -45,6 +41,7 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
...
@@ -45,6 +41,7 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
)
)
.
success
(
function
(
data
)
{
.
success
(
function
(
data
)
{
$scope
.
ownTags
.
push
(
data
);
$scope
.
ownTags
.
push
(
data
);
studentPicto
.
tags
.
push
(
data
);
$scope
.
tagToAdd
=
''
;
$scope
.
tagToAdd
=
''
;
})
})
.
error
(
function
()
{
.
error
(
function
()
{
...
@@ -64,9 +61,12 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
...
@@ -64,9 +61,12 @@ dashboardControllers.controller('TagsCtrl', function TagsCtrl(
});
});
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
for
(
i
=
0
;
i
<
$scope
.
ownTags
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
$scope
.
ownTags
.
length
;
i
++
)
{
if
(
tag
.
id
===
$scope
.
ownTags
[
i
].
id
)
{
if
(
tag
.
id
===
$scope
.
ownTags
[
i
].
id
)
$scope
.
ownTags
.
splice
(
i
,
1
);
$scope
.
ownTags
.
splice
(
i
,
1
);
}
}
for
(
i
=
0
;
i
<
studentPicto
.
tags
.
length
;
i
++
)
{
if
(
tag
.
id
===
studentPicto
.
tags
.
id
)
studentPicto
.
tags
.
splice
(
i
,
1
);
}
}
})
})
.
error
(
function
()
{
.
error
(
function
()
{
...
...
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