From a693014371b85c3e48556c308096eef44680915c Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Tue, 5 Oct 2021 17:33:50 +0530 Subject: [PATCH] =?UTF-8?q?1)=20Table=20Dialogue=20does=20not=20close=20on?= =?UTF-8?q?=20addition/deletion=C2=A0of=20partition.=20Fixes=20#6863=202)?= =?UTF-8?q?=20Nodes=20are=20loaded=20multiple=20times=20in=20server=20mode?= =?UTF-8?q?=20on=20'Reset=20Layout'.=20Fixes=20#6861?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schemas/tables/static/js/table.js | 5 ++--- web/pgadmin/browser/static/js/browser.js | 10 +++++---- web/pgadmin/browser/static/js/node.js | 22 +++++++++++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index 963400145..60621c21f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -362,7 +362,6 @@ define('pgadmin.node.table', [ 'affected_partitions' in _newNodeData ) { var partitions = _newNodeData.affected_partitions, - self = this, newPartitionsIDs = [], insertChildTreeNodes = [], insertChildrenNodes = function() { @@ -409,7 +408,7 @@ define('pgadmin.node.table', [ 'parent': tablesCollNode, 'type': 'table', 'treeHierarchy': - pgAdmin.Browser.Nodes.schema.getTreeNodeHierarchy( + pgAdmin.Browser.tree.getTreeNodeHierarchy( schemaNode ), 'childrenIDs': _.clone(childIDs), @@ -460,7 +459,7 @@ define('pgadmin.node.table', [ insertChildTreeNodes.push({ 'parent': partitionsCollNode, 'type': 'partition', - 'treeHierarchy': self.getTreeNodeHierarchy(_node), + 'treeHierarchy': pgAdmin.Browser.tree.getTreeNodeHierarchy(_node), 'childrenIDs': newPartitionsIDs, }); } diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 09b10ed82..dfbbfe67d 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -1890,7 +1890,7 @@ define('pgadmin.browser', [ _parentNode = null; for (; idx < size; idx++) { - childNode = children.eq(idx); + childNode = children[idx]; childNodeData = tree_local.itemData(childNode); if (childNodeData._type == _collType) { @@ -1906,7 +1906,7 @@ define('pgadmin.browser', [ size = children.length; for (; idx < size; idx++) { - childNode = children.eq(idx); + childNode = children[idx]; childNodeData = tree_local.itemData(childNode); if (_childIds.indexOf(childNodeData._id) != -1) { @@ -1953,7 +1953,7 @@ define('pgadmin.browser', [ idx = 0, nodeData, node; for(; idx < siblings.length; idx++) { - node = siblings.eq(idx); + node = siblings[idx]; nodeData = tree_local.itemData(node); if (nodeData && nodeData._id == _id) @@ -1987,7 +1987,7 @@ define('pgadmin.browser', [ return null; for(; idx < children.length; idx++) { - node = children.eq(idx); + node = children[idx]; nodeData = tree_local.itemData(node); if (nodeData && nodeData._type == _collType) @@ -2021,6 +2021,8 @@ define('pgadmin.browser', [ null, 'nodes', childDummyInfo, true, childTreeInfo ); + var _node = _node || arguments[1]; + $.ajax({ url: childNodeUrl, dataType: 'json', diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index f886802bd..16dc4f97e 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -1046,14 +1046,28 @@ define('pgadmin.browser.node', [ let tree = pgBrowser.tree, auto_expand = pgBrowser.get_preference('browser', 'auto_expand_sole_children'); - pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', - item); - if (auto_expand && auto_expand.value == true && tree.children(item).length == 1) { // Automatically expand the child node, if a treeview node has only a single child. - tree.open(tree.first(item)); + const first_child = tree.first(item); + + if (first_child._loaded == true) { + tree.open(first_child); + } else { + const openSoleItem = setInterval(() => { + if (first_child._loaded) { + tree.open(first_child); + clearSoleItemInterval(); + } + }, 200); + const clearSoleItemInterval = function() { + clearInterval(openSoleItem); + }; + } + } + pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', item); + }, closed: function(item) { pgBrowser.Events.trigger('pgadmin:browser:tree:remove-from-tree-state',