Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Julien Jerphanion
Rex Dri
Commits
ebac59c4
Commit
ebac59c4
authored
Sep 03, 2018
by
Florent Chehab
Browse files
Search => filter for coherence
parent
9e91cba3
Changes
10
Hide whitespace changes
Inline
Side-by-side
frontend/src/actions/action-types.js
View file @
ebac59c4
export
const
SAVE_MAIN_MAP_POSITION
=
'
SAVE_MAIN_MAP_POSITION
'
;
export
const
SAVE_SELECTED_UNIVERSITIES
=
'
SAVE_SELECTED_UNIVERSITIES
'
;
export
const
SAVE_
SEARCH
_CONFIG
=
'
SAVE_
SEARCH
_CONFIG
'
;
export
const
SAVE_
FILTER
_CONFIG
=
'
SAVE_
FILTER
_CONFIG
'
;
frontend/src/actions/filter.js
0 → 100644
View file @
ebac59c4
import
{
SAVE_SELECTED_UNIVERSITIES
,
SAVE_FILTER_CONFIG
}
from
"
./action-types
"
;
export
function
saveSelectedUniversities
(
new_selection
)
{
return
{
type
:
SAVE_SELECTED_UNIVERSITIES
,
new_selection
};
}
export
function
saveFilterConfig
(
config
)
{
return
{
type
:
SAVE_FILTER_CONFIG
,
config
};
}
frontend/src/actions/search.js
View file @
ebac59c4
import
{
SAVE_SELECTED_UNIVERSITIES
,
SAVE_
SEARCH
_CONFIG
SAVE_
FILTER
_CONFIG
}
from
"
./action-types
"
;
...
...
@@ -12,9 +12,9 @@ export function saveSelectedUniversities(new_selection) {
};
}
export
function
save
Search
Config
(
config
)
{
export
function
save
Filter
Config
(
config
)
{
return
{
type
:
SAVE_
SEARCH
_CONFIG
,
type
:
SAVE_
FILTER
_CONFIG
,
config
};
}
frontend/src/components/App.js
View file @
ebac59c4
...
...
@@ -33,7 +33,7 @@ import {
import
PageMap
from
'
./pages/PageMap
'
;
import
PageHome
from
'
./pages/PageHome
'
;
import
Page
Search
from
'
./pages/Page
Search
'
;
import
Page
Filter
from
'
./pages/Page
Filter
'
;
const
drawerWidth
=
240
;
...
...
@@ -159,7 +159,7 @@ class App extends MyComponent {
<
Route
path
=
"
/app/
"
exact
=
{
true
}
component
=
{
PageHome
}
/
>
<
Route
path
=
"
/app/map
"
component
=
{
PageMap
}
/
>
<
Route
path
=
"
/app/
search
"
component
=
{
Page
Search
}
/
>
<
Route
path
=
"
/app/
filter
"
component
=
{
Page
Filter
}
/
>
<
/main
>
<
/div
>
...
...
frontend/src/components/
search
/DownshiftMultiple.js
→
frontend/src/components/
filter
/DownshiftMultiple.js
View file @
ebac59c4
...
...
@@ -82,9 +82,9 @@ class DownshiftMultiple extends React.Component {
const
{
options
}
=
this
.
props
;
const
{
selectedItems
}
=
this
.
state
;
let
possible
=
_
.
difference
(
options
,
selectedItems
);
const
search
=
fuzzysort
.
go
(
value
,
possible
,
{
limit
:
5
,
key
:
'
label
'
});
if
(
search
.
length
>
0
){
return
_
.
map
(
search
,
(
item
)
=>
item
.
obj
)
const
filter
=
fuzzysort
.
go
(
value
,
possible
,
{
limit
:
5
,
key
:
'
label
'
});
if
(
filter
.
length
>
0
){
return
_
.
map
(
filter
,
(
item
)
=>
item
.
obj
)
}
else
{
return
possible
.
slice
(
0
,
4
)
}
...
...
frontend/src/components/
search/Search
.js
→
frontend/src/components/
filter/Filter
.js
View file @
ebac59c4
...
...
@@ -4,7 +4,7 @@ import DownshiftMultiple from './DownshiftMultiple';
import
MyComponent
from
'
../MyComponent
'
import
{
connect
}
from
"
react-redux
"
;
import
_
from
'
underscore
'
;
import
{
saveSelectedUniversities
,
save
Search
Config
}
from
'
../../actions/
search
'
;
import
{
saveSelectedUniversities
,
save
Filter
Config
}
from
'
../../actions/
filter
'
;
import
{
universitiesFetchData
,
...
...
@@ -13,7 +13,7 @@ import {
countriesFetchData
}
from
'
../../generated/actions
'
;
class
Search
extends
MyComponent
{
class
Filter
extends
MyComponent
{
joinCampus
(
campus
)
{
const
{
universities
,
countries
,
cities
}
=
this
.
getAllFetchedData
();
...
...
@@ -91,7 +91,7 @@ const mapStateToProps = (state) => {
mainCampuses
:
state
.
mainCampuses
,
cities
:
state
.
cities
,
countries
:
state
.
countries
,
contriesFilterConfig
:
state
.
app
.
search
.
contriesFilter
contriesFilterConfig
:
state
.
app
.
filter
.
contriesFilter
};
};
...
...
@@ -104,9 +104,9 @@ const mapDispatchToProps = (dispatch) => {
countries
:
()
=>
dispatch
(
countriesFetchData
())
},
saveSelection
:
(
selectedUniversities
)
=>
dispatch
(
saveSelectedUniversities
(
selectedUniversities
)),
saveConfig
:
(
config
)
=>
dispatch
(
save
Search
Config
(
config
))
saveConfig
:
(
config
)
=>
dispatch
(
save
Filter
Config
(
config
))
};
};
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Search
);
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Filter
);
frontend/src/components/pages/Page
Search
.js
→
frontend/src/components/pages/Page
Filter
.js
View file @
ebac59c4
...
...
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import
{
withStyles
}
from
'
@material-ui/core/styles
'
;
import
Grid
from
'
@material-ui/core/Grid
'
;
import
Typography
from
'
@material-ui/core/Typography
'
;
import
Search
from
'
../
search/Search
'
;
import
Filter
from
'
../
filter/Filter
'
;
import
Paper
from
'
@material-ui/core/Paper
'
;
const
styles
=
theme
=>
({
...
...
@@ -20,14 +20,14 @@ class PageMap extends React.Component {
<
Grid
container
spacing
=
{
24
}
>
<
Grid
item
xs
=
{
11
}
>
<
Typography
variant
=
"
display1
"
gutterBottom
>
Recherche
Filtrer
<
/Typography
>
<
/Grid
>
{
/* <Grid item xs={1}>
<UnivMapReloadButton />
</Grid> */
}
<
/Grid
>
<
Search
/>
<
Filter
/>
<
/Paper
>
);
}
...
...
frontend/src/components/template/listItems.js
View file @
ebac59c4
...
...
@@ -9,6 +9,7 @@ import PeopleIcon from '@material-ui/icons/People';
import
BarChartIcon
from
'
@material-ui/icons/BarChart
'
;
import
HomeIcon
from
'
@material-ui/icons/Home
'
;
import
SearchIcon
from
'
@material-ui/icons/Search
'
;
import
FilterIcon
from
'
@material-ui/icons/FilterList
'
;
import
AssignmentIcon
from
'
@material-ui/icons/Assignment
'
;
import
{
NavLink
}
from
'
react-router-dom
'
...
...
@@ -24,6 +25,15 @@ export const mainListItems = (
<
/ListItem
>
<
/NavLink
>
<
NavLink
to
=
{
'
/app/search/
'
}
>
<
ListItem
button
>
<
ListItemIcon
>
<
SearchIcon
/>
<
/ListItemIcon
>
<
ListItemText
primary
=
"
Rechercher
"
/>
<
/ListItem
>
<
/NavLink
>
<
NavLink
to
=
{
'
/app/map/
'
}
>
<
ListItem
button
>
<
ListItemIcon
>
...
...
@@ -33,16 +43,15 @@ export const mainListItems = (
<
/ListItem
>
<
/NavLink
>
<
NavLink
to
=
{
'
/app/
search
/
'
}
>
<
NavLink
to
=
{
'
/app/
filter
/
'
}
>
<
ListItem
button
>
<
ListItemIcon
>
<
Search
Icon
/>
<
Filter
Icon
/>
<
/ListItemIcon
>
<
ListItemText
primary
=
"
Recherche
"
/>
<
ListItemText
primary
=
"
Filtrer
"
/>
<
/ListItem
>
<
/NavLink
>
<
ListItem
button
>
<
ListItemIcon
>
<
LocationCityIcon
/>
...
...
frontend/src/reducers/
search
.js
→
frontend/src/reducers/
filter
.js
View file @
ebac59c4
import
{
SAVE_SELECTED_UNIVERSITIES
,
SAVE_
SEARCH
_CONFIG
}
from
'
../actions/action-types
'
import
{
SAVE_SELECTED_UNIVERSITIES
,
SAVE_
FILTER
_CONFIG
}
from
'
../actions/action-types
'
export
function
saveSelectedUniversities
(
state
=
[],
action
)
{
switch
(
action
.
type
)
{
...
...
@@ -12,9 +12,9 @@ export function saveSelectedUniversities(state = [], action) {
}
}
export
function
save
Search
Config
(
state
=
{
contriesFilter
:
{
selectedItems
:
[],
inputValue
:
''
}
},
action
)
{
export
function
save
Filter
Config
(
state
=
{
contriesFilter
:
{
selectedItems
:
[],
inputValue
:
''
}
},
action
)
{
switch
(
action
.
type
)
{
case
SAVE_
SEARCH
_CONFIG
:
case
SAVE_
FILTER
_CONFIG
:
return
Object
.
assign
(
state
,
action
.
config
)
default
:
...
...
frontend/src/reducers/index.js
View file @
ebac59c4
...
...
@@ -11,13 +11,13 @@ import {
}
from
'
../generated/combinedReducers
'
;
import
{
saveMainMapPosition
}
from
'
./map
'
;
import
{
saveSelectedUniversities
}
from
'
./
search
'
;
import
{
save
Search
Config
}
from
'
./
search
'
;
import
{
saveSelectedUniversities
}
from
'
./
filter
'
;
import
{
save
Filter
Config
}
from
'
./
filter
'
;
const
appReducers
=
combineReducers
({
mainMap
:
saveMainMapPosition
,
selectedUniversities
:
saveSelectedUniversities
,
search
:
saveSearch
Config
,
filter
:
saveFilter
Config
,
})
const
rootReducer
=
combineReducers
({
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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