public inbox for [email protected]  
help / color / mirror / Atom feed
Dialogues not closing
7+ messages / 2 participants
[nested] [flat]

* Dialogues not closing
@ 2016-04-14 20:53 Dave Page <[email protected]>
  2016-04-15 05:32 ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  0 siblings, 1 reply; 7+ messages in thread

From: Dave Page @ 2016-04-14 20:53 UTC (permalink / raw)
  To: Ashesh Vashi <[email protected]>; +Cc: pgadmin-hackers

Hey Ashesh,

We have an issue with dialogues not closing on Save button presses.
One of the team told me yesterday or the day before that it's a
general issue, not one specific to the patch I was reviewing at the
time, which I've been finding seems to be the case.

Any idea what this issue is?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Dialogues not closing
  2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
@ 2016-04-15 05:32 ` Ashesh Vashi <[email protected]>
  2016-04-15 07:50   ` Re: Dialogues not closing Dave Page <[email protected]>
  0 siblings, 1 reply; 7+ messages in thread

From: Ashesh Vashi @ 2016-04-15 05:32 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

On Fri, Apr 15, 2016 at 2:23 AM, Dave Page <[email protected]> wrote:

> Hey Ashesh,
>
> We have an issue with dialogues not closing on Save button presses.
> One of the team told me yesterday or the day before that it's a
> general issue, not one specific to the patch I was reviewing at the
> time, which I've been finding seems to be the case.
>
> Any idea what this issue is?
>
Sure - I will look into it.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com/;


*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi;

>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Dialogues not closing
  2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
  2016-04-15 05:32 ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
@ 2016-04-15 07:50   ` Dave Page <[email protected]>
  2016-04-15 08:06     ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  0 siblings, 1 reply; 7+ messages in thread

From: Dave Page @ 2016-04-15 07:50 UTC (permalink / raw)
  To: Ashesh Vashi <[email protected]>; +Cc: pgadmin-hackers

On Fri, Apr 15, 2016 at 6:32 AM, Ashesh Vashi <[email protected]
> wrote:

> On Fri, Apr 15, 2016 at 2:23 AM, Dave Page <[email protected]> wrote:
>
>> Hey Ashesh,
>>
>> We have an issue with dialogues not closing on Save button presses.
>> One of the team told me yesterday or the day before that it's a
>> general issue, not one specific to the patch I was reviewing at the
>> time, which I've been finding seems to be the case.
>>
>> Any idea what this issue is?
>>
> Sure - I will look into it.
>

Thanks - please make it a priority; I'm at PG Conf NYC next week and expect
to be doing lots of demos.


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Dialogues not closing
  2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
  2016-04-15 05:32 ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 07:50   ` Re: Dialogues not closing Dave Page <[email protected]>
