@@ -13,6 +13,7 @@ import Field from 'components/Field/Field.react';
1313import Label from 'components/Label/Label.react' ;
1414import { List } from 'immutable' ;
1515import Option from 'components/Dropdown/Option.react' ;
16+ import Parse from 'parse' ;
1617import React from 'react' ;
1718import ReactDOM from 'react-dom' ;
1819import styles from 'components/PushAudienceDialog/InstallationCondition.scss' ;
@@ -30,18 +31,34 @@ let setFocus = (input) => {
3031 }
3132}
3233
33- function compareValue ( type , value , onChangeCompareTo ) {
34+ function compareValue ( info , value , onChangeCompareTo ) {
35+ let type = info . type ;
3436 switch ( type ) {
3537 case null :
3638 return < div className = { styles . empty } > -</ div > ;
3739 case 'String' :
38- return < TextInput placeholder = 'value' value = { value } onChange = { ( value ) => onChangeCompareTo ( value ) } ref = { setFocus } /> ;
40+ return < TextInput placeholder = 'value' value = { value } onChange = { ( _value ) => onChangeCompareTo ( _value ) } ref = { setFocus } /> ;
41+ case 'Pointer' :
42+ return < TextInput
43+ placeholder = 'value'
44+ value = { value . objectId || '' }
45+ onChange = { ( _value ) => {
46+ let obj = new Parse . Object ( info . targetClass ) ;
47+ obj . id = _value ;
48+ onChangeCompareTo ( Parse . _encode ( obj ) ) ;
49+ } }
50+ ref = { setFocus } />
3951 case 'Boolean' :
40- return < Dropdown value = { value ? 'True' : 'False' } options = { [ 'True' , 'False' ] } onChange = { ( val ) => onChangeCompareTo ( val === 'True' ) } /> ;
52+ return < Dropdown value = { value ? 'True' : 'False' } options = { [ 'True' , 'False' ] } onChange = { ( _value ) => onChangeCompareTo ( _value === 'True' ) } /> ;
4153 case 'Number' :
4254 return < TextInput placeholder = 'value' className = { styles . conditionValue } value = { value } onChange = { ( _value ) => onChangeCompareTo ( validateNumeric ( _value ) ? Number ( _value ) : Number ( value ) ) } ref = { setFocus } /> ;
4355 case 'Date' :
44- return < DateTimeEntry fixed = { true } className = { styles . date } value = { value } onChange = { onChangeCompareTo } /> ;
56+ return < DateTimeEntry
57+ fixed = { true }
58+ className = { styles . date }
59+ value = { Parse . _decode ( 'date' , value ) }
60+ onChange = { ( _value ) => onChangeCompareTo ( Parse . _encode ( _value ) ) }
61+ ref = { setFocus } />
4562 }
4663}
4764
@@ -91,7 +108,7 @@ export default class InstallationCondition extends React.Component {
91108 </ Dropdown >
92109 </ div >
93110 < div className = { [ styles . conditionInput , styles . valueInput ] . join ( ' ' ) } >
94- { compareValue ( this . props . compareInfo . type , this . props . compareTo , this . props . onChangeCompareTo ) }
111+ { compareValue ( this . props . compareInfo , this . props . compareTo , this . props . onChangeCompareTo ) }
95112 </ div >
96113 </ div >
97114 ) ;
0 commit comments