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

Hi Hackers,

Please ignore the earlier patch. Find the updated patch attached.


On Mon, Nov 29, 2021 at 10:33 AM Nikhil Mohite <
[email protected]> wrote:

> 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.*
>

Regards,
Nikhil Mohite


Attachments:

  [application/octet-stream] RM-6955_v2.patch (3.1K, 3-RM-6955_v2.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/static/js/tree/pgadmin_tree_save_state.js b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
index 950d0052..0c811949 100644
--- a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
+++ b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
@@ -302,7 +302,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 +364,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 +372,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: <CAOBg0APKpQD_FEtP=y2xEkJzxtJemaObZK+Y1c4K80RRjtQm5g@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