@ 2016-04-15 08:06     ` Ashesh Vashi <[email protected]>
  2016-04-15 10:48       ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  0 siblings, 1 reply; 7+ messages in thread

From: Ashesh Vashi @ 2016-04-15 08:06 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Hi Dave,


On Fri, Apr 15, 2016 at 1:20 PM, Dave Page <[email protected]> wrote:

>
>
> On Fri, Apr 15, 2016 at 6:32 AM, Ashesh Vashi <
> [email protected]> wrote:
>
>> On Fri, Apr 15, 2016 at 2:23 AM, Dave Page <[email protected]> wrote:
>>
>>> Hey Ashesh,
>>>
>>> We have an issue with dialogues not closing on Save button presses.
>>> One of the team told me yesterday or the day before that it's a
>>> general issue, not one specific to the patch I was reviewing at the
>>> time, which I've been finding seems to be the case.
>>>
>>> Any idea what this issue is?
>>>
>> Sure - I will look into it.
>>
>
> Thanks - please make it a priority; I'm at PG Conf NYC next week and
> expect to be doing lots of demos.
>
Please find the patch for the same.

This also includes some of the cleanup required to solve some of the memory
leak issues.

I was not able to reproduce the issue at my end, but - I've idea of when it
could fail to close the panel, which I have resolved in this patch.
Can you please test it?

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com/;


*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi;


>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] dialog_close_n_memory_leak.patch (12.1K, 3-dialog_close_n_memory_leak.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/static/js/datamodel.js b/web/pgadmin/browser/static/js/datamodel.js
index b28e041..6eb3ae5 100644
--- a/web/pgadmin/browser/static/js/datamodel.js
+++ b/web/pgadmin/browser/static/js/datamodel.js
@@ -199,6 +199,36 @@ function(_, pgAdmin, $, Backbone) {
 
         return self;
       },
+      // Create a reset function, which allow us to remove the nested object.
+      reset: function() {
+        var obj;
+        for(id in this.objects) {
+          obj = this.get(id);
+
+          if (obj) {
+            if (obj instanceof pgBrowser.DataModel) {
+              obj.reset();
+              delete obj;
+            } else if (obj instanceof Backbone.Model) {
+              obj.clear({silent: true});
+              delete obj;
+            } else if (obj instanceof pgBrowser.DataCollection) {
+              obj.reset({silent: true});
+              delete obj;
+            } else if (obj instanceof Backbone.Collection) {
+              obj.each(function(m) {
+                if (m instanceof Bakbone.DataModel) {
+                  obj.reset();
+                  obj.clear({silent: true});
+                }
+              });
+              Backbone.Collection.prototype.reset.apply(obj, {silent: true});
+              delete obj;
+            }
+          }
+        }
+        this.clear({silent: true});
+      },
       sessChanged: function() {
         var self = this;
 
@@ -755,6 +785,20 @@ function(_, pgAdmin, $, Backbone) {
           return (_.size(res) == 0 ? null : res);
         }
       },
+      // Override the reset function, so that - we can reset the model
+      // properly.
+      reset: function(opts) {
+        this.each(function(m) {
+          if (!m)
+            return;
+          if (m instanceof pgBrowser.DataModel) {
+            m.reset();
+          } else {
+            m.clear({silent: true});
+          }
+        });
+        Backbone.Collection.prototype.reset.apply(this, arguments);
+      },
       objFindInSession: function(m, type) {
         var hasPrimaryKey = m.primary_key &&
               typeof(m.primary_key) == 'function',
diff --git a/web/pgadmin/browser/templates/browser/js/collection.js b/web/pgadmin/browser/templates/browser/js/collection.js
index fb1dd42..cb9b650 100644
--- a/web/pgadmin/browser/templates/browser/js/collection.js
+++ b/web/pgadmin/browser/templates/browser/js/collection.js
@@ -67,16 +67,20 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) {
         gridView = {
           'remove': function() {
             if (this.grid) {
+              if (this.grid.collection) {
+                this.grid.collection.reset(null, {silent: true});
+                delete (this.grid.collection);
+              }
               delete (this.grid);
               this.grid = null;
             }
-          }
+          },
+          grid: grid
         };
-        gridView.grid = grid;
 
       if (view) {
         // Release the view
-        view.remove();
+        view.remove({data: true});
         // Deallocate the view
         delete view;
         view = null;
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index 54ddfb8..9b43e4f 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -652,7 +652,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
           // creating new view.
           if (view) {
             // Release the view
-            view.remove();
+            view.remove({data: true});
             // Deallocate the view
             delete view;
             view = null;
@@ -773,7 +773,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
           // creating the new view.
           if (view) {
             // Release the view
-            view.remove();
+            view.remove({data: true});
             // Deallocate the view
             delete view;
             view = null;
@@ -907,8 +907,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
         }.bind(panel),
         closePanel = function() {
           // Closing this panel
-          this.close()
-        },
+          this.close();
+        }.bind(panel),
         updateTreeItem = function() {
           var panel = this;
 
@@ -940,9 +940,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
           if (view.model.tnode && '_id' in view.model.tnode) {
             var d = _.extend({}, view.model.tnode),
               func = function(i) {
-                setTimeout(function() {
-                  closePanel();
-                }, 0);
+                setTimeout(function() {closePanel();}, 0);
                 if (i) {
                   tree.select(i, {focus: true});
                 }
@@ -962,6 +960,11 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                     itemData: d,
                     success: function(i, o) {
                       func(o.items.eq(0));
+                    },
+                    fail: function() {
+                      // We still want to close the panel
+                      console.log(arguments);
+                      func(null);
                     }
                   });
                   return;
@@ -1017,7 +1020,9 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                                 func(null);
                               },
                               fail: function() {
+                                // We would still like to close it.
                                 console.log(arguments);
+                                func(null);
                               }
                             });
                           }
@@ -1052,13 +1057,17 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                         func(i);
                       },
                       fail: function() {
+                        // We would still like to close it.
                         console.log(arguments);
+                        func(null);
                       }
                     });
 
                   },
                   fail: function() {
+                    // We would still like to close it.
                     console.log(arguments);
+                    func(null);
                   }
                 });
               }
@@ -1067,53 +1076,60 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                 itemData: d,
                 success: function(i, o) {
                   func(i);
+                },
+                fail: function() {
+                  // We would still like to close it.
+                  console.log(arguments);
+                  func(null);
                 }
               });
             }
           } else {
-          /*
-           * Sometime we don't get node in response even though it's saved
-           * on server. In such case just reload the collection to get newly
-           * created nodes.
-           */
-
-           var children = tree.children(item, false, false),
-            openNode = function(item, animation){
-              tree.open(item, {
-                success: function (item, options){
-                  setTimeout(function() {
-                    closePanel();
-                  }, 0);
-                },
-                fail: function (item, options){
-                },
-                unanimated: animation
-              });
-            };
+            /*
+             * Sometime we don't get node in response even though it's saved
+             * on server. In such case just reload the collection to get newly
+             * created nodes.
+             */
+
+            var children = tree.children(item, false, false),
+                openNode = function(item, animation){
+                  tree.open(item, {
+                    success: function (item, options){
+                      setTimeout(function() {closePanel();}, 0);
+                    },
+                    fail: function (item, options){
+                      setTimeout(function() {closePanel();}, 0);
+                    },
+                    unanimated: animation
+                  });
+                };
 
             if (children) {
               _.each(children, function(child) {
-                var $child = $(child);
-                var data = tree.itemData($child)
-                  if (data._type == that.collection_type){
-                    // We found collection which need to reload.
-                    if (tree.wasLoad($child)) {
-                      tree.unload($child, {
-                        success: function (item, options){
-                          openNode(item, true);
-                        },
-                        fail: function (item, options){
-                        },
-                        unanimated: true
-                      });
-                    } else {
-                      openNode($child, false);
-                    }
+                var $child = $(child),
+                    data = tree.itemData($child);
+                if (data._type == that.collection_type){
+                  // We found collection which need to reload.
+                  if (tree.wasLoad($child)) {
+                    tree.unload($child, {
+                      success: function (item, options){
+                        openNode(item, true);
+                      },
+                      fail: function (item, options){
+                        setTimeout(function() {closePanel();}, 0);
+                      },
+                      unanimated: true
+                    });
+                  } else {
+                    openNode($child, false);
                   }
+                }
               });
+              return;
             }
+            setTimeout(function() {closePanel();}, 0);
           }
-        },
+        }.bind(panel),
         editInNewPanel = function() {
           // Open edit in separate panel
           setTimeout(function() {
@@ -1123,14 +1139,14 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
             }]);
           }, 0);
         },
-        onCancelFunc = closePanel.bind(panel),
+        onCancelFunc = closePanel,
         onSaveFunc = updateTreeItem.bind(panel),
         onEdit = editFunc.bind(panel);
 
       if (action) {
         if (action == 'create'){
-          onCancelFunc = closePanel.bind(panel);
-          onSaveFunc = saveNewNode.bind(panel);
+          onCancelFunc = closePanel;
+          onSaveFunc = saveNewNode;
         }
         if (action != 'properties') {
           // We need to keep track edit/create mode for this panel.
@@ -1143,6 +1159,17 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
         properties();
         onEdit = editInNewPanel.bind(panel);
       }
+      if (panel.closeable()) {
+        var onCloseFunc = function() {
+          var j = this.$container.find('.obj_properties').first(),
+              view = j && j.data('obj-view');
+
+          if (view) {
+            view.remove({data: true});
+          }
+        }.bind(panel);
+        panel.on(wcDocker.EVENT.CLOSED, onCloseFunc);
+      }
     },
     /**********************************************************************
      * Generate the URL for different operations
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 2f5ac15..580573c 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -594,6 +594,23 @@
       }
 
       return this;
+    },
+    remove: function(opts) {
+      if (opts && opts.data) {
+        if (this.model) {
+          if (this.model.reset) {
+            this.model.reset();
+          }
+          this.model.clear({silent: true});
+          delete (this.model);
+        }
+        if (this.errorModel) {
+          this.errorModel.clear({silent: true});
+          delete (this.errorModel);
+        }
+      }
+      this.cleanup();
+      Backform.Form.prototype.remove.apply(this, arguments);
     }
   });
 


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Dialogues not closing
  2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
  2016-04-15 05:32 ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 07:50   ` Re: Dialogues not closing Dave Page <[email protected]>
  2016-04-15 08:06     ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
