public inbox for [email protected]  
help / color / mirror / Atom feed
Tree reload & panel close issue after saving new node on server [pgadmin4]
2+ messages / 2 participants
[nested] [flat]

* Tree reload & panel close issue after saving new node on server [pgadmin4]
@ 2016-03-31 08:04 Harshal Dhumal <[email protected]>
  2016-04-01 10:06 ` Re: Tree reload & panel close issue after saving new node on server [pgadmin4] Ashesh Vashi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Harshal Dhumal @ 2016-03-31 08:04 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

PFA patch for node.js

Issues fixed:

1] Reload node collection when server doesn't send node data for newly
created node.
2] Close create panel either when collection node matches with newly create
node type  or *collection node type matches with newly created node's
collection type.*





-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com;


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


Attachments:

  [text/x-patch] node.js_tree_reload_issue_31_March_v1.patch (3.0K, 3-node.js_tree_reload_issue_31_March_v1.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 5d6ec86..bb683ee 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -847,7 +847,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
         },
         saveNewNode = function() {
           /* TODO:: Create new tree node for this */
-          if (view.model.tnode) {
+          if (view.model.tnode && '_id' in view.model.tnode) {
             var d = _.extend({}, view.model.tnode),
               func = function(i) {
                 setTimeout(function() {
@@ -888,7 +888,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                       if (data && data._type && data._type in pgBrowser.Nodes) {
                         node = pgBrowser.Nodes[data._type];
 
-                        if (node && node.node && node.node == that.type) {
+                        if (node && ((node.node && node.node == that.type) ||
+                                node.type == that.collection_type)) {
                           found = true;
                           if (tree.wasLoad(j)) {
                             tree.append(j, {
@@ -979,6 +980,48 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                 }
               });
             }
+          } 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
+              });
+            };
+
+            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);
+                    }
+                  }
+              });
+            }
           }
         },
         editInNewPanel = function() {


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

* Re: Tree reload & panel close issue after saving new node on server [pgadmin4]
  2016-03-31 08:04 Tree reload & panel close issue after saving new node on server [pgadmin4] Harshal Dhumal <[email protected]>
@ 2016-04-01 10:06 ` Ashesh Vashi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Ashesh Vashi @ 2016-04-01 10:06 UTC (permalink / raw)
  To: Harshal Dhumal <[email protected]>; +Cc: pgadmin-hackers

Thanks - committed!

--

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 Thu, Mar 31, 2016 at 1:34 PM, Harshal Dhumal <
[email protected]> wrote:

> Hi,
>
> PFA patch for node.js
>
> Issues fixed:
>
> 1] Reload node collection when server doesn't send node data for newly
> created node.
> 2] Close create panel either when collection node matches with newly
> create node type  or *collection node type matches with newly created
> node's collection type.*
>
>
>
>
>
> --
> *Harshal Dhumal*
> *Software Engineer *
>
>
>
> EenterpriseDB <http://www.enterprisedb.com;
>
>
> --
> 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] 2+ messages in thread


end of thread, other threads:[~2016-04-01 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-31 08:04 Tree reload & panel close issue after saving new node on server [pgadmin4] Harshal Dhumal <[email protected]>
2016-04-01 10:06 ` Ashesh Vashi <[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