@@ -79,6 +79,7 @@ class Browser extends DashboardView {
79
79
80
80
isUnique : false ,
81
81
uniqueField : null ,
82
+ keepAddingCols : false ,
82
83
markRequiredField : false ,
83
84
requiredColumnFields : [ ]
84
85
} ;
@@ -117,6 +118,7 @@ class Browser extends DashboardView {
117
118
this . showCreateClass = this . showCreateClass . bind ( this ) ;
118
119
this . createClass = this . createClass . bind ( this ) ;
119
120
this . addColumn = this . addColumn . bind ( this ) ;
121
+ this . addColumnAndContinue = this . addColumnAndContinue . bind ( this ) ;
120
122
this . removeColumn = this . removeColumn . bind ( this ) ;
121
123
this . showNote = this . showNote . bind ( this ) ;
122
124
this . showEditRowDialog = this . showEditRowDialog . bind ( this ) ;
@@ -274,6 +276,21 @@ class Browser extends DashboardView {
274
276
} ) ;
275
277
}
276
278
279
+ newColumn ( payload , required ) {
280
+ return this . props . schema . dispatch ( ActionTypes . ADD_COLUMN , payload )
281
+ . then ( ( ) => {
282
+ if ( required ) {
283
+ let requiredCols = [ ...this . state . requiredColumnFields , name ] ;
284
+ this . setState ( {
285
+ requiredColumnFields : requiredCols
286
+ } ) ;
287
+ }
288
+ } )
289
+ . catch ( ( err ) => {
290
+ this . showNote ( err . message , true ) ;
291
+ } ) ;
292
+ }
293
+
277
294
addColumn ( { type, name, target, required, defaultValue } ) {
278
295
let payload = {
279
296
className : this . props . params . className ,
@@ -283,18 +300,23 @@ class Browser extends DashboardView {
283
300
required,
284
301
defaultValue
285
302
} ;
286
- this . props . schema . dispatch ( ActionTypes . ADD_COLUMN , payload ) . then ( ( ) => {
287
- // if new required field column is added, then add field in requiredColumn
288
- if ( required ) {
289
- let requiredCols = [ ...this . state . requiredColumnFields , name ] ;
290
- this . setState ( {
291
- requiredColumnFields : requiredCols
292
- } ) ;
293
- }
294
- } ) . catch ( ( err ) => {
295
- this . showNote ( err . message , true ) ;
296
- } ) . finally ( ( ) => {
297
- this . setState ( { showAddColumnDialog : false } ) ;
303
+ this . newColumn ( payload , required ) . finally ( ( ) => {
304
+ this . setState ( { showAddColumnDialog : false , keepAddingCols : false } ) ;
305
+ } ) ;
306
+ }
307
+
308
+ addColumnAndContinue ( { type, name, target, required, defaultValue } ) {
309
+ let payload = {
310
+ className : this . props . params . className ,
311
+ columnType : type ,
312
+ name : name ,
313
+ targetClass : target ,
314
+ required,
315
+ defaultValue
316
+ } ;
317
+ this . newColumn ( payload , required ) . finally ( ( ) => {
318
+ this . setState ( { showAddColumnDialog : false , keepAddingCols : false } ) ;
319
+ this . setState ( { showAddColumnDialog : true , keepAddingCols : true } ) ;
298
320
} ) ;
299
321
}
300
322
@@ -412,7 +434,7 @@ class Browser extends DashboardView {
412
434
}
413
435
this . state . counts [ obj . className ] += 1 ;
414
436
}
415
-
437
+
416
438
this . setState ( state ) ;
417
439
} ,
418
440
error => {
@@ -599,7 +621,7 @@ class Browser extends DashboardView {
599
621
// Construct complex pagination query
600
622
let equalityQuery = queryFromFilters ( source , this . state . filters ) ;
601
623
let comp = this . state . data [ this . state . data . length - 1 ] . get ( field ) ;
602
-
624
+
603
625
if ( sortDir === '-' ) {
604
626
query . lessThan ( field , comp ) ;
605
627
equalityQuery . lessThan ( 'objectId' , this . state . data [ this . state . data . length - 1 ] . id ) ;
@@ -719,7 +741,7 @@ class Browser extends DashboardView {
719
741
} else {
720
742
obj . set ( attr , value ) ;
721
743
}
722
-
744
+
723
745
if ( isNewObject ) {
724
746
// for dynamically changing required placeholder text for _User class new row object
725
747
if ( obj . className === '_User' && attr === 'authData' && value !== undefined ) {
@@ -739,7 +761,7 @@ class Browser extends DashboardView {
739
761
if ( obj . className === '_User' && obj . get ( 'username' ) === undefined && obj . get ( 'password' ) === undefined && obj . get ( 'authData' ) === undefined ) {
740
762
this . setRequiredColumnFields ( ) ;
741
763
}
742
-
764
+
743
765
this . setState ( {
744
766
isNewObject : obj
745
767
} ) ;
@@ -1209,6 +1231,8 @@ class Browser extends DashboardView {
1209
1231
if ( this . state . showCreateClassDialog ) {
1210
1232
extras = (
1211
1233
< CreateClassDialog
1234
+ currentAppSlug = { this . context . currentApp . slug }
1235
+ onAddColumn = { this . showAddColumn }
1212
1236
currentClasses = { this . props . schema . data . get ( 'classes' ) . keySeq ( ) . toArray ( ) }
1213
1237
onCancel = { ( ) => this . setState ( { showCreateClassDialog : false } ) }
1214
1238
onConfirm = { this . createClass } />
@@ -1221,10 +1245,12 @@ class Browser extends DashboardView {
1221
1245
} ) ;
1222
1246
extras = (
1223
1247
< AddColumnDialog
1248
+ onAddColumn = { this . showAddColumn }
1224
1249
currentColumns = { currentColumns }
1225
1250
classes = { this . props . schema . data . get ( 'classes' ) . keySeq ( ) . toArray ( ) }
1226
1251
onCancel = { ( ) => this . setState ( { showAddColumnDialog : false } ) }
1227
1252
onConfirm = { this . addColumn }
1253
+ onContinue = { this . addColumnAndContinue }
1228
1254
showNote = { this . showNote }
1229
1255
parseServerVersion = { currentApp . serverInfo && currentApp . serverInfo . parseServerVersion } />
1230
1256
) ;
0 commit comments