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
74758708
authored
Feb 10, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue #853, search pictos in addpicto
Only accept 1 sublevel in subcategory
parent
108bffc6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
173 additions
and
18 deletions
sails/src/api/controllers/PictoController.js
sails/src/assets/app/i18n/en-gb.json
sails/src/assets/app/i18n/es-es.json
sails/src/assets/scripts/modules/student/controllers/addpicto.js
sails/src/assets/scripts/modules/student/views/addpicto.html
sails/src/config/policies.js
sails/src/config/routes.js
sails/src/api/controllers/PictoController.js
View file @
74758708
...
@@ -243,16 +243,107 @@ module.exports = {
...
@@ -243,16 +243,107 @@ module.exports = {
})
})
.
catch
(()
=>
res
.
serverError
());
.
catch
(()
=>
res
.
serverError
());
function
getCategories
(
id_cat
){
// function getCategories(id_cat){
PictoCat
// PictoCat
.
find
({
select
:
[
'id'
],
id_supercat
:
id_cat
})
// .find({select: ['id'], id_supercat: id_cat })
.
then
(
function
(
categories
)
{
// .then(function (categories) {
console
.
log
(
categories
);
// console.log(categories);
return
categories
;
// return categories;
// })
// .catch(function (err) {
// throw err;
// });
// }
},
/**
* Return own or public pictos using a search string from category
* and subcategories using the language of the specified supervisor.
* @param {request} req {} (with supervisorId and categoryId as url parameters)
* @param {response} res
* [
* {
* expressions: [
* // There should be just one expression per picto
* // with the language being used by the supervisor
* {
* id: 1234,
* lang: 'es-es',
* text: 'nacimiento',
* picto: 23
* }
* ],
* source: 1,
* owner: null,
* id: 23,
* uri: 'picto/uri.jpg',
* category: 41
* }
* ]
*/
fromSearch
:
function
(
req
,
res
)
{
Supervisor
.
findOne
({
id
:
req
.
params
.
id
}).
then
(
function
(
supervisor
)
{
if
(
supervisor
)
{
if
(
req
.
params
.
id_cat
==
0
){
//Search in all categories
getPictos
(
0
,
supervisor
.
lang
,
supervisor
.
id
);
}
else
{
//Get selected category and subcategories
PictoCat
.
find
({
select
:
[
'id'
],
id_supercat
:
req
.
params
.
id_cat
})
.
then
(
function
(
categories
)
{
var
filtered
=
[
Number
(
req
.
params
.
id_cat
)];
//Get returned ID
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
){
filtered
.
push
(
categories
[
i
].
id
);
}
getPictos
(
filtered
,
supervisor
.
lang
,
supervisor
.
id
);
})
.
catch
(
function
(
err
)
{
throw
err
;
});
}
}
else
{
return
res
.
badRequest
();
}
})
.
catch
(()
=>
res
.
serverError
());
//
// Get pictos within specified categories
//
function
getPictos
(
categories
,
lang
,
sup_id
){
var
l
=
[];
var
fs
=
require
(
'fs'
);
//Only fetch owned or public pictos
var
params
=
{
or
:
[{
owner
:
null
},
{
owner
:
sup_id
}],
source
:
req
.
params
.
source
};
if
(
typeof
categories
==
"object"
){
//Is an array
params
=
{
or
:
[{
owner
:
null
},
{
owner
:
sup_id
}],
category
:
categories
};
}
Picto
.
find
().
where
(
params
)
.
paginate
({
page
:
req
.
params
.
page
,
limit
:
req
.
params
.
limit
})
.
populate
(
'expressions'
,
{
lang
:
lang
,
text
:
{
like
:
'%'
+
req
.
params
.
text
+
'%'
}})
.
then
(
function
(
pictos
)
{
async
.
eachSeries
(
pictos
,
function
(
picto
,
next_cb
)
{
// check picto has expressions associated in student language
if
(
picto
.
expressions
.
length
==
0
||
picto
.
expressions
[
0
].
text
.
length
==
0
)
return
next_cb
();
// check picto image is available
picto
.
imageFileExists
((
found
)
=>
{
if
(
found
)
{
l
.
push
(
picto
);
next_cb
();
}
else
next_cb
();
});
},
function
(
err
)
{
// loop has end
if
(
err
)
throw
err
;
sails
.
log
.
debug
(
pictos
.
length
+
" pictos sent for category "
+
req
.
params
.
id_cat
+
" in language "
+
lang
);
return
res
.
ok
(
l
);
});
// end async.eachSeries
})
})
.
catch
(
function
(
err
)
{
.
catch
(()
=>
res
.
badRequest
());
throw
err
;
});
}
}
},
},
...
...
sails/src/assets/app/i18n/en-gb.json
View file @
74758708
...
@@ -383,7 +383,9 @@
...
@@ -383,7 +383,9 @@
"view"
:
"View"
,
"view"
:
"View"
,
"voice"
:
"Voice"
,
"voice"
:
"Voice"
,
"warning_last_session_bad"
:
"Last session was interrupted. Please, you must evaluate last tries and press 'close seesion' button"
,
"warning_last_session_bad"
:
"Last session was interrupted. Please, you must evaluate last tries and press 'close seesion' button"
,
"warning_no_pictos_found"
:
"No pictograms found with specified keyword"
,
"warning_no_tablet_online"
:
"No Pictogran Tablet online detected"
,
"warning_no_tablet_online"
:
"No Pictogran Tablet online detected"
,
"warning_two_characters"
:
"Must type at least two characters"
,
"woman"
:
"Woman"
,
"woman"
:
"Woman"
,
"year_totals"
:
"Year totals"
,
"year_totals"
:
"Year totals"
,
"yes"
:
"Yes"
,
"yes"
:
"Yes"
,
...
...
sails/src/assets/app/i18n/es-es.json
View file @
74758708
...
@@ -384,7 +384,9 @@
...
@@ -384,7 +384,9 @@
"view"
:
"Vista"
,
"view"
:
"Vista"
,
"voice"
:
"Voz"
,
"voice"
:
"Voz"
,
"warning_last_session_bad"
:
"La última sesión no se cerró correctamente. Por favor, evalúe los ensayos y pulse 'cerrar sesión' "
,
"warning_last_session_bad"
:
"La última sesión no se cerró correctamente. Por favor, evalúe los ensayos y pulse 'cerrar sesión' "
,
"warning_no_pictos_found"
:
"No se encontraron pictogramas con las palabras introducidas"
,
"warning_no_tablet_online"
:
"No se detectó ningún usuario de Pictogram Tablet online"
,
"warning_no_tablet_online"
:
"No se detectó ningún usuario de Pictogram Tablet online"
,
"warning_two_characters"
:
"Debe introducir al menos dos caracteres"
,
"woman"
:
"Mujer"
,
"woman"
:
"Mujer"
,
"year_totals"
:
"Totales año"
,
"year_totals"
:
"Totales año"
,
"yes"
:
"Sí"
,
"yes"
:
"Sí"
,
...
...
sails/src/assets/scripts/modules/student/controllers/addpicto.js
View file @
74758708
...
@@ -313,5 +313,56 @@ dashboardControllers.controller('AddPictoCtrl', function (
...
@@ -313,5 +313,56 @@ dashboardControllers.controller('AddPictoCtrl', function (
});
});
$scope
.
loadingCatPictos
=
false
;
$scope
.
loadingCatPictos
=
false
;
});
});
}
};
//
// Search srch_term_picto in owned or public pictos
//
$scope
.
search
=
function
(){
$scope
.
page
=
1
;
// Reset pagination
var
length
=
$scope
.
srch_term_picto
==
undefined
?
0
:
$scope
.
srch_term_picto
.
length
;
if
(
length
<
2
){
//Check the word length
$scope
.
alert
=
{
type
:
'warning'
,
msg
:
'warning_two_characters'
,
show
:
true
};
}
else
{
var
request
=
""
;
var
source
=
1
;
$scope
.
closeAlert
();
$scope
.
loadingCatPictos
=
true
;
//category to look in
var
category
=
$scope
.
breadcrumbs
[
$scope
.
breadcrumbs
.
length
-
1
].
id
;
if
(
$scope
.
source
==
"ownpictos"
){
source
=
2
;
category
=
0
;
}
request
=
config
.
backend
+
'/sup/'
+
supervisor
.
id
+
'/pic_fromSearch/'
+
$scope
.
srch_term_picto
+
'/category/'
+
category
+
'/page/'
+
$scope
.
page
+
'/limit/'
+
$scope
.
limit
+
'/source/'
+
source
;
// Add Search to breadcrumbs
if
(
$scope
.
breadcrumbs
[
$scope
.
breadcrumbs
.
length
-
1
].
id
!=
999
){
$scope
.
breadcrumbs
.
push
({
id
:
999
,
exp
:
"filter"
,
glyphicon
:
'glyphicon glyphicon-chevron-right'
});
}
$scope
.
symbolstxCats
=
[];
$http
.
get
(
request
)
.
success
(
function
(
data
)
{
$scope
.
pictos
=
data
;
if
(
data
.
length
==
0
){
$scope
.
alert
=
{
type
:
'warning'
,
msg
:
'warning_no_pictos_found'
,
show
:
true
};
}
$scope
.
loadingCatPictos
=
false
;
})
.
error
(
function
()
{
$translate
(
'error_loading_pictos'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
});
$scope
.
loadingCatPictos
=
false
;
});
}
};
});
});
sails/src/assets/scripts/modules/student/views/addpicto.html
View file @
74758708
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<div
class=
"panel-heading"
>
<div
class=
"panel-heading"
>
<div
class=
"pull-left"
ng-repeat=
"b in breadcrumbs"
>
<div
class=
"pull-left"
ng-repeat=
"b in breadcrumbs"
>
<a
ng-click=
"open_category_from_bc(b.id)"
>
<a
ng-click=
"open_category_from_bc(b.id)"
>
<span
class=
"{{b.glyphicon}}"
></span>
{{ b.exp }}
<span
class=
"{{b.glyphicon}}"
></span>
{{ b.exp
| translate
}}
</a>
</a>
</div>
</div>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
@@ -40,17 +40,24 @@
...
@@ -40,17 +40,24 @@
</div>
</div>
<div>
<div>
<alert
ng-show=
"alert.show"
ng-model=
"alert"
type=
"{{alert.type}}"
close=
"closeAlert()"
>
{{alert.msg}}
</alert>
<alert
ng-show=
"alert.show"
ng-model=
"alert"
type=
"{{alert.type}}"
close=
"closeAlert()"
>
{{alert.msg
| translate
}}
</alert>
</div>
</div>
<div
class=
"row"
ng-show=
"source != 'newfile'"
>
<div
class=
"row"
ng-show=
"source != 'newfile'"
>
<div
id=
"collections"
class=
"col-md-12 category-collection"
<div
id=
"collections"
class=
"col-md-12 category-collection"
ng-class=
"{ 'category-collection-loading': loadingCatPictos }"
ng-class=
"{ 'category-collection-loading': loadingCatPictos }"
data-loading=
"{{ 'loading_pictos' | translate }}"
>
data-loading=
"{{ 'loading_pictos' | translate }}"
>
<div
class=
"input-group"
id=
"search_pictos_box"
>
<form
ng-submit=
"search()"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"{{ 'filter' | translate }}"
ng-model=
"srch_term_picto"
id=
"srch_term_picto"
>
<div
class=
"input-group"
id=
"search_pictos_box"
>
<span
class=
"input-group-addon glyphicon glyphicon-search"
id=
"basic-addon2"
aria-hidden=
"true"
></span>
<input
type=
"text"
class=
"form-control"
placeholder=
"{{ 'filter' | translate }}"
</div>
id=
"srch_term_picto"
name=
"srch_term_picto"
ng-model=
"srch_term_picto"
>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
<i
class=
"fa fa-search"
aria-hidden=
"true"
>
{{ 'search' | translate }}
</i>
</button>
</span>
</div>
</form>
<div
ng-show=
"source == 'ownpictos'"
class=
"input-group"
>
<div
ng-show=
"source == 'ownpictos'"
class=
"input-group"
>
<button
class=
"btn btn-success"
ngf-select
ng-model=
"picFile"
accept=
"image/*"
ngf-change=
"addOwnPicto()"
>
<button
class=
"btn btn-success"
ngf-select
ng-model=
"picFile"
accept=
"image/*"
ngf-change=
"addOwnPicto()"
>
<span
class=
"glyphicon glyphicon-folder-open"
></span>
{{ 'new_img' | translate }}
<span
class=
"glyphicon glyphicon-folder-open"
></span>
{{ 'new_img' | translate }}
...
@@ -61,7 +68,7 @@
...
@@ -61,7 +68,7 @@
infinite-scroll-container=
"'#collections'"
>
infinite-scroll-container=
"'#collections'"
>
<div
<div
class=
"picto_peq pull-left"
class=
"picto_peq pull-left"
ng-repeat=
"p in pictos
| filter:srch_term_picto
"
>
ng-repeat=
"p in pictos"
>
<img
ng-src=
"{{p.uri}}"
popover=
"{{p.expressions[0].text}}"
popover-trigger=
"mouseenter"
/>
<img
ng-src=
"{{p.uri}}"
popover=
"{{p.expressions[0].text}}"
popover-trigger=
"mouseenter"
/>
<!-- Options to remove picto (Only for own pictos) -->
<!-- Options to remove picto (Only for own pictos) -->
<div
class=
"picto_options"
ng-show=
"source == 'ownpictos'"
>
<div
class=
"picto_options"
ng-show=
"source == 'ownpictos'"
>
...
...
sails/src/config/policies.js
View file @
74758708
...
@@ -75,7 +75,8 @@ module.exports.policies = {
...
@@ -75,7 +75,8 @@ module.exports.policies = {
categories
:
[
'tokenAuth'
],
categories
:
[
'tokenAuth'
],
fromcategory
:
[
'tokenAuth'
],
fromcategory
:
[
'tokenAuth'
],
fromSymbolStx
:
[
'tokenAuth'
],
fromSymbolStx
:
[
'tokenAuth'
],
fromCatSubcat
:
[
'tokenAuth'
]
fromCatSubcat
:
[
'tokenAuth'
],
fromSearch
:
[
'tokenAuth'
]
},
},
ServerController
:
{
ServerController
:
{
...
...
sails/src/config/routes.js
View file @
74758708
...
@@ -108,6 +108,7 @@ module.exports.routes = {
...
@@ -108,6 +108,7 @@ module.exports.routes = {
'GET /sup/:id/pic_fromcategory/:id_cat'
:
'PictoController.fromcategory'
,
'GET /sup/:id/pic_fromcategory/:id_cat'
:
'PictoController.fromcategory'
,
'GET /sup/:id/pic_fromSymbolStx/page/:page/limit/:limit'
:
'PictoController.fromSymbolStx'
,
'GET /sup/:id/pic_fromSymbolStx/page/:page/limit/:limit'
:
'PictoController.fromSymbolStx'
,
'GET /sup/:id/pic_fromCatSubcat/category/:id_cat/page/:page/limit/:limit'
:
'PictoController.fromCatSubcat'
,
'GET /sup/:id/pic_fromCatSubcat/category/:id_cat/page/:page/limit/:limit'
:
'PictoController.fromCatSubcat'
,
'GET /sup/:id/pic_fromSearch/:text/category/:id_cat/page/:page/limit/:limit/source/:source'
:
'PictoController.fromSearch'
,
'GET /sup/email/:email'
:
'SupervisorController.getByEmail'
,
'GET /sup/email/:email'
:
'SupervisorController.getByEmail'
,
'GET /sup/changepass/:email'
:
'SupervisorController.request_change_password'
,
'GET /sup/changepass/:email'
:
'SupervisorController.request_change_password'
,
'PUT /sup/changepass'
:
'SupervisorController.change_password'
,
'PUT /sup/changepass'
:
'SupervisorController.change_password'
,
...
...
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