-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from hotosm/develop
Update master
- Loading branch information
Showing
25 changed files
with
1,026 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
'use strict'; | ||
var React = require('react/addons'); | ||
var Reflux = require('reflux'); | ||
var Router = require('react-router'); | ||
var Dropdown = require('./shared/dropdown'); | ||
var actions = require('../actions/actions'); | ||
var searchQuery = require('../stores/search_query_store'); | ||
|
||
var Filters = module.exports = React.createClass({ | ||
mixins: [ | ||
Reflux.listenTo(searchQuery, 'onSearchQuery'), | ||
Router.Navigation, | ||
Router.State | ||
], | ||
|
||
getInitialState: function () { | ||
return { | ||
date: 'all', | ||
resolution: 'all', | ||
dataType: 'all' | ||
} | ||
}, | ||
|
||
onSearchQuery: function (data) { | ||
this.setState(data); | ||
}, | ||
|
||
setDate: function (d) { | ||
actions.setDateFilter(d.key); | ||
this._updateUrl('date', d.key); | ||
}, | ||
|
||
setResolution: function (d) { | ||
actions.setResolutionFilter(d.key); | ||
this._updateUrl('resolution', d.key) | ||
}, | ||
|
||
setDataType: function (d) { | ||
actions.setDataTypeFilter(d.key); | ||
this._updateUrl('type', d.key); | ||
}, | ||
|
||
_updateUrl: function (prop, value) { | ||
var query = this.getQuery(); | ||
if (value === 'all') { | ||
delete query[prop] | ||
} else { | ||
query[prop] = value; | ||
} | ||
var routes = this.getRoutes(); | ||
this.replaceWith(routes[routes.length - 1].name, this.getParams(), query); | ||
}, | ||
|
||
|
||
render: function() { | ||
function filterItem (property, clickHandler, d) { | ||
var klass = this.state[property] === d.key ? 'active' : ''; | ||
var click = clickHandler.bind(this, d); | ||
return ( | ||
<dd key={property + '-filter-' + d.key} className={klass}> | ||
<a onClick={click} title={d.title}>{d.title}</a> | ||
</dd>); | ||
} | ||
|
||
var dates = [ | ||
{key: 'all', title: 'All'}, | ||
{key: 'week', title: 'Last week'}, | ||
{key: 'month', title: 'Last month'}, | ||
{key: 'year', title: 'Last year'} | ||
].map(filterItem.bind(this, 'date', this.setDate)); | ||
|
||
var resolutions = [ | ||
{key: 'all', title: 'All'}, | ||
{key: 'low', title: 'Low'}, | ||
{key: 'medium', title: 'Medium'}, | ||
{key: 'high', title: 'High'} | ||
].map(filterItem.bind(this, 'resolution', this.setResolution)); | ||
|
||
var dataTypes = [ | ||
{key: 'all', title: 'All Images'}, | ||
{key: 'service', title: 'Image + Map Layer'} | ||
].map(filterItem.bind(this, 'dataType', this.setDataType)); | ||
|
||
return ( | ||
<Dropdown element="li" className="drop dropdown center" triggerTitle="Settings" triggerClassName="bttn-settings" triggerText="Settings"> | ||
<dl className="drop-menu filters-options-menu" role="menu"> | ||
<dt className="drop-menu-sectitle">Time</dt> | ||
{dates} | ||
<dt className="drop-menu-sectitle">Resolution</dt> | ||
{resolutions} | ||
<dt className="drop-menu-sectitle">Data Type</dt> | ||
{dataTypes} | ||
</dl> | ||
</Dropdown> | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.