@@ -189,6 +189,21 @@ var ConnectView = View.extend({
189
189
onAuthTabClicked : function ( evt ) {
190
190
this . authMethod = $ ( evt . target ) . data ( 'method' ) ;
191
191
} ,
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
+ } ,
200
+ onConnectionDestroyed : function ( ) {
201
+ this . reset ( ) ;
202
+ this . form . connection_id = '' ;
203
+ this . form . reset ( ) ;
204
+ this . authMethod = null ;
205
+ this . authOpen = false ;
206
+ } ,
192
207
193
208
/**
194
209
* Triggers when the auth methods has changed (or set back to null)
@@ -221,21 +236,15 @@ var ConnectView = View.extend({
221
236
* a list item like in `./sidebar`.
222
237
*
223
238
* @param {Connection } model
224
- * @param {Object } [options]
225
- * @option {Boolean} close - Close the connect dialog on success [Default: `false`].
226
239
* @api public
227
240
*/
228
- connect : function ( model , options ) {
229
- options = _ . defaults ( options || { } , {
230
- close : false
231
- } ) ;
232
-
241
+ connect : function ( model ) {
233
242
app . statusbar . show ( ) ;
234
243
235
244
debug ( 'testing credentials are usable...' ) ;
236
245
model . test ( function ( err ) {
237
246
if ( ! err ) {
238
- this . onConnectionSuccessful ( model , options ) ;
247
+ this . onConnectionSuccessful ( model ) ;
239
248
return ;
240
249
}
241
250
@@ -256,7 +265,7 @@ var ConnectView = View.extend({
256
265
this . onError ( new Error ( 'Could not connect to MongoDB.' ) , model ) ;
257
266
return ;
258
267
}
259
- this . onConnectionSuccessful ( model , options ) ;
268
+ this . onConnectionSuccessful ( model ) ;
260
269
} . bind ( this ) ) ;
261
270
} . bind ( this ) ) ;
262
271
} ,
@@ -266,13 +275,12 @@ var ConnectView = View.extend({
266
275
* view using it.
267
276
*
268
277
* @param {Connection } model
269
- * @param {Object } [options]
270
278
* @api private
271
279
*/
272
- onConnectionSuccessful : function ( model , options ) {
273
- options = _ . defaults ( options , {
274
- close : true
275
- } ) ;
280
+ onConnectionSuccessful : function ( model ) {
281
+ app . statusbar . hide ( ) ;
282
+ this . form . connection_id = '' ;
283
+
276
284
/**
277
285
* The save method will handle calling the correct method
278
286
* of the sync being used by the model, whether that's
@@ -301,9 +309,7 @@ var ConnectView = View.extend({
301
309
message : ''
302
310
} ) , 500 ) ;
303
311
304
- if ( options . close ) {
305
- setTimeout ( window . close , 1000 ) ;
306
- }
312
+ setTimeout ( window . close , 1000 ) ;
307
313
} ,
308
314
/**
309
315
* If there is a validation or connection error show a nice message.
@@ -350,6 +356,7 @@ var ConnectView = View.extend({
350
356
351
357
if ( ! model . isValid ( ) ) {
352
358
this . onError ( model . validationError ) ;
359
+ return ;
353
360
}
354
361
355
362
this . connect ( model ) ;
@@ -363,7 +370,7 @@ var ConnectView = View.extend({
363
370
* @api public
364
371
*/
365
372
onConnectionSelected : function ( model ) {
366
- // If the new model has auth, expand the auth options container
373
+ // If the new model has auth, expand the auth settings container
367
374
// and select the correct tab.
368
375
this . authMethod = model . auth_mechanism ;
369
376
@@ -385,6 +392,8 @@ var ConnectView = View.extend({
385
392
debug ( 'Populating form fields with keys' , keys ) ;
386
393
var values = _ . pick ( model , keys ) ;
387
394
395
+ this . form . connection_id = model . getId ( ) ;
396
+
388
397
// Populates the form from values in the model.
389
398
this . form . setValues ( values ) ;
390
399
} ,
0 commit comments