Subject: patch for RM1497

From: Harshal Dhumal <[email-masked]>
Date: Mon, 25 Jul 2016 16:47:40 +0530

Hi,

PFA attached for rm1497

Issue: fixed js error while re-rendering shubnode grid

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
index b404d46..6bd6195 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
@@ -371,6 +371,11 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
               titleTmpl({label: data.label})
             );
 
+      // Clean up existing grid if any (in case of re-render)
+      if (self.grid) {
+        self.grid.remove();
+      }
+
       $gridBody.append(self.generateHeader(data));
 
       var gridSchema = _.clone(this.gridSchema);
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 565c266..1413dbc 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -380,6 +380,11 @@
               titleTmpl(data)
             );
 
+      // Clean up existing grid if any (in case of re-render)
+      if (self.grid) {
+        self.grid.remove();
+      }
+
       var gridSchema = _.clone(this.gridSchema);
 
       _.each(gridSchema.columns, function(col) {
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 985ed46..eadea8a 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -967,7 +967,8 @@
       return this;
     },
     showGridControl: function(data) {
-      var gridHeader = _.template([
+      var self = this,
+          gridHeader = _.template([
           '<div class="subnode-header">',
           '  <label class="control-label pg-el-sm-10"><%-label%></label>',
           '  <button class="btn-sm btn-default add" <%=canAdd ? "" : "disabled=\'disabled\'"%>><%-add_label%></buttton>',
@@ -976,6 +977,11 @@
             gridHeader(data)
             );
 
+      // Clean up existing grid if any (in case of re-render)
+      if (self.grid) {
+        self.grid.remove();
+      }
+
       if (!(data.subnode)) {
         return '';
       }
@@ -983,8 +989,7 @@
       var subnode = data.subnode.schema ? data.subnode : data.subnode.prototype,
           gridSchema = Backform.generateGridColumnsFromModel(
             data.node_info, subnode, this.field.get('mode'), data.columns
-            ),
-          self = this;
+            );
 
       // Set visibility of Add button
       if (data.mode == 'properties') {
@@ -1201,7 +1206,8 @@
       return this;
     },
     showGridControl: function(data) {
-      var gridHeader = ["<div class='subnode-header'>",
+      var self = this,
+          gridHeader = ["<div class='subnode-header'>",
           "  <label class='control-label pg-el-sm-10'>" + data.label + "</label>" ,
           "  <button class='btn-sm btn-default add'>Add</buttton>",
           "</div>"].join("\n");
@@ -1210,9 +1216,14 @@
       var subnode = data.subnode.schema ? data.subnode : data.subnode.prototype,
           gridSchema = Backform.generateGridColumnsFromModel(
             data.node_info, subnode, this.field.get('mode'), data.columns, data.schema_node
-            ), self = this,
+            ),
           pgBrowser = window.pgAdmin.Browser;
 
+      // Clean up existing grid if any (in case of re-render)
+      if (self.grid) {
+        self.grid.remove();
+      }
+
       // Set visibility of Add button
       if (data.disabled || data.canAdd == false) {
         $(gridBody).find("button.add").remove();

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

---

From: Dave Page <[email-masked]>
Date: Mon, 25 Jul 2016 14:31:28 +0100

Thanks, applied.

On Mon, Jul 25, 2016 at 12:17 PM, Harshal Dhumal
<[email-masked]> wrote:
> Harshal Dhumal
> Software Engineer

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company