@ 2016-04-15 10:48       ` Ashesh Vashi <[email protected]>
  2016-04-15 10:48         ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  0 siblings, 1 reply; 7+ messages in thread

From: Ashesh Vashi @ 2016-04-15 10:48 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Hi Dave,

I was able to reproduce the issue with the help of Murtuza.
I missed one corner case - it was not able to close the dialog, when the
parent/collection has not yet been loaded.

Please find the updated patch.
This patch only includes the dialog issue.
Please let me know - if you still see the issue.

I've committed the patch about the objects (model/collection/views) release.


--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com;


*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi;

On Fri, Apr 15, 2016 at 1:36 PM, Ashesh Vashi <[email protected]
> wrote:

> Hi Dave,
>
>
> On Fri, Apr 15, 2016 at 1:20 PM, Dave Page <[email protected]> wrote:
>
>>
>>
>> On Fri, Apr 15, 2016 at 6:32 AM, Ashesh Vashi <
>> [email protected]> wrote:
>>
>>> On Fri, Apr 15, 2016 at 2:23 AM, Dave Page <[email protected]> wrote:
>>>
>>>> Hey Ashesh,
>>>>
>>>> We have an issue with dialogues not closing on Save button presses.
>>>> One of the team told me yesterday or the day before that it's a
>>>> general issue, not one specific to the patch I was reviewing at the
>>>> time, which I've been finding seems to be the case.
>>>>
>>>> Any idea what this issue is?
>>>>
>>> Sure - I will look into it.
>>>
>>
>> Thanks - please make it a priority; I'm at PG Conf NYC next week and
>> expect to be doing lots of demos.
>>
> Please find the patch for the same.
>
> This also includes some of the cleanup required to solve some of the
> memory leak issues.
>
> I was not able to reproduce the issue at my end, but - I've idea of when
> it could fail to close the panel, which I have resolved in this patch.
> Can you please test it?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/;
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi;
>
>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Dialogues not closing
  2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
  2016-04-15 05:32 ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 07:50   ` Re: Dialogues not closing Dave Page <[email protected]>
  2016-04-15 08:06     ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 10:48       ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
