diff --git a/src/App.css b/src/App.css index 5a6601b306..77dc28756d 100644 --- a/src/App.css +++ b/src/App.css @@ -80,6 +80,7 @@ button.execute-btn { .graph-controls .endtime-input input { width: 160px; + border-right: none; } .graph-controls input.resolution-input { @@ -90,6 +91,14 @@ button.execute-btn { margin-left: 20px; } +.graph-controls .clear-endtime-btn { + background: #fff; + border-left: none; + border-top: 1px solid #ced4da; + border-bottom: 1px solid #ced4da; + color: #495057; +} + .tabpane-alert { margin: 10px; } diff --git a/src/App.js b/src/App.js index a98034dbc2..511deed59e 100755 --- a/src/App.js +++ b/src/App.js @@ -52,7 +52,6 @@ import { faArrowUp, faArrowDown, faCalendarCheck, - faTrash, faTimes, } from '@fortawesome/free-solid-svg-icons'; library.add( @@ -69,10 +68,9 @@ library.add( faArrowUp, faArrowDown, faCalendarCheck, - faTrash, faTimes, ); -dom.watch() // Needed to also replace within the date picker. +dom.watch() // Sadly needed to also replace within the date picker, since it's not a React component. class App extends Component { render() { @@ -739,16 +737,20 @@ class GraphControls extends Component { this.$endTime.datetimepicker('date', endTime); } + clearEndTime = (event) => { + this.props.onChangeEndTime(null); + this.$endTime.datetimepicker('date', null); + } + componentDidMount() { this.$endTime = window.$(this.endTimeRef.current); this.$endTime.datetimepicker({ icons: { - clear: 'fas fa-trash', today: 'fas fa-calendar-check', }, buttons: { - showClear: true, + //showClear: true, showClose: true, showToday: true, }, @@ -760,6 +762,7 @@ class GraphControls extends Component { }); this.$endTime.on('change.datetimepicker', e => { + console.log("CHANGE", e) if (e.date) { this.props.onChangeEndTime(e.date); } else { @@ -768,6 +771,10 @@ class GraphControls extends Component { }); } + componentWillUnmount() { + this.$endTime.datetimepicker('destroy'); + } + render() { return (
e.preventDefault()}> @@ -800,16 +807,22 @@ class GraphControls extends Component { // onChange={this.props.onChangeEndTime} onFocus={() => this.$endTime.datetimepicker('show')} onBlur={() => this.$endTime.datetimepicker('hide')} - onKeyDown={(e) => e.key === 'Escape' && this.$endTime.datetimepicker('hide')} + onKeyDown={(e) => ['Escape', 'Enter'].includes(e.key) && this.$endTime.datetimepicker('hide')} /> - {/* */} + + {/* CAUTION: While the datetimepicker also has an option to show a 'clear' button, + that functionality is broken, so we create an external solution instead. */} + {this.props.endTime && + + + + } - {/* TODO: validate resolution and only update when valid */}