public inbox for [email protected]
help / color / mirror / Atom feedFrom: Harshal Dhumal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: Tree reload & panel close issue after saving new node on server [pgadmin4]
Date: Thu, 31 Mar 2016 13:34:21 +0530
Message-ID: <CAFiP3vxC0XQr5aGiJ5co3Mft_f7EgX3xXekiQd1qgDoEKywbeQ@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-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() {
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Tree reload & panel close issue after saving new node on server [pgadmin4]
In-Reply-To: <CAFiP3vxC0XQr5aGiJ5co3Mft_f7EgX3xXekiQd1qgDoEKywbeQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox