Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
ee683de0
Commit
ee683de0
authored
May 10, 2020
by
Imane Misrar
Browse files
feat(Filter/FilterService) : add front feature to filter only open destinations
Relates to
#148
parent
65bcecc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/filter/Filter.jsx
View file @
ee683de0
...
...
@@ -6,6 +6,9 @@ import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import
Typography
from
"
@material-ui/core/Typography
"
;
import
uuid
from
"
uuid/v4
"
;
import
{
makeStyles
}
from
"
@material-ui/styles
"
;
import
{
Checkbox
}
from
"
@material-ui/core
"
;
import
FormControl
from
"
@material-ui/core/FormControl
"
;
import
FormControlLabel
from
"
@material-ui/core/FormControlLabel
"
;
import
DownshiftMultiple
from
"
../common/DownshiftMultiple
"
;
import
useGlobalState
from
"
../../hooks/useGlobalState
"
;
import
FilterService
from
"
../../services/FilterService
"
;
...
...
@@ -54,18 +57,24 @@ function Filter() {
[]
);
const
[
onlyOpenDestinations
,
setOnlyOpenDestinations
]
=
useGlobalState
(
"
filter-only-open-destinations
"
,
false
);
useEffect
(()
=>
{
const
selectedUniversities
=
FilterService
.
getSelection
(
countries
,
semesters
,
majorMinors
majorMinors
,
onlyOpenDestinations
);
const
hasSelection
=
[
countries
,
semesters
,
majorMinors
].
some
(
arr
=>
arr
.
length
!==
0
)
;
const
hasSelection
=
[
countries
,
semesters
,
majorMinors
].
some
(
arr
=>
arr
.
length
!==
0
)
||
onlyOpenDestinations
===
true
;
saveSelectedUniversities
(
hasSelection
?
selectedUniversities
:
null
);
},
[
countries
,
semesters
,
majorMinors
]);
},
[
countries
,
semesters
,
majorMinors
,
onlyOpenDestinations
]);
const
{
countriesOptions
,
...
...
@@ -132,6 +141,23 @@ function Filter() {
effectués sont pris en compte.
</
Typography
>
</
div
>
<
div
className
=
{
classes
.
input
}
>
<
FormControl
>
<
FormControlLabel
control
=
{
<
Checkbox
color
=
"primary"
checked
=
{
onlyOpenDestinations
}
onChange
=
{
()
=>
setOnlyOpenDestinations
(
!
onlyOpenDestinations
)
}
/>
}
label
=
"Filtrer par destinations disponibles actuellement"
labelPlacement
=
"end"
/>
</
FormControl
>
</
div
>
</
ExpansionPanelDetails
>
</
ExpansionPanel
>
);
...
...
frontend/src/services/FilterService.js
View file @
ee683de0
...
...
@@ -80,7 +80,7 @@ class FilterService {
Object
.
values
(
univObj
.
denormalized_infos
.
semesters_majors_minors
).
flatMap
(
forSemester
=>
Object
.
keys
(
forSemester
))
)
)
];
}
...
...
@@ -134,7 +134,8 @@ class FilterService {
getSelection
(
selectedCountriesCode
=
[],
selectedSemesters
=
[],
selectedMajorMinors
=
[]
selectedMajorMinors
=
[],
selectOnlyOpenDestinations
=
false
)
{
let
possible
=
selectedCountriesCode
.
length
===
0
...
...
@@ -175,6 +176,12 @@ class FilterService {
});
}
if
(
selectOnlyOpenDestinations
)
{
possible
=
possible
.
filter
(
univ
=>
univ
.
denormalized_infos
.
id_destination_open
===
true
);
}
return
possible
.
map
(
univ
=>
univ
.
id
);
}
}
...
...
Write
Preview
Supports
Markdown
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