Hi, PFA patch for Subnode grid row close issue.
Issue fixed: 1] Close any existing row while adding new row. 2] Close any existing row if we edit new row. -- *Harshal Dhumal* *Software Engineer * EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index 39e3233..e067aff 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -1163,6 +1163,30 @@ }); self.model.set(data.name, collection, {silent: true}); } + + var cellEditing = function(args){ + var self = this, + cell = args[0]; + // Search for any other rows which are open. + this.each(function(m){ + // Check if row which we are about to close is not current row. + if (cell.model != m) { + var idx = self.indexOf(m); + if (idx > -1) { + var row = grid.body.rows[idx], + editCell = row.$el.find(".subnode-edit-in-process").parent(); + // Only close row if it's open. + if (editCell.length > 0){ + var event = new Event('click'); + editCell[0].dispatchEvent(event); + } + } + } + }); + } + // Listen for any row which is about to enter in edit mode. + collection.on( "enteringEditMode", cellEditing, collection); + // Initialize a new Grid instance var grid = self.grid = new Backgrid.Grid({ columns: gridSchema.columns, @@ -1184,7 +1208,18 @@ // Add button callback $dialog.find('button.add').click(function(e) { e.preventDefault(); + // Close any existing expanded row before adding new one. + _.each(grid.body.rows, function(row){ + var editCell = row.$el.find(".subnode-edit-in-process").parent(); + // Only close row if it's open. + if (editCell.length > 0){ + var event = new Event('click'); + editCell[0].dispatchEvent(event); + } + }); + grid.insertRow({}); + var newRow = $(grid.body.rows[collection.length - 1].$el); newRow.attr("class", "new").click(function(e) { $(this).attr("class", "editable"); diff --git a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js index 7c7eb0b..4b233d2 100644 --- a/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid/backgrid.pgadmin.js @@ -190,6 +190,9 @@ }); }, enterEditMode: function () { + // Notify that we are about to enter in edit mode for current cell. + this.model.trigger("enteringEditMode", [this]); + Backgrid.Cell.prototype.enterEditMode.apply(this, arguments); /* Make sure - we listen to the click event */ this.delegateEvents();
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers