[pgAdmin4][RM#4199] ENTER in Data Filter runs query

Akshay Joshi <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CANxoLDehLPumtMbVKFWNFfLHM6Bqr__65S_3+mXwJ5bkfHRsFA@mail.gmail.com>
Hi Hackers,

Attached is the patch to fix RM 4199 "ENTER in Data Filter runs query". To
solve this problem I have remove the key mapping of the "OK" button, which
is mapped to ENTER key and provided the alternative key combination that is
"*SHIFT + ENTER*".

I have added Placeholder message for that in code mirror.
Refer Data_Filter.png.
Please review it.

-- 
*Thanks & Regards*
*Akshay Joshi*

*Sr. Software Architect*
*EnterpriseDB Software India Private Limited*
*Mobile: +91 976-788-8246*
Data_Filter.png (image/png, 38.2 KB) - not displayed
RM_4199.patch (application/octet-stream, 2.2 KB)
diff --git a/web/pgadmin/static/bundle/codemirror.js b/web/pgadmin/static/bundle/codemirror.js
index b77c259e..972e6c22 100644
--- a/web/pgadmin/static/bundle/codemirror.js
+++ b/web/pgadmin/static/bundle/codemirror.js
@@ -25,5 +25,6 @@ import 'codemirror/addon/edit/closebrackets';
 import 'codemirror/addon/comment/comment';
 import 'sources/codemirror/addon/fold/pgadmin-sqlfoldcode';
 import 'sources/codemirror/extension/centre_on_line';
+import 'codemirror/addon/display/placeholder.js';
 
 export default CodeMirror;
diff --git a/web/pgadmin/tools/datagrid/static/js/show_data.js b/web/pgadmin/tools/datagrid/static/js/show_data.js
index c2fbc7be..85333672 100644
--- a/web/pgadmin/tools/datagrid/static/js/show_data.js
+++ b/web/pgadmin/tools/datagrid/static/js/show_data.js
@@ -128,7 +128,7 @@ function initFilterDialog(alertify, pgBrowser) {
               className: 'btn btn-secondary fa fa-times pg-alertify-button',
             },{
               text: gettext('OK'),
-              key: 13,
+              key: null,
               className: 'btn btn-primary fa fa-check pg-alertify-button',
             }],
             options: {
@@ -141,7 +141,16 @@ function initFilterDialog(alertify, pgBrowser) {
           };
         },
         build: function() {
-          alertify.pgDialogBuild.apply(this);
+          var that = this;
+          alertify.pgDialogBuild.apply(that);
+
+          // For sort/filter dialog we capture the keypress event
+          // and on "shift + enter" we clicked on "OK" button.
+          $(that.elements.body).on('keypress', function(evt) {
+            if (evt.shiftKey && evt.keyCode == 13) {
+              that.__internal.buttons[1].element.click();
+            }
+          });
         },
         prepare:function() {
           var that = this,
@@ -168,6 +177,7 @@ function initFilterDialog(alertify, pgBrowser) {
             lineWrapping: that.preferences.wrap_code,
             autoCloseBrackets: that.preferences.insert_pair_brackets,
             matchBrackets: that.preferences.brace_matching,
+            placeholder: gettext('Use SHIFT + ENTER to apply filter...'),
           });
 
           let sql_font_size = SqlEditorUtils.calcFontSize(that.preferences.sql_font_size);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.