public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][patch] [Macro support] RM5908 Shortcut keys should be working with Manage macro & RM6161 Macro SQL input box cursor issue.
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][patch] [Macro support] RM5908 Shortcut keys should be working with Manage macro & RM6161 Macro SQL input box cursor issue.
@ 2021-04-09 06:00 Rahul Shirsat <[email protected]>
  2021-04-09 07:12 ` Re: [pgAdmin][patch] [Macro support] RM5908 Shortcut keys should be working with Manage macro & RM6161 Macro SQL input box cursor issue. Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Rahul Shirsat @ 2021-04-09 06:00 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Please find below patch which resolves the issues :

RM5908 <https://redmine.postgresql.org/issues/5908; Shortcut keys should be
working with Manage macro.
RM6161 <https://redmine.postgresql.org/issues/6161; Macro SQL input box
cursor issue.

The issue was not only for macro support modal, but also for other models
related to sqleditor (description in RM6161
<https://redmine.postgresql.org/issues/6161;) which is resolved in this fix.

-- 
*Rahul Shirsat*
Senior Software Engineer | EnterpriseDB Corporation.


Attachments:

  [application/octet-stream] RM5908_RM6161.patch (5.3K, 3-RM5908_RM6161.patch)
  download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js
index fa08ea560..e3b269f00 100644
--- a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js
+++ b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js
@@ -191,4 +191,4 @@ module.exports =  Alertify.dialog('createModeDlg', function() {
       }
     },
   };
-}, true, 'fileSelectionDlg');
+}, false, 'fileSelectionDlg');
diff --git a/web/pgadmin/static/js/sqleditor/macro.js b/web/pgadmin/static/js/sqleditor/macro.js
index 74c7dab2d..4af0f3af5 100644
--- a/web/pgadmin/static/js/sqleditor/macro.js
+++ b/web/pgadmin/static/js/sqleditor/macro.js
@@ -63,6 +63,17 @@ let MacroDialog = {
               className: 'btn btn-primary fa fa-save pg-alertify-button',
               'data-btn-name': 'ok',
             }],
+            focus: {
+              element: function(){
+              /*
+              returning false will focus nothing, but it will make
+              contents behind the modal accessible via Tab key,
+              so focus the dialog itself instead.
+              */
+                return $(this.elements.dialog).find('.header-icon-cell button')[0];
+              },
+              select: true,
+            },
             // Set options for dialog
             options: {
               title: title,
diff --git a/web/pgadmin/static/js/sqleditor/new_connection_dialog.js b/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
index 9fede2b07..68f1ba818 100644
--- a/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
+++ b/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
@@ -82,6 +82,17 @@ let NewConnectionDialog = {
                   'data-btn-name': 'ok',
                 },
               ],
+              focus: {
+                element: function(){
+                /*
+                returning false will focus nothing, but it will make
+                contents behind the modal accessible via Tab key,
+                so focus the dialog itself instead.
+                */
+                  return $(this.elements.dialog).find('.new-connection-dialog .nav-link.active.show');
+                },
+                select: true,
+              },
               // Set options for dialog
               options: {
                 title: title,
diff --git a/web/pgadmin/static/js/sqleditor_utils.js b/web/pgadmin/static/js/sqleditor_utils.js
index e51cab57b..332bdf133 100644
--- a/web/pgadmin/static/js/sqleditor_utils.js
+++ b/web/pgadmin/static/js/sqleditor_utils.js
@@ -8,8 +8,8 @@
 //////////////////////////////////////////////////////////////////////////
 // This file contains common utilities functions used in sqleditor modules
 
-define(['jquery', 'underscore', 'sources/gettext', 'sources/url_for'],
-  function ($, _, gettext, url_for) {
+define(['jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'pgadmin.alertifyjs'],
+  function ($, _, gettext, url_for, alertify) {
     var sqlEditorUtils = {
       /* Reference link http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
        * Modified as per requirement.
@@ -236,6 +236,23 @@ define(['jquery', 'underscore', 'sources/gettext', 'sources/url_for'],
           };
         }
       },
+
+      isModalOpen: function(dialog_list) {
+        /* check the modals inside the sqleditor are open or not */
+        if(Array.isArray(dialog_list)) {
+          for(let d of dialog_list) {
+            try {
+              if(alertify.dialog(d) && alertify.dialog(d).isOpen())
+                return true;
+            }
+            catch (err) {
+              // Do nothing
+              console.warn(err.stack || err);
+            }
+          }
+        }
+        return false;
+      },
     };
     return sqlEditorUtils;
   });
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 5da66369d..b5503255c 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -506,13 +506,23 @@ define('tools.querytool', [
                 transId = self.handler.transId;
 
               if (!$container.hasClass('wcPanelTabContentHidden')) {
-                setTimeout(function () {
-                  self.handler.gridView.query_tool_obj.focus();
-                }, 200);
-                // Trigger an event to update connection status flag
-                pgBrowser.Events.trigger(
-                  'pgadmin:query_tool:panel:gain_focus:' + transId
-                );
+
+                let modal_list = ['fileSelectionDlg', 'createModeDlg',
+                  'confirm', 'alert', 'confirmSave', 'newConnectionDialog',
+                  'macroDialog'];
+
+                /* check the modals inside the sqleditor are open, if not,
+                focus on the editor instead. */
+                if(!SqlEditorUtils.isModalOpen(modal_list)) {
+                  setTimeout(function () {
+                    self.handler.gridView.query_tool_obj.focus();
+                  }, 200);
+
+                  // Trigger an event to update connection status flag
+                  pgBrowser.Events.trigger(
+                    'pgadmin:query_tool:panel:gain_focus:' + transId
+                  );
+                }
               }
             });
 


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

* Re: [pgAdmin][patch] [Macro support] RM5908 Shortcut keys should be working with Manage macro & RM6161 Macro SQL input box cursor issue.
  2021-04-09 06:00 [pgAdmin][patch] [Macro support] RM5908 Shortcut keys should be working with Manage macro & RM6161 Macro SQL input box cursor issue. Rahul Shirsat <[email protected]>
@ 2021-04-09 07:12 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-04-09 07:12 UTC (permalink / raw)
  To: Rahul Shirsat <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Fri, Apr 9, 2021 at 11:30 AM Rahul Shirsat <
[email protected]> wrote:

> Hi Hackers,
>
> Please find below patch which resolves the issues :
>
> RM5908 <https://redmine.postgresql.org/issues/5908; Shortcut keys should
> be working with Manage macro.
> RM6161 <https://redmine.postgresql.org/issues/6161; Macro SQL input box
> cursor issue.
>
> The issue was not only for macro support modal, but also for other models
> related to sqleditor (description in RM6161
> <https://redmine.postgresql.org/issues/6161;) which is resolved in this
> fix.
>
> --
> *Rahul Shirsat*
> Senior Software Engineer | EnterpriseDB Corporation.
>


-- 
*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-04-09 07:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 06:00 [pgAdmin][patch] [Macro support] RM5908 Shortcut keys should be working with Manage macro & RM6161 Macro SQL input box cursor issue. Rahul Shirsat <[email protected]>
2021-04-09 07:12 ` 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