@ 2016-04-15 10:48         ` Ashesh Vashi <[email protected]>
  2016-04-15 13:02           ` Re: Dialogues not closing Dave Page <[email protected]>
  0 siblings, 1 reply; 7+ messages in thread

From: Ashesh Vashi @ 2016-04-15 10:48 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Oops.. clicked before attaching...


--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com;


*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi;

On Fri, Apr 15, 2016 at 4:18 PM, Ashesh Vashi <[email protected]
> wrote:

> Hi Dave,
>
> I was able to reproduce the issue with the help of Murtuza.
> I missed one corner case - it was not able to close the dialog, when the
> parent/collection has not yet been loaded.
>
> Please find the updated patch.
> This patch only includes the dialog issue.
> Please let me know - if you still see the issue.
>
> I've committed the patch about the objects (model/collection/views)
> release.
>
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com;
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi;
>
> On Fri, Apr 15, 2016 at 1:36 PM, Ashesh Vashi <
> [email protected]> wrote:
>
>> Hi Dave,
>>
>>
>> On Fri, Apr 15, 2016 at 1:20 PM, Dave Page <[email protected]> wrote:
>>
>>>
>>>
>>> On Fri, Apr 15, 2016 at 6:32 AM, Ashesh Vashi <
>>> [email protected]> wrote:
>>>
>>>> On Fri, Apr 15, 2016 at 2:23 AM, Dave Page <[email protected]> wrote:
>>>>
>>>>> Hey Ashesh,
>>>>>
>>>>> We have an issue with dialogues not closing on Save button presses.
>>>>> One of the team told me yesterday or the day before that it's a
>>>>> general issue, not one specific to the patch I was reviewing at the
>>>>> time, which I've been finding seems to be the case.
>>>>>
>>>>> Any idea what this issue is?
>>>>>
>>>> Sure - I will look into it.
>>>>
>>>
>>> Thanks - please make it a priority; I'm at PG Conf NYC next week and
>>> expect to be doing lots of demos.
>>>
>> Please find the patch for the same.
>>
>> This also includes some of the cleanup required to solve some of the
>> memory leak issues.
>>
>> I was not able to reproduce the issue at my end, but - I've idea of when
>> it could fail to close the panel, which I have resolved in this patch.
>> Can you please test it?
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com/;
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi;
>>
>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] dialog_close_v2.patch (7.0K, 3-dialog_close_v2.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index a38bda2..3e149d3 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -907,8 +907,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
         }.bind(panel),
         closePanel = function() {
           // Closing this panel
-          this.close()
-        },
+          this.close();
+        }.bind(panel),
         updateTreeItem = function() {
           var panel = this;
 
@@ -940,9 +940,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
           if (view.model.tnode && '_id' in view.model.tnode) {
             var d = _.extend({}, view.model.tnode),
               func = function(i) {
-                setTimeout(function() {
-                  closePanel();
-                }, 0);
+                setTimeout(function() {closePanel();}, 0);
                 if (i) {
                   tree.select(i, {focus: true});
                 }
@@ -962,6 +960,11 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                     itemData: d,
                     success: function(i, o) {
                       func(o.items.eq(0));
+                    },
+                    fail: function() {
+                      // We still want to close the panel
+                      console.log(arguments);
+                      func(null);
                     }
                   });
                   return;
@@ -1017,7 +1020,9 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                                 func(null);
                               },
                               fail: function() {
+                                // We would still like to close it.
                                 console.log(arguments);
+                                func(null);
                               }
                             });
                           }
