Merge branch 'gilbert' into gilbert-1.3
authorStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 7 Apr 2011 17:14:35 +0000 (13:14 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 7 Apr 2011 17:14:35 +0000 (13:14 -0400)
1  2 
contrib/gilbert/static/gilbert/plugins/models.js

@@@ -418,11 -418,13 +418,13 @@@ Gilbert.lib.plugins.models.Plugin = Ext
        },
        
        create_instance_window: function (model, pk, callback, config, cls) {
-               var win = this.instance_windows[[model.app_label, model.name, pk]];
-               if (win != undefined){
-                       win.show()
-                       return
-               }
+               if (pk != undefined) {
+                       var win = this.instance_windows[[model.app_label, model.name, pk]];
+                       if (win != undefined){
+                               win.show();
+                               return;
+                       };
+               };
                var pk = pk;
                var callback = callback;
                var application = this.application;
                
                var form_callback = function (form) {
                        var oldform = form;
-                       var win = outer.instance_windows[[model.app_label, model.name, pk]] = application.create_window({
+                       var win = application.create_window({
                                layout: 'fit',
                                title: form.title,
                                iconCls: form.iconCls,
                                        },
                                ],
                        });
-                       win.on('close', function(){
-                               delete outer.instance_windows[[model.app_label, model.name, pk]];
-                       });
+                       if (pk != undefined) {
+                               outer.instance_windows[[model.app_label, model.name, pk]] = win
+                               win.on('close', function(){
+                                       delete outer.instance_windows[[model.app_label, model.name, pk]];
+                               });
+                       }
                        win.addEvents({
                                'saved': true,
                        });