public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
Date: Wed, 7 Sep 2016 17:16:44 +0530
Message-ID: <CAM5-9D8weadRDyW5tbTvb1Jz+1tY940=E5U_HAL6AWpQjBBE3g@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi

*This patch contains following changes:*
1) Set focus on query tool once loaded.
2) While switching b/w panels find active tab and set focus on query tool.
3) Remove whitespace from file.

This will allow user to switch b/w panels without insisting user to click
on query tool.

Please find attached patch and review.

Thanks,
Surinder Kumar


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM1581.patch (2.5K, 3-RM1581.patch)
  download | inline diff:
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index ebc7077..5393ede 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -279,23 +279,35 @@ define(
                if(_.size(data_store.added) ||
                    _.size(data_store.updated)) {
                  msg = '{{ _('The data has been modified, but not saved. Are you sure you wish to discard the changes?') }}';
-                 notify = true;
+                 notify = true;
                }
              } else if(self.handler.is_query_tool) {
                // We will check for modified sql content
                var sql = self.handler.gridView.query_tool_obj.getValue();
-               sql = sql.replace(/\s+/g, '');
+               sql = sql.replace(/\s+/g, '');
                // If it is an empty query, do nothing.
                if (sql.length > 0) {
                  msg = '{{ _('The query has been modified, but not saved. Are you sure you wish to discard the changes?') }}';
-                 notify = true;
-               }
+                 notify = true;
+               }
              }
              if(notify) {return self.user_confirmation(p, msg);}
              return true;
            });
+           // Set focus on query tool of active panel
+           p.on(wcDocker.EVENT.GAIN_FOCUS, function() {
+             if (!$(p.$container).hasClass('wcPanelTabContentHidden')) {
+               setTimeout(function() {
+                 self.handler.gridView.query_tool_obj.focus();
+               }, 200);
+             }
+           });
          }
        });
+       // set focus on query tool once loaded
+       setTimeout(function() {
+          self.query_tool_obj.focus();
+       }, 500);

         /* We have override/register the hint function of CodeMirror
          * to provide our own hint logic.
@@ -401,8 +413,8 @@ define(

       /* To prompt user for unsaved changes */
       user_confirmation: function(panel, msg) {
-        // If there is anything to save then prompt user
-          alertify.confirm('{{ _('Unsaved changes') }}', msg,
+        // If there is anything to save then prompt user
+          alertify.confirm('{{ _('Unsaved changes') }}', msg,
             function() {
               // Do nothing as user do not want to save, just continue
               window.onbeforeunload = null;


view thread (4+ 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]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
  In-Reply-To: <CAM5-9D8weadRDyW5tbTvb1Jz+1tY940=E5U_HAL6AWpQjBBE3g@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