@@ -1052,68 +1057,81 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                         func(i);
                       },
                       fail: function() {
+                        // We would still like to close it.
                         console.log(arguments);
+                        func(null);
                       }
                     });
 
                   },
                   fail: function() {
+                    // We would still like to close it.
                     console.log(arguments);
+                    func(null);
                   }
                 });
+              } else {
+                func(null);
               }
             } else {
               tree.append(null, {
                 itemData: d,
                 success: function(i, o) {
                   func(i);
+                },
+                fail: function() {
+                  // We would still like to close it.
+                  console.log(arguments);
+                  func(null);
                 }
               });
             }
           } else {
-          /*
-           * Sometime we don't get node in response even though it's saved
-           * on server. In such case just reload the collection to get newly
-           * created nodes.
-           */
-
-           var children = tree.children(item, false, false),
-            openNode = function(item, animation){
-              tree.open(item, {
-                success: function (item, options){
-                  setTimeout(function() {
-                    closePanel();
-                  }, 0);
-                },
-                fail: function (item, options){
-                },
-                unanimated: animation
-              });
-            };
+            /*
+             * Sometime we don't get node in response even though it's saved
+             * on server. In such case just reload the collection to get newly
+             * created nodes.
+             */
+
+            var children = tree.children(item, false, false),
+                openNode = function(item, animation){
+                  tree.open(item, {
+                    success: function (item, options){
+                      setTimeout(function() {closePanel();}, 0);
+                    },
+                    fail: function (item, options){
+                      setTimeout(function() {closePanel();}, 0);
+                    },
+                    unanimated: animation
+                  });
+                };
 
             if (children) {
               _.each(children, function(child) {
-                var $child = $(child);
-                var data = tree.itemData($child)
-                  if (data._type == that.collection_type){
-                    // We found collection which need to reload.
-                    if (tree.wasLoad($child)) {
-                      tree.unload($child, {
-                        success: function (item, options){
-                          openNode(item, true);
-                        },
-                        fail: function (item, options){
-                        },
-                        unanimated: true
-                      });
-                    } else {
-                      openNode($child, false);
-                    }
+                var $child = $(child),
+                    data = tree.itemData($child);
+                if (data._type == that.collection_type){
+                  // We found collection which need to reload.
+                  if (tree.wasLoad($child)) {
+                    tree.unload($child, {
+                      success: function (item, options){
+                        openNode(item, true);
+                      },
+                      fail: function (item, options){
+                        setTimeout(function() {closePanel();}, 0);
+                      },
+                      unanimated: true
+                    });
+                  } else {
+                    openNode($child, false);
                   }
+                }
               });
+              return;
             }
+            setTimeout(function() {closePanel();}, 0);
           }
-        },
+        }.bind(panel),
         editInNewPanel = function() {
           // Open edit in separate panel
           setTimeout(function() {
@@ -1123,14 +1141,14 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
             }]);
           }, 0);
         },
