public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch] - Fixed various issues of the Macros
Date: Wed, 20 Jan 2021 12:54:56 +0530
Message-ID: <CAFOhELejKEuCvut78N2u8y05YU2XiD3y4=NU0N1R2j+04DOnew@mail.gmail.com> (raw)
Hi,
Please find the attached patch to fix below the issues of the macro module:
#5905 - Save button is enabled by-default
#5906 - Consistent behaviour should be displayed if user clear manage macro
#5907 - We need to fix the behaviour of Clear All Rows if user does not
enter any value
#5929 - Message "Not connected to the server or the connection to the
server has been closed." displayed if user created SQL with invalid syntax
Thanks,
Khushboo
Attachments:
[application/octet-stream] macros.patch (4.1K, 3-macros.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/sqleditor/macro.js b/web/pgadmin/static/js/sqleditor/macro.js
index c8f9292f3..74c7dab2d 100644
--- a/web/pgadmin/static/js/sqleditor/macro.js
+++ b/web/pgadmin/static/js/sqleditor/macro.js
@@ -194,6 +194,8 @@ let MacroDialog = {
// We got the latest attributes of the object. Render the view
// now.
$container.append(self.view.render().$el);
+ self.__internal.buttons[2].element.disabled = true;
+
// Enable/disable save button and show/hide statusbar based on session
self.view.listenTo(self.view.model, 'pgadmin-session:start', function() {
@@ -272,11 +274,12 @@ let MacroDialog = {
<a class="dropdown-item" id="btn-manage-macros" href="#" tabindex="0">
<span> ${gettext('Manage Macros...')} </span>
</a>
- </li>
- <li class="dropdown-divider"></li>`;
+ </li>`;
+
+ let macro_list_tmpl = '';
_.each(macros, function(m) {
if (m.name) {
- str += `<li>
+ macro_list_tmpl += `<li>
<a class="dropdown-item btn-macro" data-macro-id="${m.id}" href="#" tabindex="0">
<span> ${_.escape(m.name)} </span>
<span> (${m.key_label}) </span>
@@ -285,6 +288,7 @@ let MacroDialog = {
}
});
+ if (macro_list_tmpl.length > 0) str += '<li class="dropdown-divider"></li>' + macro_list_tmpl;
$($.find('div.btn-group.mr-1.user_macros ul.dropdown-menu')).html($(str));
self.close(); // Close the dialog now
diff --git a/web/pgadmin/static/js/sqleditor/macro_model.js b/web/pgadmin/static/js/sqleditor/macro_model.js
index 4a9351a38..7886e63b7 100644
--- a/web/pgadmin/static/js/sqleditor/macro_model.js
+++ b/web/pgadmin/static/js/sqleditor/macro_model.js
@@ -126,18 +126,22 @@ export default function macroModel(transId) {
var that = this;
// We will check if row is deletable or not
- Alertify.confirm(
- gettext('Clear All Rows'),
- gettext('Are you sure you wish to clear all rows?'),
- function() {
- _.each(that.collection.toJSON(), function(m) {
- that.collection.get(m.id).set({'name': null, 'sql': null});
- });
- },
- function() {
- return true;
- }
- );
+ let macros = that.collection.toJSON().filter(m => m.name !== undefined && m.name !== null);
+
+ if (macros.length > 0) {
+ Alertify.confirm(
+ gettext('Clear All Rows'),
+ gettext('Are you sure you wish to clear all rows?'),
+ function() {
+ _.each(that.collection.toJSON(), function(m) {
+ that.collection.get(m.id).set({'name': null, 'sql': null});
+ });
+ },
+ function() {
+ return true;
+ }
+ );
+ }
},
render: function() {
this.$el.empty();
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 05deebc41..576793252 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -4376,6 +4376,8 @@ define('tools.querytool', [
// Find the next space from the character or end of line
var error_line = self.gridView.query_tool_obj.getLine(error_line_no);
+
+ if (_.isUndefined(error_line)) return;
end_marker = error_line.indexOf(' ', start_marker);
if (end_marker < 0)
end_marker = error_line.length;
view thread (2+ 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: [pgAdmin4][Patch] - Fixed various issues of the Macros
In-Reply-To: <CAFOhELejKEuCvut78N2u8y05YU2XiD3y4=NU0N1R2j+04DOnew@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