@@ -189,6 +189,14 @@ var ConnectView = View.extend({
189189 onAuthTabClicked : function ( evt ) {
190190 this . authMethod = $ ( evt . target ) . data ( 'method' ) ;
191191 } ,
192+ createNewConnection : function ( ) {
193+ debug ( 'new connection requested' ) ;
194+ this . reset ( ) ;
195+ this . form . connection_id = '' ;
196+ this . form . reset ( ) ;
197+ this . authMethod = null ;
198+ this . authOpen = false ;
199+ } ,
192200
193201 /**
194202 * Triggers when the auth methods has changed (or set back to null)
@@ -221,21 +229,15 @@ var ConnectView = View.extend({
221229 * a list item like in `./sidebar`.
222230 *
223231 * @param {Connection } model
224- * @param {Object } [options]
225- * @option {Boolean} close - Close the connect dialog on success [Default: `false`].
226232 * @api public
227233 */
228- connect : function ( model , options ) {
229- options = _ . defaults ( options || { } , {
230- close : false
231- } ) ;
232-
234+ connect : function ( model ) {
233235 app . statusbar . show ( ) ;
234236
235237 debug ( 'testing credentials are usable...' ) ;
236238 model . test ( function ( err ) {
237239 if ( ! err ) {
238- this . onConnectionSuccessful ( model , options ) ;
240+ this . onConnectionSuccessful ( model ) ;
239241 return ;
240242 }
241243
@@ -256,7 +258,7 @@ var ConnectView = View.extend({
256258 this . onError ( new Error ( 'Could not connect to MongoDB.' ) , model ) ;
257259 return ;
258260 }
259- this . onConnectionSuccessful ( model , options ) ;
261+ this . onConnectionSuccessful ( model ) ;
260262 } . bind ( this ) ) ;
261263 } . bind ( this ) ) ;
262264 } ,
@@ -266,13 +268,12 @@ var ConnectView = View.extend({
266268 * view using it.
267269 *
268270 * @param {Connection } model
269- * @param {Object } [options]
270271 * @api private
271272 */
272- onConnectionSuccessful : function ( model , options ) {
273- options = _ . defaults ( options , {
274- close : true
275- } ) ;
273+ onConnectionSuccessful : function ( model ) {
274+ app . statusbar . hide ( ) ;
275+ this . form . connection_id = '' ;
276+
276277 /**
277278 * The save method will handle calling the correct method
278279 * of the sync being used by the model, whether that's
@@ -301,9 +302,7 @@ var ConnectView = View.extend({
301302 message : ''
302303 } ) , 500 ) ;
303304
304- if ( options . close ) {
305- setTimeout ( window . close , 1000 ) ;
306- }
305+ setTimeout ( window . close , 1000 ) ;
307306 } ,
308307 /**
309308 * If there is a validation or connection error show a nice message.
@@ -350,6 +349,7 @@ var ConnectView = View.extend({
350349
351350 if ( ! model . isValid ( ) ) {
352351 this . onError ( model . validationError ) ;
352+ return ;
353353 }
354354
355355 this . connect ( model ) ;
@@ -363,7 +363,7 @@ var ConnectView = View.extend({
363363 * @api public
364364 */
365365 onConnectionSelected : function ( model ) {
366- // If the new model has auth, expand the auth options container
366+ // If the new model has auth, expand the auth settings container
367367 // and select the correct tab.
368368 this . authMethod = model . auth_mechanism ;
369369
@@ -385,6 +385,8 @@ var ConnectView = View.extend({
385385 debug ( 'Populating form fields with keys' , keys ) ;
386386 var values = _ . pick ( model , keys ) ;
387387
388+ this . form . connection_id = model . getId ( ) ;
389+
388390 // Populates the form from values in the model.
389391 this . form . setValues ( values ) ;
390392 } ,
0 commit comments