public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch] - Fixed various issues of the Macros
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch] - Fixed various issues of the Macros
@ 2021-01-20 07:24 Khushboo Vashi <[email protected]>
  2021-01-20 08:23 ` Re: [pgAdmin4][Patch] - Fixed various issues of the Macros Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Khushboo Vashi @ 2021-01-20 07:24 UTC (permalink / raw)
  To: pgadmin-hackers

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;


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin4][Patch] - Fixed various issues of the Macros
  2021-01-20 07:24 [pgAdmin4][Patch] - Fixed various issues of the Macros Khushboo Vashi <[email protected]>
@ 2021-01-20 08:23 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-01-20 08:23 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Wed, Jan 20, 2021 at 12:55 PM Khushboo Vashi <
[email protected]> wrote:

> 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
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-01-20 08:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 07:24 [pgAdmin4][Patch] - Fixed various issues of the Macros Khushboo Vashi <[email protected]>
2021-01-20 08:23 ` Akshay Joshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox