Commit ebac59c4 authored by Florent Chehab's avatar Florent Chehab
Browse files

Search => filter for coherence

parent 9e91cba3
Pipeline #26891 passed with stages
in 2 minutes and 28 seconds
export const SAVE_MAIN_MAP_POSITION = 'SAVE_MAIN_MAP_POSITION'; export const SAVE_MAIN_MAP_POSITION = 'SAVE_MAIN_MAP_POSITION';
export const SAVE_SELECTED_UNIVERSITIES = 'SAVE_SELECTED_UNIVERSITIES'; export const SAVE_SELECTED_UNIVERSITIES = 'SAVE_SELECTED_UNIVERSITIES';
export const SAVE_SEARCH_CONFIG = 'SAVE_SEARCH_CONFIG'; export const SAVE_FILTER_CONFIG = 'SAVE_FILTER_CONFIG';
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
};
}
import { import {
SAVE_SELECTED_UNIVERSITIES, SAVE_SELECTED_UNIVERSITIES,
SAVE_SEARCH_CONFIG SAVE_FILTER_CONFIG
} from "./action-types"; } from "./action-types";
...@@ -12,9 +12,9 @@ export function saveSelectedUniversities(new_selection) { ...@@ -12,9 +12,9 @@ export function saveSelectedUniversities(new_selection) {
}; };
} }
export function saveSearchConfig(config) { export function saveFilterConfig(config) {
return { return {
type: SAVE_SEARCH_CONFIG, type: SAVE_FILTER_CONFIG,
config config
}; };
} }
...@@ -33,7 +33,7 @@ import { ...@@ -33,7 +33,7 @@ import {
import PageMap from './pages/PageMap'; import PageMap from './pages/PageMap';
import PageHome from './pages/PageHome'; import PageHome from './pages/PageHome';
import PageSearch from './pages/PageSearch'; import PageFilter from './pages/PageFilter';
const drawerWidth = 240; const drawerWidth = 240;
...@@ -159,7 +159,7 @@ class App extends MyComponent { ...@@ -159,7 +159,7 @@ class App extends MyComponent {
<Route path="/app/" exact={true} component={PageHome} /> <Route path="/app/" exact={true} component={PageHome} />
<Route path="/app/map" component={PageMap} /> <Route path="/app/map" component={PageMap} />
<Route path="/app/search" component={PageSearch} /> <Route path="/app/filter" component={PageFilter} />
</main> </main>
</div> </div>
......
...@@ -82,9 +82,9 @@ class DownshiftMultiple extends React.Component { ...@@ -82,9 +82,9 @@ class DownshiftMultiple extends React.Component {
const { options } = this.props; const { options } = this.props;
const { selectedItems } = this.state; const { selectedItems } = this.state;
let possible = _.difference(options, selectedItems); let possible = _.difference(options, selectedItems);
const search = fuzzysort.go(value, possible, { limit: 5, key: 'label' }); const filter = fuzzysort.go(value, possible, { limit: 5, key: 'label' });
if (search.length > 0){ if (filter.length > 0){
return _.map(search, (item) => item.obj) return _.map(filter, (item) => item.obj)
} else { } else {
return possible.slice(0,4) return possible.slice(0,4)
} }
......
...@@ -4,7 +4,7 @@ import DownshiftMultiple from './DownshiftMultiple'; ...@@ -4,7 +4,7 @@ import DownshiftMultiple from './DownshiftMultiple';
import MyComponent from '../MyComponent' import MyComponent from '../MyComponent'
import { connect } from "react-redux"; import { connect } from "react-redux";
import _ from 'underscore'; import _ from 'underscore';
import { saveSelectedUniversities, saveSearchConfig } from '../../actions/search'; import { saveSelectedUniversities, saveFilterConfig } from '../../actions/filter';
import { import {
universitiesFetchData, universitiesFetchData,
...@@ -13,7 +13,7 @@ import { ...@@ -13,7 +13,7 @@ import {
countriesFetchData countriesFetchData
} from '../../generated/actions'; } from '../../generated/actions';
class Search extends MyComponent { class Filter extends MyComponent {
joinCampus(campus) { joinCampus(campus) {
const { universities, countries, cities } = this.getAllFetchedData(); const { universities, countries, cities } = this.getAllFetchedData();
...@@ -91,7 +91,7 @@ const mapStateToProps = (state) => { ...@@ -91,7 +91,7 @@ const mapStateToProps = (state) => {
mainCampuses: state.mainCampuses, mainCampuses: state.mainCampuses,
cities: state.cities, cities: state.cities,
countries: state.countries, countries: state.countries,
contriesFilterConfig: state.app.search.contriesFilter contriesFilterConfig: state.app.filter.contriesFilter
}; };
}; };
...@@ -104,9 +104,9 @@ const mapDispatchToProps = (dispatch) => { ...@@ -104,9 +104,9 @@ const mapDispatchToProps = (dispatch) => {
countries: () => dispatch(countriesFetchData()) countries: () => dispatch(countriesFetchData())
}, },
saveSelection: (selectedUniversities) => dispatch(saveSelectedUniversities(selectedUniversities)), saveSelection: (selectedUniversities) => dispatch(saveSelectedUniversities(selectedUniversities)),
saveConfig: (config) => dispatch(saveSearchConfig(config)) saveConfig: (config) => dispatch(saveFilterConfig(config))
}; };
}; };
export default connect(mapStateToProps, mapDispatchToProps)(Search); export default connect(mapStateToProps, mapDispatchToProps)(Filter);
...@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; ...@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import Search from '../search/Search'; import Filter from '../filter/Filter';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
const styles = theme => ({ const styles = theme => ({
...@@ -20,14 +20,14 @@ class PageMap extends React.Component { ...@@ -20,14 +20,14 @@ class PageMap extends React.Component {
<Grid container spacing={24}> <Grid container spacing={24}>
<Grid item xs={11}> <Grid item xs={11}>
<Typography variant="display1" gutterBottom> <Typography variant="display1" gutterBottom>
Recherche Filtrer
</Typography> </Typography>
</Grid> </Grid>
{/* <Grid item xs={1}> {/* <Grid item xs={1}>
<UnivMapReloadButton /> <UnivMapReloadButton />
</Grid> */} </Grid> */}
</Grid> </Grid>
<Search /> <Filter />
</Paper> </Paper>
); );
} }
......
...@@ -9,6 +9,7 @@ import PeopleIcon from '@material-ui/icons/People'; ...@@ -9,6 +9,7 @@ import PeopleIcon from '@material-ui/icons/People';
import BarChartIcon from '@material-ui/icons/BarChart'; import BarChartIcon from '@material-ui/icons/BarChart';
import HomeIcon from '@material-ui/icons/Home'; import HomeIcon from '@material-ui/icons/Home';
import SearchIcon from '@material-ui/icons/Search'; import SearchIcon from '@material-ui/icons/Search';
import FilterIcon from '@material-ui/icons/FilterList';
import AssignmentIcon from '@material-ui/icons/Assignment'; import AssignmentIcon from '@material-ui/icons/Assignment';
import { NavLink } from 'react-router-dom' import { NavLink } from 'react-router-dom'
...@@ -24,6 +25,15 @@ export const mainListItems = ( ...@@ -24,6 +25,15 @@ export const mainListItems = (
</ListItem> </ListItem>
</NavLink> </NavLink>
<NavLink to={'/app/search/'}>
<ListItem button>
<ListItemIcon>
<SearchIcon />
</ListItemIcon>
<ListItemText primary="Rechercher" />
</ListItem>
</NavLink>
<NavLink to={'/app/map/'}> <NavLink to={'/app/map/'}>
<ListItem button> <ListItem button>
<ListItemIcon> <ListItemIcon>
...@@ -33,16 +43,15 @@ export const mainListItems = ( ...@@ -33,16 +43,15 @@ export const mainListItems = (
</ListItem> </ListItem>
</NavLink> </NavLink>
<NavLink to={'/app/search/'}> <NavLink to={'/app/filter/'}>
<ListItem button> <ListItem button>
<ListItemIcon> <ListItemIcon>
<SearchIcon /> <FilterIcon />
</ListItemIcon> </ListItemIcon>
<ListItemText primary="Recherche" /> <ListItemText primary="Filtrer" />
</ListItem> </ListItem>
</NavLink> </NavLink>
<ListItem button> <ListItem button>
<ListItemIcon> <ListItemIcon>
<LocationCityIcon /> <LocationCityIcon />
......
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) { export function saveSelectedUniversities(state = [], action) {
switch (action.type) { switch (action.type) {
...@@ -12,9 +12,9 @@ export function saveSelectedUniversities(state = [], action) { ...@@ -12,9 +12,9 @@ export function saveSelectedUniversities(state = [], action) {
} }
} }
export function saveSearchConfig(state = { contriesFilter: { selectedItems: [], inputValue: '' } }, action) { export function saveFilterConfig(state = { contriesFilter: { selectedItems: [], inputValue: '' } }, action) {
switch (action.type) { switch (action.type) {
case SAVE_SEARCH_CONFIG: case SAVE_FILTER_CONFIG:
return Object.assign(state, action.config) return Object.assign(state, action.config)
default: default:
......
...@@ -11,13 +11,13 @@ import { ...@@ -11,13 +11,13 @@ import {
} from '../generated/combinedReducers'; } from '../generated/combinedReducers';
import { saveMainMapPosition } from './map'; import { saveMainMapPosition } from './map';
import { saveSelectedUniversities } from './search'; import { saveSelectedUniversities } from './filter';
import { saveSearchConfig } from './search'; import { saveFilterConfig } from './filter';
const appReducers = combineReducers({ const appReducers = combineReducers({
mainMap: saveMainMapPosition, mainMap: saveMainMapPosition,
selectedUniversities: saveSelectedUniversities, selectedUniversities: saveSelectedUniversities,
search: saveSearchConfig, filter: saveFilterConfig,
}) })
const rootReducer = combineReducers({ const rootReducer = combineReducers({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment