 RuleSelectorMenu = React.createClass
   getInitialState: ->
     nowMenuPath: ['_root']
-    nowLastMenu: menuTree['_root']
-    ruleValue: null
-    applyEnabled: false
+    inputText: ''
     errorText: null
 
   handleDropdownChange: (level, e) ->
+    @clearErrorText()
     path = @state.nowMenuPath[0..level]
     path.push e.target.value
-    totalDetails = accumulateMenu path
-    @clearErrorText()
     @setState
       nowMenuPath: path
-      nowLastMenu: totalDetails
-      applyEnabled: totalDetails.value?
-      ruleValue: totalDetails.value
-
-  handleTextChange: (e) ->
-    path = @state.nowMenuPath
-    nowMenu = @state.nowLastMenu
-    value = e.target.value
+
+  handleTextChange: (value) ->
     @setState
-      applyEnabled: !nowMenu.applyEnabledFunc? || nowMenu.applyEnabledFunc path, value
-      ruleValue: value
+      inputText: value
 
   handleAddRule: ->
     path = @state.nowMenuPath.slice()
-    menu = @state.nowLastMenu
+    menu = accumulateMenu path
     preprocess = menu.preprocess || ((path, value) -> value)
-    value = cloneByJson(preprocess(path, @state.ruleValue))
-    if menu.testError? && (errorText = menu.testError path, value)?
+    value = menu.value || @state.inputText
+    preValue = preprocess path, value
+    if menu.testError? && (errorText = menu.testError path, preValue)?
       @setState {errorText}
     else
-      @props.onAddRule? path, value
+      @props.onAddRule? path, preValue
 
   clearErrorText: ->
     @setState
       errorText: null
 
   render: ->
+    applyEnable = false
+    lastMenu = accumulateMenu @state.nowMenuPath
     <Panel collapsible defaultExpanded header={__ 'Filter'}>
       <form className='form-horizontal'>
         <ListGroup fill>


              # A text input
              else
                <Input type='text' onChange={@handleTextChange}
                  {...options} />
         }
        </ListGroup>

      show: false
      text: null
    @props.onDismiss?()

StatefulInputText = React.createClass
  getInitialState: ->
    text: ''

  onChange: (e) ->
    @props.onChange? e.target.value
    @setState
      text: e.target.value

  render: ->
    props = @props
    <Input type='text' value={@state.text} {...props} onChange={@onChange}/>
  

# This function is written totally based on unit test. See comments after it.
parseTimeMenu = (path, value) ->
