From c269752d37d289b5775fa5168743e9a457761034 Mon Sep 17 00:00:00 2001 From: kertal Date: Fri, 12 Apr 2019 15:39:46 +0200 Subject: [PATCH 1/6] Remove roundUp flag from formatTimeString function So when you set e.g. 70 years ago in the To field of the date range with "Round to the year" active, the To field's value is rounded up. So instead of: Jan 1, 1949 @ 00:00:00.000 It's Jan 1, 1949 @ 23:59:59.999 Since now this date is less then 70 years in the past, moment.js fromNow displays 69 years --- .../super_date_picker/date_popover/date_popover_button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js index 0c75d9fa71b..f6b9eda79c6 100644 --- a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js +++ b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js @@ -48,7 +48,7 @@ export function EuiDatePopoverButton(props) { data-test-subj={`superDatePicker${position}DatePopoverButton`} {...buttonProps} > - {formatTimeString(value, dateFormat, roundUp)} + {formatTimeString(value, dateFormat)} ); From 0f877ae247464d7e3762617d14ec99aa44cb5256 Mon Sep 17 00:00:00 2001 From: kertal Date: Wed, 24 Apr 2019 11:12:53 +0200 Subject: [PATCH 2/6] Add roundUp flag to displayed value of timestamp in relative tab - to sync displayed value with the value displayed in the popover button --- .../super_date_picker/date_popover/date_popover_content.js | 1 + .../date_picker/super_date_picker/date_popover/relative_tab.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/date_picker/super_date_picker/date_popover/date_popover_content.js b/src/components/date_picker/super_date_picker/date_popover/date_popover_content.js index 75e6482da3f..0ea4c7a56c2 100644 --- a/src/components/date_picker/super_date_picker/date_popover/date_popover_content.js +++ b/src/components/date_picker/super_date_picker/date_popover/date_popover_content.js @@ -52,6 +52,7 @@ export function EuiDatePopoverContent({ value, roundUp, onChange, dateFormat }) dateFormat={dateFormat} value={value} onChange={onChange} + roundUp={roundUp} /> ), 'data-test-subj': 'superDatePickerRelativeTab', diff --git a/src/components/date_picker/super_date_picker/date_popover/relative_tab.js b/src/components/date_picker/super_date_picker/date_popover/relative_tab.js index 311838443f8..391f44619a0 100644 --- a/src/components/date_picker/super_date_picker/date_popover/relative_tab.js +++ b/src/components/date_picker/super_date_picker/date_popover/relative_tab.js @@ -55,7 +55,7 @@ export class EuiRelativeTab extends Component { render() { const isInvalid = this.state.count < 0; - const parsedValue = dateMath.parse(this.props.value); + const parsedValue = dateMath.parse(this.props.value, { roundUp: this.props.roundUp }); const formatedValue = isInvalid || !parsedValue || !parsedValue.isValid() ? '' : parsedValue.format(this.props.dateFormat); @@ -107,4 +107,5 @@ EuiRelativeTab.propTypes = { dateFormat: PropTypes.string.isRequired, value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, + roundUp: PropTypes.bool }; From d2b2f9e1bf2334778e5d13f62deb0f0c82e3db97 Mon Sep 17 00:00:00 2001 From: kertal Date: Wed, 24 Apr 2019 11:17:14 +0200 Subject: [PATCH 3/6] Undo removal of roundup flag in datepicker popover button --- .../super_date_picker/date_popover/date_popover_button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js index f6b9eda79c6..0c75d9fa71b 100644 --- a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js +++ b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js @@ -48,7 +48,7 @@ export function EuiDatePopoverButton(props) { data-test-subj={`superDatePicker${position}DatePopoverButton`} {...buttonProps} > - {formatTimeString(value, dateFormat)} + {formatTimeString(value, dateFormat, roundUp)} ); From aad054be61a6f5f83021f09952613e931bcb305b Mon Sep 17 00:00:00 2001 From: kertal Date: Wed, 24 Apr 2019 19:09:32 +0200 Subject: [PATCH 4/6] Switch position of "Round to the X" button and timestamp string --- .../super_date_picker/date_popover/relative_tab.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/date_picker/super_date_picker/date_popover/relative_tab.js b/src/components/date_picker/super_date_picker/date_popover/relative_tab.js index 391f44619a0..35f39710894 100644 --- a/src/components/date_picker/super_date_picker/date_popover/relative_tab.js +++ b/src/components/date_picker/super_date_picker/date_popover/relative_tab.js @@ -87,9 +87,6 @@ export class EuiRelativeTab extends Component { - - - + + + ); } From 0140ecf33e12b115347249eaf9fd421167b81fee Mon Sep 17 00:00:00 2001 From: kertal Date: Wed, 24 Apr 2019 19:52:23 +0200 Subject: [PATCH 5/6] Switch position of "Round to the X" button and timestamp string --- .../date_popover/relative_tab.js | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/date_picker/super_date_picker/date_popover/relative_tab.js b/src/components/date_picker/super_date_picker/date_popover/relative_tab.js index 35f39710894..c810b5baa09 100644 --- a/src/components/date_picker/super_date_picker/date_popover/relative_tab.js +++ b/src/components/date_picker/super_date_picker/date_popover/relative_tab.js @@ -12,6 +12,7 @@ import { EuiFieldText, EuiSwitch } from '../../../form'; +import { EuiSpacer } from '../../../spacer'; import { timeUnits } from '../time_units'; import { relativeOptions } from '../relative_options'; @@ -87,17 +88,15 @@ export class EuiRelativeTab extends Component { - - - - - - + + + + ); } @@ -107,5 +106,5 @@ EuiRelativeTab.propTypes = { dateFormat: PropTypes.string.isRequired, value: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, - roundUp: PropTypes.bool + roundUp: PropTypes.bool, }; From 6c29b2c9ca00b502f9b3ba811b7b0755b9dcb61d Mon Sep 17 00:00:00 2001 From: kertal Date: Thu, 25 Apr 2019 14:07:55 +0200 Subject: [PATCH 6/6] Add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85f2c56acd6..e82e7d68565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Converted `EuiStat` to TS ([#1848](https://github.com/elastic/eui/pull/1848)) - Added `isLoading` prop to `EuiStat` ([#1848](https://github.com/elastic/eui/pull/1848)) +- Added `roundUp` prop to relative tab of `EuiSuperDatePicker` ([#1827](https://github.com/elastic/eui/pull/1827)) +- Changed position of `EuiSwitch` for date rounding used at relative tab of `EuiSuperDatePicker` ([#1827](https://github.com/elastic/eui/pull/1827)) **Bug fixes**