Loic CHOLLIER
2015-05-14 802bee8cea85fe1c4c9bb1860bcb509e6eb0a702
Change this.state.inputFormat when this.props.inputFormat changes
1 files modified
27 ■■■■■ changed files
src/DateTimeField.jsx 27 ●●●●● patch | view | raw | blame | history
src/DateTimeField.jsx
@@ -35,17 +35,6 @@
      }
    };
  },
  resolvePropsInputFormat: function() {
    if(this.props.inputFormat) return this.props.inputFormat;
    switch(this.props.mode) {
      case Constants.MODE_TIME:
        return "h:mm A";
      case Constants.MODE_DATE:
        return "MM/DD/YY";
      default:
        return "MM/DD/YY h:mm A";
    }
  },
  getInitialState: function() {
    return {
      showDatePicker: this.props.mode !== Constants.MODE_TIME,
@@ -71,6 +60,22 @@
        inputValue: moment(nextProps.dateTime, nextProps.format, true).format(nextProps.inputFormat)
      });
    }
    if (nextProps.inputFormat !== this.props.inputFormat) {
      return this.setState({
        inputFormat: nextProps.inputFormat
      });
    }
  },
  resolvePropsInputFormat: function() {
    if(this.props.inputFormat) return this.props.inputFormat;
    switch(this.props.mode) {
      case Constants.MODE_TIME:
        return "h:mm A";
      case Constants.MODE_DATE:
        return "MM/DD/YY";
      default:
        return "MM/DD/YY h:mm A";
    }
  },
  onChange: function(event) {
    var value = event.target == null ? event : event.target.value;