@@ -78,7 +78,7 @@ export default class BrowserTable extends React.Component {
78
78
} ) ;
79
79
}
80
80
81
- renderRow ( { row, obj, rowWidth } ) {
81
+ renderRow ( { row, obj, json , rowWidth } ) {
82
82
let attributes = obj . attributes ;
83
83
let index = row - this . state . offset ;
84
84
return (
@@ -101,6 +101,12 @@ export default class BrowserTable extends React.Component {
101
101
} else if ( type === 'Relation' && ! attr && obj . id ) {
102
102
attr = new Parse . Relation ( obj , name ) ;
103
103
attr . targetClassName = this . props . columns [ name ] . targetClass ;
104
+ } else if ( type === 'Array' || type === 'Object' ) {
105
+ // This is needed to avoid unwanted conversions of objects to Parse.Objects.
106
+ // When retrieving data from JSON, Parse-SDK will not try to convert any data.
107
+ // Since array and object are generic types, we want to render them the way
108
+ // they were stored in the database.
109
+ attr = json [ name ] ;
104
110
}
105
111
}
106
112
let current = this . props . current && this . props . current . row === row && this . props . current . col === j ;
@@ -161,7 +167,7 @@ export default class BrowserTable extends React.Component {
161
167
if ( this . props . newObject && this . state . offset <= 0 ) {
162
168
newRow = (
163
169
< div style = { { marginBottom : 30 , borderBottom : '1px solid #169CEE' } } >
164
- { this . renderRow ( { row : - 1 , obj : this . props . newObject , rowWidth : rowWidth } ) }
170
+ { this . renderRow ( { row : - 1 , obj : this . props . newObject , json : { } , rowWidth : rowWidth } ) }
165
171
</ div >
166
172
) ;
167
173
}
@@ -170,7 +176,7 @@ export default class BrowserTable extends React.Component {
170
176
for ( let i = this . state . offset ; i < end ; i ++ ) {
171
177
let index = i - this . state . offset ;
172
178
let obj = this . props . data [ i ] ;
173
- rows [ index ] = this . renderRow ( { row : i , obj : obj , rowWidth : rowWidth } ) ;
179
+ rows [ index ] = this . renderRow ( { row : i , obj, json : obj . toJSON ( ) , rowWidth : rowWidth } ) ;
174
180
}
175
181
176
182
if ( this . props . editing ) {
@@ -193,8 +199,20 @@ export default class BrowserTable extends React.Component {
193
199
}
194
200
let obj = this . props . current . row < 0 ? this . props . newObject : this . props . data [ this . props . current . row ] ;
195
201
let value = obj ;
202
+ let json = obj . toJSON ( ) ;
196
203
if ( ! this . props . isUnique ) {
197
- value = obj . get ( name ) ;
204
+ if ( type === 'Array' || type === 'Object' ) {
205
+ if ( ! json ) {
206
+ json = obj . toJSON ( ) ;
207
+ }
208
+ // This is needed to avoid unwanted conversions of objects to Parse.Objects.
209
+ // When retrieving data from JSON, Parse-SDK will not try to convert any data.
210
+ // Since array and object are generic types, we want to edit them the way
211
+ // they were stored in the database.
212
+ value = json [ name ] ;
213
+ } else {
214
+ value = obj . get ( name ) ;
215
+ }
198
216
}
199
217
if ( name === 'objectId' ) {
200
218
if ( ! this . props . isUnique ) {
@@ -204,18 +222,6 @@ export default class BrowserTable extends React.Component {
204
222
value = new Parse . ACL ( { '*' : { read : true } , [ obj . id ] : { read : true , write : true } } ) ;
205
223
} else if ( name === 'password' && this . props . className === '_User' ) {
206
224
value = '' ;
207
- } else if ( type === 'Array' ) {
208
- if ( value ) {
209
- value = value . map ( val => {
210
- if ( val instanceof Parse . Object ) {
211
- return val . toPointer ( ) ;
212
- } else if ( val && typeof val . getMonth === 'function' ) {
213
- return { __type : "Date" , iso : val . toISOString ( ) } ;
214
- }
215
-
216
- return val ;
217
- } ) ;
218
- }
219
225
}
220
226
let wrapTop = Math . max ( 0 , this . props . current . row * ROW_HEIGHT ) ;
221
227
if ( this . props . current . row > - 1 && this . props . newObject ) {
0 commit comments