@@ -79,6 +79,7 @@ class Browser extends DashboardView {
7979
8080 isUnique : false ,
8181 uniqueField : null ,
82+ keepAddingCols : false ,
8283 markRequiredField : false ,
8384 requiredColumnFields : [ ]
8485 } ;
@@ -117,6 +118,7 @@ class Browser extends DashboardView {
117118 this . showCreateClass = this . showCreateClass . bind ( this ) ;
118119 this . createClass = this . createClass . bind ( this ) ;
119120 this . addColumn = this . addColumn . bind ( this ) ;
121+ this . addColumnAndContinue = this . addColumnAndContinue . bind ( this ) ;
120122 this . removeColumn = this . removeColumn . bind ( this ) ;
121123 this . showNote = this . showNote . bind ( this ) ;
122124 this . showEditRowDialog = this . showEditRowDialog . bind ( this ) ;
@@ -274,6 +276,21 @@ class Browser extends DashboardView {
274276 } ) ;
275277 }
276278
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+
277294 addColumn ( { type, name, target, required, defaultValue } ) {
278295 let payload = {
279296 className : this . props . params . className ,
@@ -283,18 +300,23 @@ class Browser extends DashboardView {
283300 required,
284301 defaultValue
285302 } ;
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 } ) ;
298320 } ) ;
299321 }
300322
@@ -412,7 +434,7 @@ class Browser extends DashboardView {
412434 }
413435 this . state . counts [ obj . className ] += 1 ;
414436 }
415-
437+
416438 this . setState ( state ) ;
417439 } ,
418440 error => {
@@ -599,7 +621,7 @@ class Browser extends DashboardView {
599621 // Construct complex pagination query
600622 let equalityQuery = queryFromFilters ( source , this . state . filters ) ;
601623 let comp = this . state . data [ this . state . data . length - 1 ] . get ( field ) ;
602-
624+
603625 if ( sortDir === '-' ) {
604626 query . lessThan ( field , comp ) ;
605627 equalityQuery . lessThan ( 'objectId' , this . state . data [ this . state . data . length - 1 ] . id ) ;
@@ -719,7 +741,7 @@ class Browser extends DashboardView {
719741 } else {
720742 obj . set ( attr , value ) ;
721743 }
722-
744+
723745 if ( isNewObject ) {
724746 // for dynamically changing required placeholder text for _User class new row object
725747 if ( obj . className === '_User' && attr === 'authData' && value !== undefined ) {
@@ -739,7 +761,7 @@ class Browser extends DashboardView {
739761 if ( obj . className === '_User' && obj . get ( 'username' ) === undefined && obj . get ( 'password' ) === undefined && obj . get ( 'authData' ) === undefined ) {
740762 this . setRequiredColumnFields ( ) ;
741763 }
742-
764+
743765 this . setState ( {
744766 isNewObject : obj
745767 } ) ;
@@ -1209,6 +1231,8 @@ class Browser extends DashboardView {
12091231 if ( this . state . showCreateClassDialog ) {
12101232 extras = (
12111233 < CreateClassDialog
1234+ currentAppSlug = { this . context . currentApp . slug }
1235+ onAddColumn = { this . showAddColumn }
12121236 currentClasses = { this . props . schema . data . get ( 'classes' ) . keySeq ( ) . toArray ( ) }
12131237 onCancel = { ( ) => this . setState ( { showCreateClassDialog : false } ) }
12141238 onConfirm = { this . createClass } />
@@ -1221,10 +1245,12 @@ class Browser extends DashboardView {
12211245 } ) ;
12221246 extras = (
12231247 < AddColumnDialog
1248+ onAddColumn = { this . showAddColumn }
12241249 currentColumns = { currentColumns }
12251250 classes = { this . props . schema . data . get ( 'classes' ) . keySeq ( ) . toArray ( ) }
12261251 onCancel = { ( ) => this . setState ( { showAddColumnDialog : false } ) }
12271252 onConfirm = { this . addColumn }
1253+ onContinue = { this . addColumnAndContinue }
12281254 showNote = { this . showNote }
12291255 parseServerVersion = { currentApp . serverInfo && currentApp . serverInfo . parseServerVersion } />
12301256 ) ;
0 commit comments