Skip to content

Commit

Permalink
#502 fixed short links in date picker. fixed layouting of date picker
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Eremic committed Sep 2, 2016
1 parent c37ab4e commit 0b44e33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 0 additions & 1 deletion client/lib/common/asset/less/violation/date-dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
div.dateDropdown-dropdown {
position: absolute;
z-index: @layer-2;
width: 600px;
background: @white;
outline: 1px solid @gray;
box-shadow: 0px 5px 15px @gray-light;
Expand Down
16 changes: 12 additions & 4 deletions client/lib/violation/src/violation/date-dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'react-date-picker/index.css';
import 'common/asset/less/violation/date-dropdown.less';
import listenToOutsideClick from 'react-onclickoutside/decorator';

const WEEK_START_MONDAY = 1;

class DateDropdown extends React.Component {
constructor(props) {
super();
Expand All @@ -15,6 +17,8 @@ class DateDropdown extends React.Component {
visible: false,
range: props.range
};

this.onUpdate = this.onUpdate.bind(this);
}

onHeaderClick() {
Expand All @@ -35,7 +39,7 @@ class DateDropdown extends React.Component {
onUpdate(_, range) {
this.setState({range});
if (this.props.onUpdate && range.length > 1) {
this.props.onUpdate(range);
this.props.onUpdate(range.map(r => r.dateMoment));
}
}

Expand All @@ -44,6 +48,8 @@ class DateDropdown extends React.Component {
}

render() {
const maxDate = moment().endOf('day');

return <div ref='dropdown' className='date-dropdown'>
<header
ref='header'
Expand All @@ -70,9 +76,11 @@ class DateDropdown extends React.Component {
</div>
<div className='dateDropdown-container'>
<Picker
weekStartDay={1}
range={this.state.range}
onRangeChange={this.onUpdate.bind(this)} />
weekStartDay = {WEEK_START_MONDAY}
range = {this.state.range}
maxDate = {maxDate}
highlightRangeOnMouseMove = {true}
onRangeChange = {this.onUpdate} />
</div>
</div>
</div> :
Expand Down
4 changes: 2 additions & 2 deletions client/lib/violation/src/violation/violation-filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ViolationFilters extends React.Component {
}
} else if (what === 'date') {
if (data[1]) {
params.from = data[0].dateMoment.toISOString();
params.to = data[1].dateMoment.toISOString();
params.from = data[0].toISOString();
params.to = data[1].toISOString();
params.page = 0;
this.context.router.push(Routes.violation(params));
if (this.props.onUpdate) {
Expand Down

0 comments on commit 0b44e33

Please sign in to comment.