-
-
Notifications
You must be signed in to change notification settings - Fork 144
PersistenceTransforms for date in datePickerRange and datePickerSingle #854
Changes from 5 commits
d2d0f1a
4d18af3
1c61fa4
de4647a
cc69b07
f4b82d1
abc13ec
c66bb74
2745855
24db1fe
57e5019
c2668a2
778f8ca
c76c973
605594c
4ba16c8
cc121c6
32852c0
d80a500
e733726
6df0230
c0f98b4
0519d89
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, {Component, lazy, Suspense} from 'react'; | ||
import datePickerRange from '../utils/LazyLoader/datePickerRange'; | ||
import moment from 'moment'; | ||
|
||
const RealDatePickerRange = lazy(datePickerRange); | ||
|
||
|
@@ -263,6 +264,31 @@ DatePickerRange.propTypes = { | |
persistence_type: PropTypes.oneOf(['local', 'session', 'memory']), | ||
}; | ||
|
||
DatePickerRange.persistenceTransforms = { | ||
end_date: { | ||
extract: propValue => { | ||
if (!(propValue === null || propValue === undefined)) { | ||
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. This check is fine but can be simplified by using https://ramdajs.com/docs/#isNil instead 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. |
||
return moment(propValue) | ||
.startOf('day') | ||
.format('YYYY-MM-DD'); | ||
} | ||
return propValue; | ||
}, | ||
apply: storedValue => storedValue, | ||
}, | ||
start_date: { | ||
extract: propValue => { | ||
if (!(propValue === null || propValue === undefined)) { | ||
return moment(propValue) | ||
.startOf('day') | ||
.format('YYYY-MM-DD'); | ||
} | ||
return propValue; | ||
}, | ||
apply: storedValue => storedValue, | ||
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. The implementation for 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. |
||
}, | ||
}; | ||
|
||
DatePickerRange.defaultProps = { | ||
calendar_orientation: 'horizontal', | ||
is_RTL: false, | ||
|
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.
With plotly/dash#1376 now merged, this can be 🔪
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.
6df0230