From 518b852e8bd9c50a6c5c7e84cddecb5c94ebb5b6 Mon Sep 17 00:00:00 2001
From: MG12 <wuzhao.mail@gmail.com>
Date: Sat, 12 Dec 2015 20:34:00 +0800
Subject: add new options about disabled time

---
 src/module/Header.jsx | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'src/module/Header.jsx')

diff --git a/src/module/Header.jsx b/src/module/Header.jsx
index ef88948..c2f8eef 100644
--- a/src/module/Header.jsx
+++ b/src/module/Header.jsx
@@ -13,6 +13,9 @@ const Header = React.createClass({
     hourOptions: PropTypes.array,
     minuteOptions: PropTypes.array,
     secondOptions: PropTypes.array,
+    disabledHours: PropTypes.array,
+    disabledMinutes: PropTypes.array,
+    disabledSeconds: PropTypes.array,
     onChange: PropTypes.func,
     onClear: PropTypes.func,
     onEsc: PropTypes.func,
@@ -54,7 +57,7 @@ const Header = React.createClass({
       str,
     });
     let value = null;
-    const {formatter, gregorianCalendarLocale, hourOptions, minuteOptions, secondOptions, onChange, allowEmpty} = this.props;
+    const {formatter, gregorianCalendarLocale, hourOptions, minuteOptions, secondOptions, disabledHours, disabledMinutes, disabledSeconds, onChange, allowEmpty} = this.props;
 
     if (str) {
       const originalValue = this.props.value;
@@ -71,6 +74,7 @@ const Header = React.createClass({
       }
 
       if (value) {
+        // if time value not allowed, response warning.
         if (
           hourOptions.indexOf(value.getHourOfDay()) < 0 ||
           minuteOptions.indexOf(value.getMinutes()) < 0 ||
@@ -82,6 +86,18 @@ const Header = React.createClass({
           return;
         }
 
+        // if time value is disabled, response warning.
+        if (
+          disabledHours.indexOf(value.getHourOfDay()) >= 0 ||
+          disabledMinutes.indexOf(value.getMinutes()) >= 0 ||
+          disabledSeconds.indexOf(value.getSeconds()) >= 0
+        ) {
+          this.setState({
+            invalid: true,
+          });
+          return;
+        }
+
         if (originalValue && value) {
           if (
             originalValue.getHourOfDay() !== value.getHourOfDay() ||
-- 
cgit v1.2.3


From 0e62bf0b7bdc260e882fd185492939cbaed04d56 Mon Sep 17 00:00:00 2001
From: MG12 <wuzhao.mail@gmail.com>
Date: Sun, 13 Dec 2015 00:03:19 +0800
Subject: update test case and fix bugs

---
 src/module/Header.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/module/Header.jsx')

diff --git a/src/module/Header.jsx b/src/module/Header.jsx
index c2f8eef..fec02af 100644
--- a/src/module/Header.jsx
+++ b/src/module/Header.jsx
@@ -88,9 +88,9 @@ const Header = React.createClass({
 
         // if time value is disabled, response warning.
         if (
-          disabledHours.indexOf(value.getHourOfDay()) >= 0 ||
-          disabledMinutes.indexOf(value.getMinutes()) >= 0 ||
-          disabledSeconds.indexOf(value.getSeconds()) >= 0
+          (disabledHours && disabledHours.indexOf(value.getHourOfDay()) >= 0) ||
+          (disabledMinutes && disabledMinutes.indexOf(value.getMinutes()) >= 0) ||
+          (disabledSeconds && disabledSeconds.indexOf(value.getSeconds()) >= 0)
         ) {
           this.setState({
             invalid: true,
-- 
cgit v1.2.3


From 71bd9bc11f2ca6068f7977ff3511b2798f73d0c6 Mon Sep 17 00:00:00 2001
From: MG12 <wuzhao.mail@gmail.com>
Date: Mon, 14 Dec 2015 00:50:41 +0800
Subject: update disabled options

---
 src/module/Header.jsx | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

(limited to 'src/module/Header.jsx')

diff --git a/src/module/Header.jsx b/src/module/Header.jsx
index fec02af..9a048dc 100644
--- a/src/module/Header.jsx
+++ b/src/module/Header.jsx
@@ -13,9 +13,9 @@ const Header = React.createClass({
     hourOptions: PropTypes.array,
     minuteOptions: PropTypes.array,
     secondOptions: PropTypes.array,
-    disabledHours: PropTypes.array,
-    disabledMinutes: PropTypes.array,
-    disabledSeconds: PropTypes.array,
+    disabledHours: PropTypes.func,
+    disabledMinutes: PropTypes.func,
+    disabledSeconds: PropTypes.func,
     onChange: PropTypes.func,
     onClear: PropTypes.func,
     onEsc: PropTypes.func,
@@ -87,10 +87,13 @@ const Header = React.createClass({
         }
 
         // if time value is disabled, response warning.
+        const disabledHourOptions = disabledHours();
+        const disabledMinuteOptions = disabledMinutes(value.getHourOfDay());
+        const disabledSecondOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes());
         if (
-          (disabledHours && disabledHours.indexOf(value.getHourOfDay()) >= 0) ||
-          (disabledMinutes && disabledMinutes.indexOf(value.getMinutes()) >= 0) ||
-          (disabledSeconds && disabledSeconds.indexOf(value.getSeconds()) >= 0)
+          (disabledHourOptions && disabledHourOptions.indexOf(value.getHourOfDay()) >= 0) ||
+          (disabledMinuteOptions && disabledMinuteOptions.indexOf(value.getMinutes()) >= 0) ||
+          (disabledSecondOptions && disabledSecondOptions.indexOf(value.getSeconds()) >= 0)
         ) {
           this.setState({
             invalid: true,
-- 
cgit v1.2.3

