-
-
Notifications
You must be signed in to change notification settings - Fork 144
Improved DatePickerRange #221
Changes from 5 commits
1cc0315
d402fd1
1fe7446
3646328
97e4378
0f4ea4c
4b7c337
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,11 @@ | |
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [0.23.1] | ||
### Fixed | ||
- Improved DatePickerRange, fixing issues #209 and 152 | ||
|
||
### Added | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can ⚡️ this one |
||
## [0.23.0] | ||
### Added | ||
- Upgraded Plotly.js, the underlying library behind the | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,73 +139,6 @@ | |
} | ||
} | ||
}, | ||
"src/components/Confirm.react.js": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why this chunk of meta was removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is curious... I have no idea why it's there in the first place, as there's no Confirm component or anything. Could it be related to the new Confirmation modal? |
||
"description": "Confirm wraps window.confirm", | ||
"displayName": "Confirm", | ||
"methods": [], | ||
"props": { | ||
"id": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "" | ||
}, | ||
"message": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "" | ||
}, | ||
"init": { | ||
"type": { | ||
"name": "shape", | ||
"value": { | ||
"value": { | ||
"name": "any", | ||
"required": false | ||
}, | ||
"ask": { | ||
"name": "bool", | ||
"required": false | ||
} | ||
} | ||
}, | ||
"required": false, | ||
"description": "" | ||
}, | ||
"result": { | ||
"type": { | ||
"name": "shape", | ||
"value": { | ||
"timestamp": { | ||
"name": "custom", | ||
"raw": "PropTypes.integer", | ||
"required": false | ||
}, | ||
"value": { | ||
"name": "any", | ||
"required": false | ||
} | ||
} | ||
}, | ||
"required": false, | ||
"description": "", | ||
"defaultValue": { | ||
"value": "{\n timestamp: -1\n}", | ||
"computed": false | ||
} | ||
}, | ||
"setProps": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Dash-assigned callback that gets fired when the value changes." | ||
} | ||
} | ||
}, | ||
"src/components/DatePickerRange.react.js": { | ||
"description": "DatePickerRange is a tailor made component designed for selecting\ntimespan across multiple days off of a calendar.\n\nThe DatePicker integrates well with the Python datetime module with the\nstartDate and endDate being returned in a string format suitable for\ncreating datetime objects.\n\nThis component is based off of Airbnb's react-dates react component\nwhich can be found here: https://github.com/airbnb/react-dates", | ||
"displayName": "DatePickerRange", | ||
|
@@ -512,6 +445,27 @@ | |
}, | ||
"required": false, | ||
"description": "Dash-assigned callback that gets fired when the value changes." | ||
}, | ||
"updatemode": { | ||
"type": { | ||
"name": "enum", | ||
"value": [ | ||
{ | ||
"value": "'singledate'", | ||
"computed": false | ||
}, | ||
{ | ||
"value": "'bothdates'", | ||
"computed": false | ||
} | ||
] | ||
}, | ||
"required": false, | ||
"description": "Determines when the component should update\nits value. If `bothdates`, then the DatePicker \nwill only trigger its value when the user has\nfinished picking both dates. If `singledate`, then\nthe DatePicker will update its value \nas one date is picked.", | ||
"defaultValue": { | ||
"value": "'singledate'", | ||
"computed": false | ||
} | ||
} | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.23.0' | ||
__version__ = '0.23.1' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,21 +55,28 @@ export default class DatePickerRange extends Component { | |
componentWillMount() { | ||
this.propsToState(this.props); | ||
} | ||
|
||
onDatesChange({startDate: start_date, endDate: end_date}) { | ||
const {setProps, fireEvent} = this.props; | ||
const {setProps, fireEvent, updatemode} = this.props; | ||
const old_start_date = this.state.start_date | ||
const old_end_date = this.state.end_date | ||
const newState = {}; | ||
if (setProps && start_date !== null) { | ||
setProps({start_date: start_date.format('YYYY-MM-DD')}); | ||
} else { | ||
newState.start_date = start_date; | ||
} | ||
if (setProps && start_date !== null && start_date !== old_start_date) { | ||
if(updatemode === 'singledate') { | ||
setProps({start_date: start_date.format('YYYY-MM-DD')}); | ||
} | ||
} | ||
|
||
if (setProps && end_date !== null) { | ||
setProps({end_date: end_date.format('YYYY-MM-DD')}); | ||
} else { | ||
newState.end_date = end_date; | ||
newState.start_date = start_date; | ||
|
||
if (setProps && end_date !== null && end_date !== old_end_date) { | ||
if(updatemode === 'singledate') { | ||
setProps({end_date: end_date.format('YYYY-MM-DD')}); | ||
} | ||
else if (updatemode === 'bothdates') { | ||
setProps({start_date: start_date.format('YYYY-MM-DD'), end_date: end_date.format('YYYY-MM-DD')}); | ||
} | ||
} | ||
newState.end_date = end_date; | ||
|
||
if (fireEvent) { | ||
fireEvent('change'); | ||
|
@@ -313,7 +320,17 @@ DatePickerRange.propTypes = { | |
/** | ||
* Dash-assigned callback that gets fired when the value changes. | ||
*/ | ||
dashEvents: PropTypes.oneOf(['change']) | ||
dashEvents: PropTypes.oneOf(['change']), | ||
|
||
/** | ||
* Determines when the component should update | ||
* its value. If `bothdates`, then the DatePicker | ||
* will only trigger its value when the user has | ||
* finished picking both dates. If `singledate`, then | ||
* the DatePicker will update its value | ||
* as one date is picked. | ||
*/ | ||
updatemode: PropTypes.oneOf(['singledate', 'bothdates']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Nice |
||
}; | ||
|
||
DatePickerRange.defaultProps = { | ||
|
@@ -327,5 +344,6 @@ DatePickerRange.defaultProps = { | |
stay_open_on_select: false, | ||
reopen_calendar_on_clear: false, | ||
clearable: false, | ||
disabled: false | ||
disabled: false, | ||
updatemode: 'singledate' | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make these links to the issues, i.e.: