@@ -96,14 +96,17 @@ export default class BrowserTable extends React.Component {
96
96
</ span >
97
97
{ this . props . order . map ( ( { name, width } , j ) => {
98
98
let type = this . props . columns [ name ] . type ;
99
- let attr = attributes [ name ] ;
100
- if ( name === 'objectId' ) {
101
- attr = obj . id ;
102
- } else if ( name === 'ACL' && this . props . className === '_User' && ! attr ) {
103
- attr = new Parse . ACL ( { '*' : { read : true } , [ obj . id ] : { read : true , write : true } } ) ;
104
- } else if ( type === 'Relation' && ! attr && obj . id ) {
105
- attr = new Parse . Relation ( obj , name ) ;
106
- attr . targetClassName = this . props . columns [ name ] . targetClass ;
99
+ let attr = obj ;
100
+ if ( ! this . props . isUnique ) {
101
+ attr = attributes [ name ] ;
102
+ if ( name === 'objectId' ) {
103
+ attr = obj . id ;
104
+ } else if ( name === 'ACL' && this . props . className === '_User' && ! attr ) {
105
+ attr = new Parse . ACL ( { '*' : { read : true } , [ obj . id ] : { read : true , write : true } } ) ;
106
+ } else if ( type === 'Relation' && ! attr && obj . id ) {
107
+ attr = new Parse . Relation ( obj , name ) ;
108
+ attr . targetClassName = this . props . columns [ name ] . targetClass ;
109
+ }
107
110
}
108
111
let current = this . props . current && this . props . current . row === row && this . props . current . col === j ;
109
112
let hidden = false ;
@@ -118,7 +121,7 @@ export default class BrowserTable extends React.Component {
118
121
< BrowserCell
119
122
key = { name }
120
123
type = { type }
121
- readonly = { READ_ONLY . indexOf ( name ) > - 1 }
124
+ readonly = { this . props . isUnique || READ_ONLY . indexOf ( name ) > - 1 }
122
125
width = { width }
123
126
current = { current }
124
127
onSelect = { ( ) => this . props . setCurrent ( { row : row , col : j } ) }
@@ -187,16 +190,21 @@ export default class BrowserTable extends React.Component {
187
190
if ( visible ) {
188
191
let { name, width } = this . props . order [ this . props . current . col ] ;
189
192
let { type, targetClass } = this . props . columns [ name ] ;
190
- let readonly = READ_ONLY . indexOf ( name ) > - 1 ;
193
+ let readonly = this . props . isUnique || READ_ONLY . indexOf ( name ) > - 1 ;
191
194
if ( name === 'sessionToken' ) {
192
195
if ( this . props . className === '_User' || this . props . className === '_Session' ) {
193
196
readonly = true ;
194
197
}
195
198
}
196
199
let obj = this . props . current . row < 0 ? this . props . newObject : this . props . data [ this . props . current . row ] ;
197
- let value = obj . get ( name ) ;
200
+ let value = obj ;
201
+ if ( ! this . props . isUnique ) {
202
+ value = obj . get ( name ) ;
203
+ }
198
204
if ( name === 'objectId' ) {
199
- value = obj . id ;
205
+ if ( ! this . props . isUnique ) {
206
+ value = obj . id ;
207
+ }
200
208
} else if ( name === 'ACL' && this . props . className === '_User' && ! value ) {
201
209
value = new Parse . ACL ( { '*' : { read : true } , [ obj . id ] : { read : true , write : true } } ) ;
202
210
} else if ( name === 'password' && this . props . className === '_User' ) {
@@ -222,27 +230,28 @@ export default class BrowserTable extends React.Component {
222
230
for ( let i = 0 ; i < this . props . current . col ; i ++ ) {
223
231
wrapLeft += this . props . order [ i ] . width ;
224
232
}
225
-
226
- editor = (
227
- < Editor
228
- top = { wrapTop }
229
- left = { wrapLeft }
230
- type = { type }
231
- targetClass = { targetClass }
232
- value = { value }
233
- readonly = { readonly }
234
- width = { width }
235
- onCommit = { ( newValue ) => {
236
- if ( newValue !== value ) {
237
- this . props . updateRow (
238
- this . props . current . row ,
239
- name ,
240
- newValue
241
- ) ;
242
- }
243
- this . props . setEditing ( false ) ;
244
- } } />
245
- ) ;
233
+ if ( ! this . props . isUnique ) {
234
+ editor = (
235
+ < Editor
236
+ top = { wrapTop }
237
+ left = { wrapLeft }
238
+ type = { type }
239
+ targetClass = { targetClass }
240
+ value = { value }
241
+ readonly = { readonly }
242
+ width = { width }
243
+ onCommit = { ( newValue ) => {
244
+ if ( newValue !== value ) {
245
+ this . props . updateRow (
246
+ this . props . current . row ,
247
+ name ,
248
+ newValue
249
+ ) ;
250
+ }
251
+ this . props . setEditing ( false ) ;
252
+ } } />
253
+ ) ;
254
+ }
246
255
}
247
256
}
248
257
@@ -264,7 +273,7 @@ export default class BrowserTable extends React.Component {
264
273
/>
265
274
</ div >
266
275
) ;
267
- } else {
276
+ } else if ( ! this . props . isUnique ) {
268
277
addRow = (
269
278
< div className = { styles . addRow } >
270
279
< a title = 'Add Row' onClick = { this . props . onAddRow } >
@@ -324,7 +333,7 @@ export default class BrowserTable extends React.Component {
324
333
selectAll = { this . props . selectRow . bind ( null , '*' ) }
325
334
headers = { headers }
326
335
updateOrdering = { this . props . updateOrdering }
327
- readonly = { ! ! this . props . relation }
336
+ readonly = { ! ! this . props . relation || ! ! this . props . isUnique }
328
337
handleDragDrop = { this . props . handleHeaderDragDrop }
329
338
onResize = { this . props . handleResize }
330
339
onAddColumn = { this . props . onAddColumn }
0 commit comments