diff options
Diffstat (limited to 'src/module/Header.jsx')
-rw-r--r-- | src/module/Header.jsx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/module/Header.jsx b/src/module/Header.jsx index ef88948..9a048dc 100644 --- a/src/module/Header.jsx +++ b/src/module/Header.jsx | |||
@@ -13,6 +13,9 @@ const Header = React.createClass({ | |||
13 | hourOptions: PropTypes.array, | 13 | hourOptions: PropTypes.array, |
14 | minuteOptions: PropTypes.array, | 14 | minuteOptions: PropTypes.array, |
15 | secondOptions: PropTypes.array, | 15 | secondOptions: PropTypes.array, |
16 | disabledHours: PropTypes.func, | ||
17 | disabledMinutes: PropTypes.func, | ||
18 | disabledSeconds: PropTypes.func, | ||
16 | onChange: PropTypes.func, | 19 | onChange: PropTypes.func, |
17 | onClear: PropTypes.func, | 20 | onClear: PropTypes.func, |
18 | onEsc: PropTypes.func, | 21 | onEsc: PropTypes.func, |
@@ -54,7 +57,7 @@ const Header = React.createClass({ | |||
54 | str, | 57 | str, |
55 | }); | 58 | }); |
56 | let value = null; | 59 | let value = null; |
57 | const {formatter, gregorianCalendarLocale, hourOptions, minuteOptions, secondOptions, onChange, allowEmpty} = this.props; | 60 | const {formatter, gregorianCalendarLocale, hourOptions, minuteOptions, secondOptions, disabledHours, disabledMinutes, disabledSeconds, onChange, allowEmpty} = this.props; |
58 | 61 | ||
59 | if (str) { | 62 | if (str) { |
60 | const originalValue = this.props.value; | 63 | const originalValue = this.props.value; |
@@ -71,6 +74,7 @@ const Header = React.createClass({ | |||
71 | } | 74 | } |
72 | 75 | ||
73 | if (value) { | 76 | if (value) { |
77 | // if time value not allowed, response warning. | ||
74 | if ( | 78 | if ( |
75 | hourOptions.indexOf(value.getHourOfDay()) < 0 || | 79 | hourOptions.indexOf(value.getHourOfDay()) < 0 || |
76 | minuteOptions.indexOf(value.getMinutes()) < 0 || | 80 | minuteOptions.indexOf(value.getMinutes()) < 0 || |
@@ -82,6 +86,21 @@ const Header = React.createClass({ | |||
82 | return; | 86 | return; |
83 | } | 87 | } |
84 | 88 | ||
89 | // if time value is disabled, response warning. | ||
90 | const disabledHourOptions = disabledHours(); | ||
91 | const disabledMinuteOptions = disabledMinutes(value.getHourOfDay()); | ||
92 | const disabledSecondOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes()); | ||
93 | if ( | ||
94 | (disabledHourOptions && disabledHourOptions.indexOf(value.getHourOfDay()) >= 0) || | ||
95 | (disabledMinuteOptions && disabledMinuteOptions.indexOf(value.getMinutes()) >= 0) || | ||
96 | (disabledSecondOptions && disabledSecondOptions.indexOf(value.getSeconds()) >= 0) | ||
97 | ) { | ||
98 | this.setState({ | ||
99 | invalid: true, | ||
100 | }); | ||
101 | return; | ||
102 | } | ||
103 | |||
85 | if (originalValue && value) { | 104 | if (originalValue && value) { |
86 | if ( | 105 | if ( |
87 | originalValue.getHourOfDay() !== value.getHourOfDay() || | 106 | originalValue.getHourOfDay() !== value.getHourOfDay() || |