@@ -96,14 +96,17 @@ export default class BrowserTable extends React.Component {
9696 </ span >
9797 { this . props . order . map ( ( { name, width } , j ) => {
9898 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+ }
107110 }
108111 let current = this . props . current && this . props . current . row === row && this . props . current . col === j ;
109112 let hidden = false ;
@@ -118,7 +121,7 @@ export default class BrowserTable extends React.Component {
118121 < BrowserCell
119122 key = { name }
120123 type = { type }
121- readonly = { READ_ONLY . indexOf ( name ) > - 1 }
124+ readonly = { this . props . isUnique || READ_ONLY . indexOf ( name ) > - 1 }
122125 width = { width }
123126 current = { current }
124127 onSelect = { ( ) => this . props . setCurrent ( { row : row , col : j } ) }
@@ -187,16 +190,21 @@ export default class BrowserTable extends React.Component {
187190 if ( visible ) {
188191 let { name, width } = this . props . order [ this . props . current . col ] ;
189192 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 ;
191194 if ( name === 'sessionToken' ) {
192195 if ( this . props . className === '_User' || this . props . className === '_Session' ) {
193196 readonly = true ;
194197 }
195198 }
196199 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+ }
198204 if ( name === 'objectId' ) {
199- value = obj . id ;
205+ if ( ! this . props . isUnique ) {
206+ value = obj . id ;
207+ }
200208 } else if ( name === 'ACL' && this . props . className === '_User' && ! value ) {
201209 value = new Parse . ACL ( { '*' : { read : true } , [ obj . id ] : { read : true , write : true } } ) ;
202210 } else if ( name === 'password' && this . props . className === '_User' ) {
@@ -222,27 +230,28 @@ export default class BrowserTable extends React.Component {
222230 for ( let i = 0 ; i < this . props . current . col ; i ++ ) {
223231 wrapLeft += this . props . order [ i ] . width ;
224232 }
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+ }
246255 }
247256 }
248257
@@ -264,7 +273,7 @@ export default class BrowserTable extends React.Component {
264273 />
265274 </ div >
266275 ) ;
267- } else {
276+ } else if ( ! this . props . isUnique ) {
268277 addRow = (
269278 < div className = { styles . addRow } >
270279 < a title = 'Add Row' onClick = { this . props . onAddRow } >
@@ -324,7 +333,7 @@ export default class BrowserTable extends React.Component {
324333 selectAll = { this . props . selectRow . bind ( null , '*' ) }
325334 headers = { headers }
326335 updateOrdering = { this . props . updateOrdering }
327- readonly = { ! ! this . props . relation }
336+ readonly = { ! ! this . props . relation || ! ! this . props . isUnique }
328337 handleDragDrop = { this . props . handleHeaderDragDrop }
329338 onResize = { this . props . handleResize }
330339 onAddColumn = { this . props . onAddColumn }
0 commit comments