From 52780079f330146067344b44813f7cb9568ef7b5 Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Mon, 14 Dec 2020 12:02:02 +0530 Subject: [PATCH] Fixed an issue where the dirty indicator stays active even if all changes were undone. Fixes #6047 --- docs/en_US/release_notes_4_30.rst | 1 + .../tools/sqleditor/static/js/sqleditor.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/en_US/release_notes_4_30.rst b/docs/en_US/release_notes_4_30.rst index e6b07adf4..5dca2f2dd 100644 --- a/docs/en_US/release_notes_4_30.rst +++ b/docs/en_US/release_notes_4_30.rst @@ -18,4 +18,5 @@ Bug fixes ********* | `Issue #5965 `_ - Ensure that the macro query result should be download properly. +| `Issue #6047 `_ - Fixed an issue where the dirty indicator stays active even if all changes were undone. | `Issue #6058 `_ - Ensure that the rename panel should be disabled when the SQL file opened in the query tool. diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 522107cab..47d4de44b 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -3783,6 +3783,7 @@ define('tools.querytool', [ .done(function(res) { self.gridView.query_tool_obj.setValue(res); self.gridView.current_file = e; + self.gridView.query_tool_obj.file_data = res; self.setTitle(self.gridView.current_file.split('\\').pop().split('/').pop(), true); self.trigger('pgadmin-sqleditor:loading-icon:hide'); // hide cursor @@ -3817,6 +3818,7 @@ define('tools.querytool', [ 'file_name': decodeURI(e), 'file_content': self.gridView.query_tool_obj.getValue(), }; + var file_data = self.gridView.query_tool_obj.getValue(); self.trigger( 'pgadmin-sqleditor:loading-icon:show', gettext('Saving the queries in the file...') @@ -3834,6 +3836,7 @@ define('tools.querytool', [ alertify.success(gettext('File saved successfully.')); self.gridView.current_file = e; self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''), true); + self.gridView.query_tool_obj.file_data = file_data; // disable save button on file save $('#btn-save-file').prop('disabled', true); $('#btn-file-menu-save').css('display', 'none'); @@ -3892,6 +3895,18 @@ define('tools.querytool', [ $('#btn-save-file').prop('disabled', false); $('#btn-file-menu-save').css('display', 'block'); $('#btn-file-menu-dropdown').prop('disabled', false); + } else { + if(self.gridView.current_file) { + if (self.gridView.query_tool_obj.file_data == self.gridView.query_tool_obj.getValue()) { + title = self.gridView.current_file.replace(/^.*[\\\/]/g, ''); + is_dirty_editor = false; + } else { + title = self.gridView.current_file.replace(/^.*[\\\/]/g, '') + ' *'; + is_dirty_editor = true; + } + + self.setTitle(title, true, is_dirty_editor); + } } },