1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

[advanced search] fixed and improved 'date picker' (#4614)

* fixed UI
* added 'clear', 'disabledDate', 'click outside to close'
* allow user to choose the same day for start & end date
This commit is contained in:
llj
2020-07-21 11:17:09 +08:00
committed by GitHub
parent dccddea02f
commit 3a5d6ba3fb
3 changed files with 65 additions and 27 deletions

View File

@@ -14,8 +14,6 @@ const propsTypes = {
onChange: PropTypes.func.isRequired
};
const FORMAT = 'YYYY-MM-DD HH:mm';
class Picker extends React.Component {
constructor(props) {
@@ -24,7 +22,7 @@ class Picker extends React.Component {
this.calendarContainerRef = React.createRef();
this.inputRef = React.createRef();
this.state = {
isOpen: true
isOpen: false
};
}
@@ -64,12 +62,20 @@ class Picker extends React.Component {
render() {
const props = this.props;
let showHourAndMinute = true; // default: true
if (props.showHourAndMinute != undefined) {
showHourAndMinute = props.showHourAndMinute;
}
const FORMAT = showHourAndMinute ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
const calendar = (<Calendar
defaultValue={this.defaultCalendarValue}
disabledDate={props.disabledDate}
format={FORMAT}
locale={translateCalendar()}
showHourAndMinute={true}
showHourAndMinute={showHourAndMinute}
/>);
return (
<DatePicker