public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nikhil Mohite <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM-6955]: pgadmin 6.1: browser tree sort order not updating when renaming a server group
Date: Mon, 29 Nov 2021 10:33:46 +0530
Message-ID: <CAOBg0AP-fG0QvZL=rQQPRyA5vpDBHjuof_WimmBE=9tQew-vGQ@mail.gmail.com> (raw)

Hi Hackers,

Please find the attached patch for RM-6955:
<https://redmine.postgresql.org/issues/6955;  pgadmin 6.1: browser tree
sort order not updating when renaming a server group


-- 
*Thanks & Regards,*
*Nikhil Mohite*
*Senior Software Engineer.*
*EDB Postgres* <https://www.enterprisedb.com/;
*Mob.No: +91-7798364578.*


Attachments:

  [application/octet-stream] RM-6955.patch (4.2K, 3-RM-6955.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js
index ac7222ea..c2ad41d6 100644
--- a/web/pgadmin/browser/static/js/browser.js
+++ b/web/pgadmin/browser/static/js/browser.js
@@ -1274,7 +1274,14 @@ define('pgadmin.browser', [
             // If there is no parent then just update the node
             if(this.t.isRootNode(_parent) ||
              (_parent && _parent.length == 0 && ctx.op == 'UPDATE')) {
-              updateNode();
+              var that = this;
+              this.t.remove(this.i).then(() => {
+                that.t.before(that.i, that.new).then((new_item) => {
+                  that.t.select(new_item);
+                }, () => {
+                  console.warn('Failed to add before..', arguments);
+                });
+              });
             } else {
               var postRemove = function() {
                 // If item has parent but no grand parent
diff --git a/web/pgadmin/browser/static/js/collection.js b/web/pgadmin/browser/static/js/collection.js
index 4445892a..586cf26e 100644
--- a/web/pgadmin/browser/static/js/collection.js
+++ b/web/pgadmin/browser/static/js/collection.js
@@ -428,6 +428,7 @@ define([
                 pgBrowser.report_error(res.errormsg, res.info);
               } else {
                 $(pgBrowser.panels['properties'].panel).removeData('node-prop');
+                //pgBrowser.Events.trigger('pgadmin:browser:tree:refresh-tree-state');
                 pgBrowser.Events.trigger(
                   'pgadmin:browser:tree:refresh', sel_item || pgBrowser.tree.selected(), {
                     success: function() {
diff --git a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
index 950d0052..2f802820 100644
--- a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
+++ b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
@@ -69,6 +69,8 @@ _.extend(pgBrowser.browserTreeState, {
         this.remove_from_cache, this);
       pgBrowser.Events.on('pgadmin:browser:tree:update-tree-state',
         this.update_cache, this);
+      /*pgBrowser.Events.on('pgadmin:browser:tree:refresh-tree-state',
+        this.refresh_cache, this);*/
     } else if (!_.isUndefined(save_tree_state_period)) {
       $.ajax({
         url: url_for('settings.reset_tree_state'),
@@ -302,7 +304,7 @@ _.extend(pgBrowser.browserTreeState, {
             let index = tmpItemData.indexOf(data.id);
 
             pgBrowser.tree.open(item);
-
+            pgBrowser.tree.ensureLoaded(item);
             if (index == (tmpItemData.length - 1 )) {
               let tIndex = treeData[treeHierarchy[self.parent]['_id']]['paths'].indexOf(tData);
               treeData[treeHierarchy[self.parent]['_id']]['paths'].splice(tIndex, 1);
@@ -364,7 +366,6 @@ _.extend(pgBrowser.browserTreeState, {
       if (!_.isUndefined(databaseItem))
         this.current_state[topParent]['selected'][databaseItem] = selectedItem;
     }
-
   },
   select_tree_item(item) {
     let treeData = this.stored_state || {},
@@ -373,12 +374,12 @@ _.extend(pgBrowser.browserTreeState, {
       tmpTreeData = treeData[treeHierarchy[this.parent]['_id']];
 
 
-    if (treeHierarchy.hasOwnProperty('database')) {
-      let databaseItem = treeHierarchy['database']['id'];
+    if (treeHierarchy.hasOwnProperty('server')) {
+      let selectedItem = treeHierarchy['server']['id'];
 
-      if (tmpTreeData && 'selected' in tmpTreeData && databaseItem in tmpTreeData['selected']) {
-        if (tmpTreeData['selected'][databaseItem] == data.id) {
-          pgBrowser.tree.select(item);
+      if (tmpTreeData && 'selected' in tmpTreeData && selectedItem in tmpTreeData['selected']) {
+        if (tmpTreeData['selected'][selectedItem] == data.id) {
+          pgBrowser.tree.select(item, true, 'center');
         }
       }
     }
diff --git a/web/pgadmin/static/js/tree/tree.js b/web/pgadmin/static/js/tree/tree.js
index 42c8b129..c527ffc8 100644
--- a/web/pgadmin/static/js/tree/tree.js
+++ b/web/pgadmin/static/js/tree/tree.js
@@ -123,6 +123,10 @@ export class Tree {
     await this.tree.toggleDirectory(item);
   }
 
+  async ensureLoaded(item) {
+    await item.ensureLoaded();
+  }
+
   async ensureVisible(item){
     await this.tree.ensureVisible(item);
   }


view thread (3+ 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: [pgAdmin][RM-6955]: pgadmin 6.1: browser tree sort order not updating when renaming a server group
  In-Reply-To: <CAOBg0AP-fG0QvZL=rQQPRyA5vpDBHjuof_WimmBE=9tQew-vGQ@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