-        onCancelFunc = closePanel.bind(panel),
+        onCancelFunc = closePanel,
         onSaveFunc = updateTreeItem.bind(panel),
         onEdit = editFunc.bind(panel);
 
       if (action) {
         if (action == 'create'){
-          onCancelFunc = closePanel.bind(panel);
-          onSaveFunc = saveNewNode.bind(panel);
+          onCancelFunc = closePanel;
+          onSaveFunc = saveNewNode;
         }
         if (action != 'properties') {
           // We need to keep track edit/create mode for this panel.


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Dialogues not closing
  2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
  2016-04-15 05:32 ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 07:50   ` Re: Dialogues not closing Dave Page <[email protected]>
  2016-04-15 08:06     ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 10:48       ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
  2016-04-15 10:48         ` Re: Dialogues not closing Ashesh Vashi <[email protected]>
@ 2016-04-15 13:02           ` Dave Page <[email protected]>
  0 siblings, 0 replies; 7+ messages in thread

From: Dave Page @ 2016-04-15 13:02 UTC (permalink / raw)
  To: Ashesh Vashi <[email protected]>; +Cc: pgadmin-hackers

That seems to have got it - thanks!

On Fri, Apr 15, 2016 at 11:48 AM, Ashesh Vashi <
[email protected]> wrote:

> Oops.. clicked before attaching...
>
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com;
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi;
>
> On Fri, Apr 15, 2016 at 4:18 PM, Ashesh Vashi <
> [email protected]> wrote:
>
>> Hi Dave,
>>
>> I was able to reproduce the issue with the help of Murtuza.
>> I missed one corner case - it was not able to close the dialog, when the
>> parent/collection has not yet been loaded.
>>
>> Please find the updated patch.
>> This patch only includes the dialog issue.
>> Please let me know - if you still see the issue.
>>
>> I've committed the patch about the objects (model/collection/views)
>> release.
>>
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com;
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi;
>>
>> On Fri, Apr 15, 2016 at 1:36 PM, Ashesh Vashi <
>> [email protected]> wrote:
>>
>>> Hi Dave,
>>>
>>>
>>> On Fri, Apr 15, 2016 at 1:20 PM, Dave Page <[email protected]> wrote:
>>>
>>>>
>>>>
>>>> On Fri, Apr 15, 2016 at 6:32 AM, Ashesh Vashi <
>>>> [email protected]> wrote:
>>>>
>>>>> On Fri, Apr 15, 2016 at 2:23 AM, Dave Page <[email protected]> wrote:
>>>>>
>>>>>> Hey Ashesh,
>>>>>>
>>>>>> We have an issue with dialogues not closing on Save button presses.
>>>>>> One of the team told me yesterday or the day before that it's a
>>>>>> general issue, not one specific to the patch I was reviewing at the
>>>>>> time, which I've been finding seems to be the case.
>>>>>>
>>>>>> Any idea what this issue is?
>>>>>>
>>>>> Sure - I will look into it.
>>>>>
>>>>
>>>> Thanks - please make it a priority; I'm at PG Conf NYC next week and
>>>> expect to be doing lots of demos.
>>>>
>>> Please find the patch for the same.
>>>
>>> This also includes some of the cleanup required to solve some of the
>>> memory leak issues.
>>>
>>> I was not able to reproduce the issue at my end, but - I've idea of when
>>> it could fail to close the panel, which I have resolved in this patch.
>>> Can you please test it?
>>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> <http://www.enterprisedb.com/;
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> <http://www.linkedin.com/in/asheshvashi;
>>>
>>>
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: http://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2016-04-15 13:02 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14 20:53 Dialogues not closing Dave Page <[email protected]>
2016-04-15 05:32 ` Ashesh Vashi <[email protected]>
2016-04-15 07:50   ` Dave Page <[email protected]>
2016-04-15 08:06     ` Ashesh Vashi <[email protected]>
2016-04-15 10:48       ` Ashesh Vashi <[email protected]>
2016-04-15 10:48         ` Ashesh Vashi <[email protected]>
2016-04-15 13:02           ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox