public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
4+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
@ 2016-09-07 11:46 Surinder Kumar <[email protected]>
  2016-09-07 13:03 ` Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Dave Page <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Surinder Kumar @ 2016-09-07 11:46 UTC (permalink / raw)
  To: pgadmin-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;


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

* Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
  2016-09-07 11:46 [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Surinder Kumar <[email protected]>
@ 2016-09-07 13:03 ` Dave Page <[email protected]>
  2016-09-07 14:27   ` Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Surinder Kumar <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Dave Page @ 2016-09-07 13:03 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Hi

This doesn't apply - can you rebase it please?

Thanks.

On Wed, Sep 7, 2016 at 12:46 PM, Surinder Kumar
<[email protected]> wrote:
> 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
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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



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

* Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
  2016-09-07 11:46 [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Surinder Kumar <[email protected]>
  2016-09-07 13:03 ` Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Dave Page <[email protected]>
@ 2016-09-07 14:27   ` Surinder Kumar <[email protected]>
  2016-09-07 15:20     ` Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Dave Page <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Surinder Kumar @ 2016-09-07 14:27 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Hi

Please find updated patch with below changes:
1. A code block is formatted, previously not aligned.
2. rebased the patch.
3. Remove trailing whitespace.

On Wed, Sep 7, 2016 at 6:33 PM, Dave Page <[email protected]> wrote:

> Hi
>
> This doesn't apply - can you rebase it please?
>
> Thanks.
>
> On Wed, Sep 7, 2016 at 12:46 PM, Surinder Kumar
> <[email protected]> wrote:
> > 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
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


-- 
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_v1.patch (4.2K, 3-RM1581_v1.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..615255c 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -268,34 +268,47 @@ define(
 
         self.render_history_grid();
 
-       // Listen on the panel closed event and notify user to save modifications.
-       _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(p) {
-         if(p.isVisible()) {
-           p.on(wcDocker.EVENT.CLOSING, function() {
-             // Only if we can edit data then perform this check
-             var notify = false, msg;
-             if(self.handler.can_edit) {
-               var data_store = self.handler.data_store;
-               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; 
-               }
-             } 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, ''); 
-               // 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; 
-               } 
-             }
-             if(notify) {return self.user_confirmation(p, msg);}
-             return true;
-           });
-         }
-       });
+        // Listen on the panel closed event and notify user to save modifications.
+        _.each(window.top.pgAdmin.Browser.docker.findPanels('frm_datagrid'), function(p) {
+          if(p.isVisible()) {
+            p.on(wcDocker.EVENT.CLOSING, function() {
+              // Only if we can edit data then perform this check
+              var notify = false, msg;
+              if(self.handler.can_edit) {
+                var data_store = self.handler.data_store;
+                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;
+                }
+              } 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, '');
+                // 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;
+                }
+              }
+              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 +414,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;


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

* Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query
  2016-09-07 11:46 [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Surinder Kumar <[email protected]>
  2016-09-07 13:03 ` Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Dave Page <[email protected]>
  2016-09-07 14:27   ` Re: [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Surinder Kumar <[email protected]>
@ 2016-09-07 15:20     ` Dave Page <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Page @ 2016-09-07 15:20 UTC (permalink / raw)
  To: Surinder Kumar <[email protected]>; +Cc: pgadmin-hackers

Thanks - applied.

On Wed, Sep 7, 2016 at 3:27 PM, Surinder Kumar
<[email protected]> wrote:
> Hi
>
> Please find updated patch with below changes:
> 1. A code block is formatted, previously not aligned.
> 2. rebased the patch.
> 3. Remove trailing whitespace.
>
> On Wed, Sep 7, 2016 at 6:33 PM, Dave Page <[email protected]> wrote:
>>
>> Hi
>>
>> This doesn't apply - can you rebase it please?
>>
>> Thanks.
>>
>> On Wed, Sep 7, 2016 at 12:46 PM, Surinder Kumar
>> <[email protected]> wrote:
>> > 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
>> >
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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




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


end of thread, other threads:[~2016-09-07 15:20 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07 11:46 [pgAdmin4][Patch]: RM1581 - When switching between query tabs, the selected tab is not ready to run a query Surinder Kumar <[email protected]>
2016-09-07 13:03 ` Dave Page <[email protected]>
2016-09-07 14:27   ` Surinder Kumar <[email protected]>
2016-09-07 15:20     ` Dave Page <[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