@@ -13,6 +13,7 @@ import Field from 'components/Field/Field.react';
13
13
import Label from 'components/Label/Label.react' ;
14
14
import { List } from 'immutable' ;
15
15
import Option from 'components/Dropdown/Option.react' ;
16
+ import Parse from 'parse' ;
16
17
import React from 'react' ;
17
18
import ReactDOM from 'react-dom' ;
18
19
import styles from 'components/PushAudienceDialog/InstallationCondition.scss' ;
@@ -30,18 +31,34 @@ let setFocus = (input) => {
30
31
}
31
32
}
32
33
33
- function compareValue ( type , value , onChangeCompareTo ) {
34
+ function compareValue ( info , value , onChangeCompareTo ) {
35
+ let type = info . type ;
34
36
switch ( type ) {
35
37
case null :
36
38
return < div className = { styles . empty } > -</ div > ;
37
39
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 } />
39
51
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' ) } /> ;
41
53
case 'Number' :
42
54
return < TextInput placeholder = 'value' className = { styles . conditionValue } value = { value } onChange = { ( _value ) => onChangeCompareTo ( validateNumeric ( _value ) ? Number ( _value ) : Number ( value ) ) } ref = { setFocus } /> ;
43
55
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 } />
45
62
}
46
63
}
47
64
@@ -91,7 +108,7 @@ export default class InstallationCondition extends React.Component {
91
108
</ Dropdown >
92
109
</ div >
93
110
< 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 ) }
95
112
</ div >
96
113
</ div >
97
114
) ;
0 commit comments