Resolve the issue related to the close query tool panel with the save query tool changes.

refs #6710
This commit is contained in:
Nikhil Mohite 2021-09-06 19:17:16 +05:30 committed by Akshay Joshi
parent c5ad2c03a2
commit f91908f627
2 changed files with 13 additions and 25 deletions

View File

@ -274,7 +274,7 @@ define('pgadmin.datagrid', [
*/
var propertiesPanel = pgBrowser.docker.findPanels('properties');
var queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, propertiesPanel[0]);
queryToolPanel.trans_id = trans_id;
showQueryTool._set_dynamic_tab(pgBrowser, browser_preferences['dynamic_tabs']);
// Set panel title and icon

View File

@ -517,9 +517,10 @@ define('tools.querytool', [
if (_.isNull(open_new_tab) || _.isUndefined(open_new_tab) || !open_new_tab.includes('qt')) {
// Listen on the panel closed event and notify user to save modifications.
_.each(pgWindow.default.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(p) {
if (p.isVisible()) {
if (p.trans_id == self.transId) {
self.currentPanel = p;
p.on(wcDocker.EVENT.CLOSING, function() {
return self.handler.check_needed_confirmations_before_closing_panel(true, p);
return self.handler.check_needed_confirmations_before_closing_panel(true);
});
// Set focus on query tool of active panel
@ -4908,7 +4909,7 @@ define('tools.querytool', [
/* Checks if there is any unsaved data changes, unsaved changes in the query
or uncommitted transactions before closing a panel */
check_needed_confirmations_before_closing_panel: function(is_close_event_call = false, panel= null) {
check_needed_confirmations_before_closing_panel: function(is_close_event_call = false) {
var self = this, msg;
/*
@ -4950,7 +4951,7 @@ define('tools.querytool', [
// No other function should call close() except through this function
// in order to perform necessary checks
self.ignore_on_close = undefined;
self.close(panel);
self.close();
}
// Return false so that the panel does not close unless close()
// is called explicitly (when all needed prompts are issued).
@ -5123,30 +5124,17 @@ define('tools.querytool', [
alertify.confirmSave(gettext('Save changes?'), msg, is_unsaved_data);
},
close: function(closePanel=null) {
close: function() {
var self = this;
pgBrowser.Events.off('pgadmin:user:logged-in', this.initTransaction);
// close specific panel
if (closePanel) {
self._close(closePanel);
} else {
// Iterate the all query tool instance and close the visible query tool instance.
_.each(pgWindow.default.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(panel) {
self._close(panel);
});
}
},
_close: function(closePanel) {
if (closePanel.isVisible()) {
window.onbeforeunload = null;
closePanel.off(wcDocker.EVENT.CLOSING);
// remove col_size object on panel close
if (!_.isUndefined(self.col_size)) {
delete self.col_size;
}
pgWindow.default.pgAdmin.Browser.docker.removePanel(closePanel);
window.onbeforeunload = null;
self.gridView.currentPanel.off(wcDocker.EVENT.CLOSING);
// remove col_size object on panel close
if (!_.isUndefined(self.col_size)) {
delete self.col_size;
}
pgWindow.default.pgAdmin.Browser.docker.removePanel(self.gridView.currentPanel);
},
/* This function is used to raise notify messages and update
* the notification grid.