-
Notifications
You must be signed in to change notification settings - Fork 208
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 #144 from onefinestay/allow-external-setting-of-dates
Allow externally setting dates
- Loading branch information
Showing
14 changed files
with
611 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import _ from 'underscore'; | ||
import Selection from './selection'; | ||
|
||
const QuickSelection = React.createClass({ | ||
propTypes: { | ||
dates: React.PropTypes.object.isRequired, | ||
value: React.PropTypes.object, | ||
onSelect: React.PropTypes.func.isRequired, | ||
}, | ||
|
||
isCurrentlySelected(date) { | ||
const { value } = this.props; | ||
|
||
if (!value) { | ||
return false; | ||
} | ||
|
||
return date.isSame(value); | ||
}, | ||
|
||
renderSelections() { | ||
return _.map(this.props.dates, (date, label) => { | ||
return ( | ||
<Selection key={label} | ||
className='quickSelection__selection' | ||
onSelect={this.props.onSelect} | ||
date={date} | ||
disabled={this.isCurrentlySelected(date)} | ||
label={label} /> | ||
); | ||
}); | ||
}, | ||
|
||
render() { | ||
return ( | ||
<div className='quickSelection'> | ||
{this.renderSelections()} | ||
</div> | ||
); | ||
}, | ||
}); | ||
|
||
export default QuickSelection; |
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,33 @@ | ||
import React from 'react'; | ||
|
||
const Selection = React.createClass({ | ||
propTypes: { | ||
className: React.PropTypes.string.isRequired, | ||
date: React.PropTypes.object.isRequired, | ||
disabled: React.PropTypes.bool.isRequired, | ||
label: React.PropTypes.string.isRequired, | ||
onSelect: React.PropTypes.func.isRequired, | ||
}, | ||
|
||
getDefaultProps() { | ||
return { | ||
disabled: false, | ||
}; | ||
}, | ||
|
||
onSelect() { | ||
this.props.onSelect(this.props.date); | ||
}, | ||
|
||
render() { | ||
return ( | ||
<input className={this.props.className} | ||
type='button' | ||
onClick={this.onSelect} | ||
disabled={this.props.disabled} | ||
value={this.props.label} /> | ||
); | ||
}, | ||
}); | ||
|
||
export default Selection; |
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
Oops, something went wrong.