From a202478f9541048908c9b5922b5c725d71de0159 Mon Sep 17 00:00:00 2001 From: Marcin Lawrowski Date: Wed, 5 Dec 2018 14:24:47 +0100 Subject: [PATCH] Added option to hide Today button in Date field (#4869) --- fields/types/date/DateField.js | 10 +++++++--- fields/types/date/DateType.js | 3 ++- fields/types/date/Readme.md | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fields/types/date/DateField.js b/fields/types/date/DateField.js index 07ea682997..3bb5661bb5 100644 --- a/fields/types/date/DateField.js +++ b/fields/types/date/DateField.js @@ -28,6 +28,7 @@ module.exports = Field.create({ note: React.PropTypes.string, onChange: React.PropTypes.func, path: React.PropTypes.string, + todayButton: React.PropTypes.bool, value: React.PropTypes.string, }, @@ -85,9 +86,12 @@ module.exports = Field.create({ value={value} /> -
- -
+ { + this.props.todayButton + &&
+ +
+ } ); }, diff --git a/fields/types/date/DateType.js b/fields/types/date/DateType.js index 11499a067d..5d25164900 100644 --- a/fields/types/date/DateType.js +++ b/fields/types/date/DateType.js @@ -13,12 +13,13 @@ function date (list, path, options) { this._nativeType = Date; this._underscoreMethods = ['format', 'moment', 'parse']; this._fixedSize = 'medium'; - this._properties = ['formatString', 'yearRange', 'isUTC', 'inputFormat']; + this._properties = ['formatString', 'yearRange', 'isUTC', 'inputFormat', 'todayButton']; this.parseFormatString = options.inputFormat || 'YYYY-MM-DD'; this.formatString = (options.format === false) ? false : (options.format || 'Do MMM YYYY'); this.yearRange = options.yearRange; this.isUTC = options.utc || false; + this.todayButton = typeof options.todayButton !== 'undefined' ? options.todayButton : true; /* * This offset is used to determine whether or not a stored date is probably corrupted or not. diff --git a/fields/types/date/Readme.md b/fields/types/date/Readme.md index 8b7e431c36..8006694fc1 100644 --- a/fields/types/date/Readme.md +++ b/fields/types/date/Readme.md @@ -30,6 +30,12 @@ Defaults to 'Do MMM YYYY' See the [momentjs format docs](http://momentjs.com/docs/#/displaying/format/) for information on the supported formats and options. +* `todayButton` `Boolean` + +Determines if the Today button will be displayed. + +Defaults to 'true' + ## Methods ### `format(formatString)`